ucommon-6.0.7/0000755000175000017500000000000012175176706010216 500000000000000ucommon-6.0.7/commoncpp-config.cmake0000755000175000017500000000427712163025062014374 00000000000000#!/bin/sh # Copyright (C) 2006-2007 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. prefix=${CMAKE_INSTALL_PREFIX} exec_prefix=${CMAKE_INSTALL_PREFIX}/bin includedir=${CMAKE_INSTALL_PREFIX}/include libdir=${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} usage() { cat < 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 Software 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 . ucommon-6.0.7/commoncpp.pc.cmake0000644000175000017500000000043412163025062013516 00000000000000prefix=${CMAKE_INSTALL_PREFIX} libdir=${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} includedir=${CMAKE_INSTALL_PREFIX}/include Name: ucommon Description: GNU Common C++ class framework Version: ${PACKAGE_FILE_VERSION} Libs: -lcommoncpp -lucommon ${PACKAGE_LIBS} Cflags: ${PACKAGE_FLAGS} ucommon-6.0.7/commoncpp/0000755000175000017500000000000012175176705012210 500000000000000ucommon-6.0.7/commoncpp/map.cpp0000644000175000017500000001301512163025062013373 00000000000000// Copyright (C) 2004-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include using namespace COMMONCPP_NAMESPACE; MapIndex& MapIndex::operator=(MapObject *theObject) { thisObject = theObject; return *this; } MapIndex& MapIndex::operator++() { if ( thisObject == NULL ) return *this; if (thisObject->nextObject != NULL) { thisObject = thisObject->nextObject; } else if (thisObject->table != NULL) { MapObject* obj = NULL; unsigned i = thisObject->table->getIndex(thisObject->idObject) + 1; thisObject->table->enterMutex(); for ( ; obj == NULL && i < thisObject->table->range; i++) obj = thisObject->table->map[i]; thisObject->table->leaveMutex(); thisObject = obj; } return *this; } MapTable::MapTable(unsigned size) : Mutex() { map = new MapObject *[size + 1]; memset(map, 0, sizeof(MapObject *) * (size + 1)); range = size; count = 0; } MapTable::~MapTable() { cleanup(); } void MapTable::cleanup(void) { enterMutex(); if(map) delete[] map; map = NULL; leaveMutex(); } unsigned MapTable::getIndex(const char *id) { unsigned key = 0; while(*id) key = (key << 1) ^ (*(id++) & 0x1f); return key % range; } void *MapTable::getObject(const char *id) { if(!map) return NULL; enterMutex(); MapObject *obj = map[getIndex(id)]; while(obj) { if(!stricmp(obj->idObject, id)) break; obj = obj->nextObject; } leaveMutex(); return (void *)obj; } void *MapTable::getFirst() { MapObject *obj; if(!map) return NULL; enterMutex(); obj = *map; for (register unsigned i = 0; obj == NULL && i < range; i++) obj = map[i]; leaveMutex(); return obj; } void *MapTable::getLast() { MapObject *obj = NULL; if(!map) return NULL; enterMutex(); for (register int i = range - 1; obj == NULL && i >= 0; i--) obj = map[i]; if ( obj != NULL ) while ( obj->nextObject != NULL ) obj = obj->nextObject; leaveMutex(); return obj; } void *MapTable::getFree(void) { enterMutex(); MapObject *obj = map[range]; if(obj) map[range] = obj->nextObject; leaveMutex(); return obj; } void MapTable::addFree(MapObject *obj) { obj->detach(); enterMutex(); obj->nextObject = map[range]; map[range] = obj; leaveMutex(); } void MapTable::addObject(MapObject &obj) { unsigned idx = getIndex(obj.idObject); if(obj.table == this || !map) return; obj.detach(); enterMutex(); obj.nextObject = map[idx]; map[idx] = &obj; obj.table = this; count++; leaveMutex(); } MapTable &MapTable::operator+=(MapObject &obj) { addObject(obj); return *this; } MapTable &MapTable::operator-=(MapObject &obj) { if(obj.table == this) obj.detach(); return *this; } MapObject::MapObject(const char *id) { table = NULL; idObject = id; } void MapObject::detach(void) { MapObject *node, *prev = NULL; unsigned idx; if(!table) return; idx = table->getIndex(idObject); table->enterMutex(); node = table->map[idx]; while(node) { if(node == this) break; prev = node; node = prev->nextObject; } if(node && !prev) table->map[idx] = nextObject; else if(node) prev->nextObject = nextObject; table->count--; table->leaveMutex(); table = NULL; } ucommon-6.0.7/commoncpp/process.cpp0000644000175000017500000004141512163025062014301 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include #include #include #ifdef HAVE_FCNTL_H #include #endif #ifdef MACOSX #undef _POSIX_PRIORITY_SCHEDULING #endif #ifndef _MSWINDOWS_ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_WAIT_H #include #endif #include #include #ifdef SIGTSTP #include #include #endif #ifndef _PATH_TTY #define _PATH_TTY "/dev/tty" #endif #endif #ifdef _MSWINDOWS_ #include #include #endif using namespace COMMONCPP_NAMESPACE; bool Process::rtflag = false; #ifdef _MSWINDOWS_ static SYSTEM_INFO sysinfo; static LPSYSTEM_INFO lpSysInfo = NULL; static void init_sysinfo(void) { if(!lpSysInfo) { lpSysInfo = &sysinfo; memset(&sysinfo, 0, sizeof(sysinfo)); GetSystemInfo(lpSysInfo); } } const char *Process::getUser(void) { static char userid[65]; DWORD length = sizeof(userid); if(GetUserName(userid, &length)) return userid; return NULL; } size_t Process::getPageSize(void) { init_sysinfo(); return (size_t) lpSysInfo->dwPageSize; } int Process::spawn(const char *exename, const char **args, bool wait) { int mode = P_NOWAIT; if(wait) mode = P_WAIT; return (int)::spawnvp(mode, (char *)exename, (char **)args); } int Process::join(int pid) { int status, result; if(pid == -1) return pid; result = (int)cwait(&status, pid, WAIT_CHILD); if(status & 0x0) return -1; return result; } bool Process::cancel(int pid, int sig) { HANDLE hPid = OpenProcess(PROCESS_TERMINATE, FALSE, pid); bool rtn = true; if(!hPid) return false; switch(sig) { case SIGABRT: case SIGTERM: if(!TerminateProcess(hPid, -1)) rtn = false; case 0: break; default: rtn = false; } CloseHandle(hPid); return rtn; } void Process::setPriority(int pri) { DWORD pc = NORMAL_PRIORITY_CLASS; DWORD pid = GetCurrentProcessId(); HANDLE hProcess = OpenProcess(PROCESS_DUP_HANDLE, TRUE, pid); #ifdef BELOW_NORMAL_PRIORITY_CLASS if(pri == -1) pc = BELOW_NORMAL_PRIORITY_CLASS; else if(pri == 1) pc = ABOVE_NORMAL_PRIORITY_CLASS; else #endif if(pri == 2) pc = HIGH_PRIORITY_CLASS; else if(pri > 2) pc = REALTIME_PRIORITY_CLASS; else if(pri < -1) pc = IDLE_PRIORITY_CLASS; SetPriorityClass(hProcess, pc); CloseHandle(hProcess); } void Process::setScheduler(const char *cp) { if(!stricmp(cp, "fifo")) setPriority(3); else if(!stricmp(cp, "rr")) setPriority(2); else if(!stricmp(cp, "idle")) setPriority(-2); else setPriority(0); } void Process::setRealtime(int pri) { setPriority(3); } bool Process::isScheduler(void) { return false; } #else #ifndef WEXITSTATUS #define WEXITSTATUS(status) ((unsigned)(status) >> 8) #endif #ifndef WIFEXITED #define WIFEXITED(status) (((status) & 255) == 0) #endif #ifndef WTERMSIG #define WTERMSIG(status) (((unsigned)(status)) & 0x7F) #endif #ifndef WIFSIGNALLED #define WIFSIGNALLED(status) (((status) & 255) != 0) #endif #ifndef WCOREDUMP #define WCOREDUMP(status) (((status) & 0x80) != 0) #endif static char *_pUser = NULL; static char *_pHome = NULL; static void lookup(void) { struct passwd *pw = NULL; #ifdef HAVE_GETPWUID_R struct passwd pwd; char buffer[1024]; ::getpwuid_r(geteuid(), &pwd, buffer, 1024, &pw); #else pw = ::getpwuid(geteuid()); #endif if(_pHome) delString(_pHome); if(_pUser) delString(_pUser); _pUser = _pHome = NULL; if(pw != NULL && pw->pw_dir != NULL) _pHome = newString(pw->pw_dir); if(pw != NULL && pw->pw_name != NULL) _pUser = newString(pw->pw_name); endpwent(); } const char *Process::getUser(void) { if(!_pUser) lookup(); return (const char *)_pUser; } const char *Process::getConfigDir(void) { #ifdef ETC_CONFDIR return ETC_CONFDIR; #else return "/etc"; #endif } const char *Process::getHomeDir(void) { if(!_pHome) lookup(); return (const char *)_pHome; } #ifdef HAVE_GETPAGESIZE size_t Process::getPageSize(void) { return (size_t)getpagesize(); } #else size_t Process::getPageSize(void) { return 1024; } #endif bool Process::setUser(const char *id, bool grp) { struct passwd *pw = NULL; #ifdef HAVE_GETPWNAM_R struct passwd pwd; char buffer[1024]; ::getpwnam_r(id, &pwd, buffer, 1024, &pw); #else pw = ::getpwnam(id); #endif if(!pw) return false; if(grp) if(setgid(pw->pw_gid)) return false; if(setuid(pw->pw_uid)) return false; lookup(); return true; } bool Process::setGroup(const char *id) { struct group *group = NULL; #ifdef HAVE_GETGRNAM_R struct group grp; char buffer[2048]; ::getgrnam_r(id, &grp, buffer, 1024, &group); #else group = ::getgrnam(id); #endif if(!group) { endgrent(); return false; } #ifdef HAVE_SETEGID setegid(group->gr_gid); #endif if(setgid(group->gr_gid)) { endgrent(); return false; } endgrent(); return true; } bool Process::cancel(int pid, int sig) { if(!sig) sig = SIGTERM; if(pid < 1) return false; if(::kill(pid, sig)) return false; return true; } int Process::join(int pid) { int status; if(pid < 1) return -1; #ifdef HAVE_WAITPID waitpid(pid, &status, 0); #else #ifdef HAVE_WAIT4 wait4(pid, &status, 0, NULL); #else int result; while((result = ::wait(&status)) != pid && result != -1) ; #endif #endif if(WIFEXITED(status)) return WEXITSTATUS(status); else if(WIFSIGNALLED(status)) return -WTERMSIG(status); else return -1; } int Process::spawn(const char *exename, const char **args, bool wait) { int pid; pid = vfork(); if(pid == -1) return -1; if(!pid) { execvp((char *)exename, (char **)args); _exit(-1); } if(!wait) return pid; return join(pid); } Process::Trap Process::setInterruptSignal(int signo, Trap func) { struct sigaction sig_act, old_act; memset(&sig_act, 0, sizeof(sig_act)); sig_act.sa_handler = func; sigemptyset(&sig_act.sa_mask); if(signo != SIGALRM) sigaddset(&sig_act.sa_mask, SIGALRM); sig_act.sa_flags = 0; #ifdef SA_INTERRUPT sig_act.sa_flags |= SA_INTERRUPT; #endif if(sigaction(signo, &sig_act, &old_act) < 0) return SIG_ERR; return old_act.sa_handler; } Process::Trap Process::setPosixSignal(int signo, Trap func) { struct sigaction sig_act, old_act; memset(&sig_act, 0, sizeof(sig_act)); sig_act.sa_handler = func; sigemptyset(&sig_act.sa_mask); sig_act.sa_flags = 0; if(signo == SIGALRM) { #ifdef SA_INTERRUPT sig_act.sa_flags |= SA_INTERRUPT; #endif } else { sigaddset(&sig_act.sa_mask, SIGALRM); #ifdef SA_RESTART sig_act.sa_flags |= SA_RESTART; #endif } if(sigaction(signo, &sig_act, &old_act) < 0) return SIG_ERR; return old_act.sa_handler; } void Process::detach(void) { attach("/dev/null"); } void Process::attach(const char *dev) { int pid; if(getppid() == 1) return; ::close(0); ::close(1); ::close(2); #ifdef SIGTTOU setPosixSignal(SIGTTOU, SIG_IGN); #endif #ifdef SIGTTIN setPosixSignal(SIGTTIN, SIG_IGN); #endif #ifdef SIGTSTP setPosixSignal(SIGTSTP, SIG_IGN); #endif if((pid = fork()) < 0) THROW(pid); else if(pid > 0) exit(0); #if defined(SIGTSTP) && defined(TIOCNOTTY) int fd; if(setpgid(0, getpid()) == -1) THROW(-1); if((fd = open(_PATH_TTY, O_RDWR)) >= 0) { ioctl(fd, TIOCNOTTY, NULL); close(fd); } #else #ifdef HAVE_SETPGRP if(setpgrp() == -1) THROW(-1); #else if(setpgid(0, getpid()) == -1) THROW(-1); #endif setPosixSignal(SIGHUP, SIG_IGN); if((pid = fork()) < 0) THROW(-1); else if(pid > 0) exit(0); #endif if(dev && *dev) { ::open(dev, O_RDWR); ::open(dev, O_RDWR); ::open(dev, O_RDWR); } } void Process::setScheduler(const char *pol) { #ifdef _POSIX_PRIORITY_SCHEDULING struct sched_param p; int policy, orig; pthread_t ptid = pthread_self(); if(pthread_getschedparam(ptid, &policy, &p)) return; orig = policy; if(pol) { #if defined(SCHED_TS) policy = SCHED_TS; #elif defined(SCHED_OTHER) policy = SCHED_OTHER; #else policy = 0; #endif #ifdef SCHED_RR if(ucommon::eq_case(pol, "rr")) policy = SCHED_RR; #endif #if !defined(SCHED_RR) && defined(SCHED_FIFO) if(ucommon::eq_case(pol, "rr")) policy = SCHED_FIFO; #endif #ifdef SCHED_FIFO if(ucommon::eq_case(pol, "fifo")) { rtflag = true; policy = SCHED_FIFO; } #endif #ifdef SCHED_TS if(ucommon::eq_case(pol, "ts")) policy = SCHED_TS; #endif #ifdef SCHED_OTHER if(ucommon::eq_case(pol, "other")) policy = SCHED_OTHER; #endif } else policy = orig; int min = sched_get_priority_min(policy); int max = sched_get_priority_max(policy); if(p.sched_priority < min) p.sched_priority = min; else if(p.sched_priority > max) p.sched_priority = max; pthread_setschedparam(ptid, policy, &p); #endif } void Process::setPriority(int pri) { #ifdef _POSIX_PRIORITY_SCHEDULING struct sched_param p; int policy; pthread_t ptid = pthread_self(); pthread_getschedparam(ptid, &policy, &p); int min = sched_get_priority_min(policy); int max = sched_get_priority_max(policy); if(pri < min) pri = min; if(pri > max) pri = max; p.sched_priority = pri; pthread_setschedparam(ptid, policy, &p); #else if(pri < -20) pri = -20; if(pri > 20) pri = 20; nice(-pri); #endif } bool Process::isScheduler(void) { #ifdef _POSIX_PRIORITY_SCHEDULING return true; #else return false; #endif } void Process::setRealtime(int pri) { if(pri < 1) pri = 1; setScheduler("rr"); setPriority(pri); } #endif #ifdef _OSF_SOURCE #undef HAVE_SETENV #endif void Process::setEnv(const char *name, const char *value, bool overwrite) { #ifdef HAVE_SETENV ::setenv(name, value, (int)overwrite); #else char strbuf[256]; snprintf(strbuf, sizeof(strbuf), "%s=%s", name, value); if(!overwrite) if(getenv(strbuf)) return; ::putenv(strdup(strbuf)); #endif } const char *Process::getEnv(const char *name) { return ::getenv(name); } #if defined(HAVE_MLOCKALL) && defined(MCL_FUTURE) #include bool Process::lock(bool future) { int rc; if(future) rc = mlockall(MCL_CURRENT | MCL_FUTURE); else rc = mlockall(MCL_CURRENT); if(rc) return false; return true; } void Process::unlock(void) { munlockall(); } #else bool Process::lock(bool future) { return false; } void Process::unlock(void) { } #endif #ifdef _MSWINDOWS_ Lockfile::Lockfile() { _mutex = INVALID_HANDLE_VALUE; _flagged = false; } Lockfile::Lockfile(const char *name) { _mutex = INVALID_HANDLE_VALUE; _flagged = false; lock(name); } bool Lockfile::lock(const char *name) { char mname[65]; char *ext = strrchr((char *)name, '/'); if(ext) name = ++ext; unlock(); snprintf(mname, sizeof(mname) - 4, "_lock_%s", name); ext = strrchr(mname, '.'); if(ext && !stricmp(ext, ".lock")) { *ext = 0; ext = NULL; } if(!ext) addString(mname, sizeof(mname), ".lck"); _mutex = CreateMutex(NULL, FALSE, mname); if(WaitForSingleObject(_mutex, 200) == WAIT_OBJECT_0) _flagged = true; return _flagged; } void Lockfile::unlock(void) { if(_mutex == INVALID_HANDLE_VALUE) return; if(_flagged) ReleaseMutex(_mutex); CloseHandle(_mutex); _flagged = false; _mutex = INVALID_HANDLE_VALUE; } bool Lockfile::isLocked(void) { return _flagged; } #else Lockfile::Lockfile() { _path = NULL; } Lockfile::Lockfile(const char *name) { _path = NULL; lock(name); } bool Lockfile::lock(const char *name) { struct stat ino; int fd, pid, status; const char *ext; char buffer[128]; bool rtn = true; unlock(); ext = strrchr(name, '/'); if(ext) ext = strrchr(ext, '.'); else ext = strrchr(name, '.'); if(strchr(name, '/')) { _path = new char[strlen(name) + 1]; strcpy(_path, name); } else if(ext && !strcmp(ext, ".pid")) { if(stat("/var/run", &ino)) snprintf(buffer, sizeof(buffer), "/tmp/.%s", name); else snprintf(buffer, sizeof(buffer), "/var/run/%s", name); _path = new char[strlen(buffer) + 1]; strcpy(_path, buffer); } else { if(!ext) ext = ".lock"; if(stat("/var/lock", &ino)) snprintf(buffer, sizeof(buffer), "/tmp/.%s%s", name, ext); else snprintf(buffer, sizeof(buffer), "/var/lock/%s%s", name, ext); _path = new char[strlen(buffer) + 1]; strcpy(_path, buffer); } for(;;) { fd = ::open(_path, O_WRONLY | O_CREAT | O_EXCL, 0660); if(fd > 0) { pid = getpid(); snprintf(buffer, sizeof(buffer), "%d\n", pid); if(::write(fd, buffer, strlen(buffer))) rtn = false; ::close(fd); return rtn; } if(fd < 0 && errno != EEXIST) { delete[] _path; return false; } fd = ::open(_path, O_RDONLY); if(fd < 0) { if(errno == ENOENT) continue; delete[] _path; return false; } Thread::sleep(2000); status = ::read(fd, buffer, sizeof(buffer) - 1); if(status < 1) { ::close(fd); continue; } buffer[status] = 0; pid = atoi(buffer); if(pid) { if(pid == getpid()) { status = -1; errno = 0; } else status = kill(pid, 0); if(!status || (errno == EPERM)) { ::close(fd); delete[] _path; return false; } } ::close(fd); ::unlink(_path); } } void Lockfile::unlock(void) { if(_path) { remove(_path); delete[] _path; _path = NULL; } } bool Lockfile::isLocked(void) { if(_path) return true; return false; } #endif ucommon-6.0.7/commoncpp/dccp.cpp0000644000175000017500000004226412163025062013537 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include #ifdef _MSWINDOWS_ #include #define _IOLEN64 (unsigned) #define _IORET64 (int) typedef int socklen_t; #define socket_errno WSAGetLastError() #else #include #include #ifdef HAVE_NET_IP6_H #include #endif #define socket_errno errno # ifndef O_NONBLOCK # define O_NONBLOCK O_NDELAY # endif # ifdef IPPROTO_IP # ifndef SOL_IP # define SOL_IP IPPROTO_IP # endif // !SOL_IP # endif // IPPROTO_IP #endif // !WIN32 #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK (unsigned long)0x7f000001 #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_FILIO_H #include #endif #if defined(__hpux) #define _XOPEN_SOURCE_EXTENDED #endif #ifdef HAVE_NET_IF_H #include #endif #ifndef _IOLEN64 #define _IOLEN64 #endif #ifndef _IORET64 #define _IORET64 #endif using namespace COMMONCPP_NAMESPACE; DCCPSocket::DCCPSocket(Family fam) : Socket(fam, SOCK_DCCP, IPPROTO_DCCP) { family = fam; } DCCPSocket::DCCPSocket(DCCPSocket& server, timeout_t timeout) : Socket(accept(server.so, NULL, NULL)) { family = server.family; Socket::state = CONNECTED; socklen_t alen = sizeof(peer); getpeername(so, (struct sockaddr *)&peer, &alen); switch(family) { #ifdef CCXX_IPV6 case IPV6: if(!server.onAccept(IPV6Host(peer.ipv6.sin6_addr), peer.ipv6.sin6_port)) endSocket(); break; #endif case IPV4: if(!server.onAccept(IPV4Host(peer.ipv4.sin_addr), peer.ipv4.sin_port)) endSocket(); break; } } #ifdef HAVE_GETADDRINFO DCCPSocket::DCCPSocket(const char *name, Family fam, unsigned backlog) : Socket(fam, SOCK_DCCP, IPPROTO_DCCP) { char namebuf[128], *cp; struct addrinfo hint, *list = NULL, *first; snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { cp = namebuf; name = NULL; } else { name = namebuf; *(cp++) = 0; if(!strcmp(name, "*")) name = NULL; } family = fam; memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = SOCK_DCCP; hint.ai_protocol = IPPROTO_DCCP; hint.ai_flags = AI_PASSIVE; if(getaddrinfo(name, cp, &hint, &list) || !list) { endSocket(); error(errBindingFailed, (char *)"Could not find service", errno); return; } #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif first = list; while(list) { if(!bind(so, list->ai_addr, (socklen_t)list->ai_addrlen)) { state = BOUND; break; } list = list->ai_next; } freeaddrinfo(first); if(state != BOUND) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } } #else DCCPSocket::DCCPSocket(const char *name, Family fam, unsigned backlog) : Socket(fam, SOCK_DCCP, IPPROTO_DCCP) { char namebuf[128], *cp; struct sockaddr_in addr; #ifdef CCXX_IPV6 struct sockaddr_in6 addr6; #endif struct sockaddr *ap = NULL; socklen_t alen = 0; struct servent *svc; family = fam; memset(&addr, 0, sizeof(addr)); snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { cp = namebuf; name = "*"; } else { name = namebuf; *(cp++) = 0; } addr.sin_family = family; if(isdigit(*cp)) addr.sin_port = htons(atoi(cp)); else { mutex.enter(); svc = getservbyname(cp, "dccp"); if(svc) addr.sin_port = svc->s_port; mutex.leave(); if(!svc) { endSocket(); error(errBindingFailed, "Could not find service", errno); return; } } #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif switch(family) { #ifdef CCXX_IPV6 case IPV6: { IPV6Address ia6(name); addr6.sin6_port = addr.sin_port; addr6.sin6_family = family; addr6.sin6_addr = getaddress(ia6); ap = (struct sockaddr *)&addr6; alen = sizeof(addr6); break; } #endif case IPV4: IPV4Address ia(name); addr.sin_addr = getaddress(ia); ap = (struct sockaddr *)&addr; alen = sizeof(addr); break; } if(!ap || bind(so, (struct sockaddr *)ap, alen)) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket", socket_errno); return; } state = BOUND; } #endif DCCPSocket::DCCPSocket(const IPV4Address &ia, tpport_t port, unsigned backlog) : Socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP) { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr = getaddress(ia); addr.sin_port = htons(port); family = IPV4; memset(&peer, 0, sizeof(peer)); peer.ipv4 = addr; #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&addr, sizeof(addr))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } state = BOUND; } #ifdef CCXX_IPV6 DCCPSocket::DCCPSocket(const IPV6Address &ia, tpport_t port, unsigned backlog) : Socket(AF_INET6, SOCK_DCCP, IPPROTO_DCCP) { struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_addr = getaddress(ia); addr.sin6_port = htons(port); family = IPV6; memset(&peer, 0, sizeof(peer)); peer.ipv6 = addr; #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&addr, sizeof(addr))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } state = BOUND; } bool DCCPSocket::onAccept(const IPV6Host &ia, tpport_t port) { return true; } #endif bool DCCPSocket::onAccept(const IPV4Host &ia, tpport_t port) { return true; } IPV4Host DCCPSocket::getIPV4Sender(tpport_t *port) const { if(port) *port = ntohs(peer.ipv4.sin_port); return IPV4Host(peer.ipv4.sin_addr); } #ifdef CCXX_IPV6 IPV6Host DCCPSocket::getIPV6Sender(tpport_t *port) const { return IPV6Host(peer.ipv6.sin6_addr); } #endif DCCPSocket::~DCCPSocket() { endSocket(); } void DCCPSocket::disconnect(void) { if(Socket::state != CONNECTED) return; endSocket(); so = socket(family, SOCK_DCCP, IPPROTO_DCCP); if(so != INVALID_SOCKET) Socket::state = AVAILABLE; } #ifdef HAVE_GETADDRINFO void DCCPSocket::connect(const char *target) { char namebuf[128]; char *cp; struct addrinfo hint, *list = NULL, *next, *first; bool connected = false; snprintf(namebuf, sizeof(namebuf), "%s", target); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { connectError(); return; } *(cp++) = 0; memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = SOCK_DCCP; hint.ai_protocol = IPPROTO_DCCP; if(getaddrinfo(namebuf, cp, &hint, &list) || !list) { connectError(); return; } first = list; while(list) { if(!::connect(so, list->ai_addr, (socklen_t)list->ai_addrlen)) { connected = true; break; } next = list->ai_next; list = next; } freeaddrinfo(first); if(!connected) { connectError(); return; } Socket::state = CONNECTED; } #else void DCCPSocket::connect(const char *target) { char namebuf[128]; char *cp; struct servent *svc; tpport_t port; snprintf(namebuf, sizeof(namebuf), "%s", target); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { connectError(); return; } *(cp++) = 0; if(isdigit(*cp)) port = atoi(cp); else { mutex.enter(); svc = getservbyname(cp, "dccp"); if(svc) port = ntohs(svc->s_port); mutex.leave(); if(!svc) { connectError(); return; } } switch(family) { case IPV4: connect(IPV4Host(namebuf), port); break; #ifdef CCXX_IPV6 case IPV6: connect(IPV6Host(namebuf), port); break; #endif default: connectError(); } } #endif void DCCPSocket::connect(const IPV4Host &host, tpport_t port, timeout_t timeout) { size_t i; fd_set fds; struct timeval to; bool connected = false; int rtn; int sockopt; socklen_t len = sizeof(sockopt); for(i = 0 ; i < host.getAddressCount(); i++) { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr = host.getAddress(i); addr.sin_port = htons(port); if(timeout) setCompletion(false); // Win32 will crash if you try to connect to INADDR_ANY. if ( INADDR_ANY == addr.sin_addr.s_addr ) addr.sin_addr.s_addr = INADDR_LOOPBACK; rtn = ::connect(so, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)); if(!rtn) { connected = true; break; } #ifndef _MSWINDOWS_ if(errno == EINPROGRESS) #else if(WSAGetLastError() == WSAEINPROGRESS) #endif { FD_ZERO(&fds); FD_SET(so, &fds); to.tv_sec = timeout / 1000; to.tv_usec = timeout % 1000 * 1000; // timeout check for connect completion if(::select((int)so + 1, NULL, &fds, NULL, &to) < 1) continue; getsockopt(so, SOL_SOCKET, SO_ERROR, (char *)&sockopt, &len); if(!sockopt) { connected = true; break; } endSocket(); so = socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP); if(so == INVALID_SOCKET) break; } } setCompletion(true); if(!connected) { rtn = errno; errno = rtn; connectError(); return; } Socket::state = CONNECTED; } #ifdef CCXX_IPV6 void DCCPSocket::connect(const IPV6Host &host, tpport_t port, timeout_t timeout) { size_t i; fd_set fds; struct timeval to; bool connected = false; int rtn; int sockopt; socklen_t len = sizeof(sockopt); for(i = 0 ; i < host.getAddressCount(); i++) { struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_addr = host.getAddress(i); addr.sin6_port = htons(port); if(timeout) setCompletion(false); // Win32 will crash if you try to connect to INADDR_ANY. if ( !memcmp(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any))) memcpy(&addr.sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)); rtn = ::connect(so, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)); if(!rtn) { connected = true; break; } #ifndef _MSWINDOWS_ if(errno == EINPROGRESS) #else if(WSAGetLastError() == WSAEINPROGRESS) #endif { FD_ZERO(&fds); FD_SET(so, &fds); to.tv_sec = timeout / 1000; to.tv_usec = timeout % 1000 * 1000; // timeout check for connect completion if(::select((int)so + 1, NULL, &fds, NULL, &to) < 1) continue; getsockopt(so, SOL_SOCKET, SO_ERROR, (char *)&sockopt, &len); if(!sockopt) { connected = true; break; } endSocket(); so = socket(AF_INET6, SOCK_DCCP, IPPROTO_DCCP); if(so == INVALID_SOCKET) break; } } setCompletion(true); if(!connected) { rtn = errno; errno = rtn; connectError(); return; } Socket::state = CONNECTED; } #endif bool DCCPSocket::setCCID(uint8_t ccid) { uint8_t ccids[16]; /* for getting the available CCIDs, should be large enough */ socklen_t len = sizeof(ccids); int ret; bool ccid_supported = false; /* * Determine which CCIDs are available on the host */ ret = getsockopt(so, SOL_DCCP, DCCP_SOCKOPT_AVAILABLE_CCIDS, (char *)&ccids, &len); if (ret < 0) { error(errInput,(char *)"Can not determine available CCIDs",socket_errno); return false; } for (unsigned i = 0; i < sizeof(ccids); i++) { if (ccid == ccids[i]) { ccid_supported = true; break; } } if (!ccid_supported) { error(errInput,(char *)"CCID specified is not supported",socket_errno); return false; } if (setsockopt(so, SOL_DCCP, DCCP_SOCKOPT_CCID, (char *)&ccid, sizeof (ccid)) < 0) { error(errInput,(char *)"Can not set CCID",socket_errno); return false; } return true; } int DCCPSocket::getTxCCID() { int ccid, ret; socklen_t ccidlen; ccidlen = sizeof(ccid); ret = getsockopt(so, SOL_DCCP, DCCP_SOCKOPT_TX_CCID, (char *)&ccid, &ccidlen); if (ret < 0) { error(errInput,(char *)"Can not determine get current TX CCID value",socket_errno); return -1; } return ccid; } int DCCPSocket::getRxCCID() { int ccid, ret; socklen_t ccidlen; ccidlen = sizeof(ccid); ret = getsockopt(so, SOL_DCCP, DCCP_SOCKOPT_RX_CCID, (char *)&ccid, &ccidlen); if (ret < 0) { error(errInput,(char *)"Can not determine get current DX CCID value",socket_errno); return -1; } return ccid; } size_t DCCPSocket::available() { size_t readsize; #ifndef _MSWINDOWS_ if (ioctl (so, FIONREAD, &readsize) < 0) { error(errInput,(char *)"Error on retrieve the FIONREAD option.",socket_errno); } #else if (ioctlsocket(so, FIONREAD, (u_long *)&readsize)){ error(errInput,(char *)"Error on retrieve the FIONREAD option.",socket_errno); } #endif return readsize; } ucommon-6.0.7/commoncpp/exception.cpp0000644000175000017500000000730612163025062014622 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 #endif #include #include #include #include #include #if defined(CCXX_EXCEPTIONS) using namespace COMMONCPP_NAMESPACE; Exception::Exception(const String& what_arg) throw(): _what(what_arg) {} Exception::~Exception() throw() {} const char *Exception::what() const throw() { return _what.c_str(); } const char *Exception::getString() const { return _what.c_str(); } IOException::IOException(const String &what_arg, long systemError) throw() : Exception(what_arg), _systemError(systemError), _systemErrorString(NULL) { } IOException::~IOException() throw() { delete [] _systemErrorString; } long IOException::getSystemError() const throw() { return _systemError; } const char* IOException::getSystemErrorString() const throw() { const uint32_t errStrSize = 2048; if ( !_systemErrorString ) _systemErrorString = new char[errStrSize]; #ifndef _MSWINDOWS_ #ifdef HAVE_STRERROR_R #if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE) || !defined(APPLE)) assert(strerror_r(_systemError, _systemErrorString, errStrSize) == 0); #else _systemErrorString = strerror_r(_systemError, _systemErrorString, errStrSize); #endif #else static Mutex mlock; mlock.enter(); String::set(_systemErrorString, errStrSize, strerror(_systemError)); mlock.leave(); #endif return _systemErrorString; #else FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, _systemError, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), _systemErrorString, errStrSize, NULL); return _systemErrorString; #endif } #endif ucommon-6.0.7/commoncpp/tokenizer.cpp0000644000175000017500000001140512163025062014631 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include #include #include NAMESPACE_COMMONCPP using namespace std; // sorted by the usual probability of occurence // see also: manpage of isspace() const char * const StringTokenizer::SPACE=" \t\n\r\f\v"; StringTokenizer::StringTokenizer (const char *_str, const char *_delim, bool _skipAll, bool _trim) : str(_str),delim(_delim),skipAll(_skipAll),trim(_trim) { if (str == 0) itEnd = iterator(*this, 0); else itEnd = iterator(*this,strchr(str, '\0')+1); } StringTokenizer::StringTokenizer (const char *s) : str(s), delim(SPACE), skipAll(false),trim(true) { if (str == 0) itEnd = iterator(*this, 0); else itEnd = iterator(*this,strchr(str, '\0')+1); } StringTokenizer::iterator& StringTokenizer::iterator::operator ++ () THROWS (StringTokenizer::NoSuchElementException) { // someone requested to read beyond the end .. tsts if (endp == myTok->itEnd.endp) THROW (NoSuchElementException()); if (token) { // this is to help people find their bugs, if they // still maintain a pointer to this invalidated // area :-) *token = '\0'; delete[] token; token = 0; } start = ++endp; if (endp == myTok->itEnd.endp) return *this; // done // search for next delimiter while (*endp && strchr(myTok->delim, *endp)==NULL) ++endp; tokEnd = endp; if (*endp && myTok->skipAll) { // skip all delimiters while (*(endp+1) && strchr(myTok->delim, *(endp+1))) ++endp; } return *this; } /* * if no one requests the token, no time is spent skipping the whitespaces * or allocating memory. */ const char * StringTokenizer::iterator::operator * () THROWS (StringTokenizer::NoSuchElementException) { // someone requested to read beyond the end .. tsts if (endp == myTok->itEnd.endp) THROW (NoSuchElementException()); if (!token) { /* * someone requests this token; return a copy to provide * a NULL terminated string. */ /* don't clobber tokEnd, it is used in nextDelimiter() */ const char *wsTokEnd = tokEnd; if (myTok->trim) { while (wsTokEnd > start && strchr(SPACE, *start)) ++start; while (wsTokEnd > start && strchr(SPACE,*(wsTokEnd-1))) --wsTokEnd; } size_t tokLen = wsTokEnd - start; if (start > wsTokEnd) { tokLen = 0; } token = newString(start, tokLen + 1); } return token; } END_NAMESPACE /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 4 * End: */ ucommon-6.0.7/commoncpp/linked.cpp0000644000175000017500000001142112163025062014063 00000000000000// Copyright (C) 2004-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include using namespace COMMONCPP_NAMESPACE; LinkedSingle::~LinkedSingle() {} LinkedSingle *LinkedSingle::getFirst(void) { return this; } LinkedSingle *LinkedSingle::getLast(void) { LinkedSingle *obj = this; while(obj->nextObject) obj = obj->nextObject; return obj; } void LinkedSingle::insert(LinkedSingle& obj) { obj.nextObject = nextObject; nextObject = &obj; } LinkedSingle &LinkedSingle::operator+=(LinkedSingle &obj) { insert(obj); return *this; } LinkedDouble::~LinkedDouble() { detach(); } void LinkedDouble::enterLock() {} void LinkedDouble::leaveLock() {} LinkedDouble *LinkedDouble::firstObject() { LinkedDouble *node = this; while(node->prevObject) node = node->prevObject; return node; } LinkedDouble *LinkedDouble::lastObject() { LinkedDouble *node = this; while(node->nextObject) node = node->nextObject; return node; } LinkedDouble *LinkedDouble::getFirst(void) { LinkedDouble *node; enterLock(); node = firstObject(); leaveLock(); return node; } LinkedDouble *LinkedDouble::getLast(void) { LinkedDouble *node; enterLock(); node = lastObject(); leaveLock(); return node; } LinkedDouble *LinkedDouble::getInsert(void) { return getLast(); } void LinkedDouble::insert(LinkedDouble& obj, InsertMode position) { LinkedDouble *node; enterLock(); obj.detach(); switch ( position ) { case modeAtFirst: node = firstObject(); obj.nextObject = node; node->prevObject = &obj; break; case modeBefore: obj.nextObject = this; obj.prevObject = this->prevObject; this->prevObject = &obj; if (obj.prevObject) obj.prevObject->nextObject = &obj; break; case modeAfter: obj.nextObject = this->nextObject; obj.prevObject = this; this->nextObject = &obj; if (obj.nextObject) obj.nextObject->prevObject = &obj; break; case modeAtLast: default: node = lastObject(); obj.nextObject = node->nextObject; obj.prevObject = node; node->nextObject = &obj; if(obj.nextObject) obj.nextObject->prevObject = &obj; break; } leaveLock(); } void LinkedDouble::detach(void) { enterLock(); if(prevObject) prevObject->nextObject = nextObject; if(nextObject) nextObject->prevObject = prevObject; prevObject = NULL; nextObject = NULL; leaveLock(); } LinkedDouble &LinkedDouble::operator+=(LinkedDouble &obj) { insert(obj); return *this; } LinkedDouble &LinkedDouble::operator--() { detach(); return *this; } ucommon-6.0.7/commoncpp/Makefile.am0000644000175000017500000000172012163025062014146 00000000000000# Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = -version-info $(LT_VERSION) AM_CXXFLAGS = -I$(top_srcdir)/inc $(UCOMMON_FLAGS) LIBTOOL = @LT_GENERIC@ lib_LTLIBRARIES = libcommoncpp.la libcommoncpp_la_LDFLAGS = ../corelib/libucommon.la @UCOMMON_LIBS@ $(RELEASE) libcommoncpp_la_SOURCES = strchar.cpp slog.cpp exception.cpp thread.cpp \ address.cpp socket.cpp tcp.cpp udp.cpp dccp.cpp applog.cpp mime.cpp \ process.cpp serial.cpp tokenizer.cpp file.cpp dso.cpp linked.cpp \ pointer.cpp map.cpp ucommon-6.0.7/commoncpp/strchar.cpp0000644000175000017500000000675412163025062014300 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include NAMESPACE_COMMONCPP char *newString(const char *src, size_t size) { char *dest; if(!size) size = strlen(src) + 1; dest = new char[size]; return setString(dest, size, src); } void delString(char *str) { delete[] str; } char *setUpper(char *string, size_t size) { char *ret = string; if(!size) size = strlen(string); while(size && *string) { *string = toupper(*string); ++string; --size; } return ret; } char *setLower(char *string, size_t size) { char *ret = string; if(!size) size = strlen(string); while(size && *string) { *string = tolower(*string); ++string; --size; } return ret; } char *rsetField(char *dest, size_t size, const char *src, const char fill) { size_t len = 0; if(src) len = strlen(src); if(len > size) len = size; if(len) memmove(dest + size - len, (void *)src, len); if(len < size && fill) memset(dest, fill, size - len); return dest; } char *lsetField(char *dest, size_t size, const char *src, const char fill) { size_t len = 0; if(src) len = strlen(src); if(len > size) len = size; if(len) memmove(dest, src, len); if(len < size && fill) memset(dest + len, fill, size - len); return dest; } END_NAMESPACE ucommon-6.0.7/commoncpp/Makefile.in0000644000175000017500000005535712175171470014206 00000000000000# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = commoncpp DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/autoconf/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ucommon-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libcommoncpp_la_LIBADD = am_libcommoncpp_la_OBJECTS = strchar.lo slog.lo exception.lo thread.lo \ address.lo socket.lo tcp.lo udp.lo dccp.lo applog.lo mime.lo \ process.lo serial.lo tokenizer.lo file.lo dso.lo linked.lo \ pointer.lo map.lo libcommoncpp_la_OBJECTS = $(am_libcommoncpp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libcommoncpp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libcommoncpp_la_LDFLAGS) \ $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libcommoncpp_la_SOURCES) DIST_SOURCES = $(libcommoncpp_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKFLAGS = @CHECKFLAGS@ COMPAT = @COMPAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LT_GENERIC@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_GENERIC = @LT_GENERIC@ LT_VERSION = @LT_VERSION@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SECURE = @SECURE@ SECURE_LIBS = @SECURE_LIBS@ SECURE_LOCAL = @SECURE_LOCAL@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UCOMMON_CFGPATH = @UCOMMON_CFGPATH@ UCOMMON_CLINK = @UCOMMON_CLINK@ UCOMMON_FLAGS = @UCOMMON_FLAGS@ UCOMMON_INCLUDES = @UCOMMON_INCLUDES@ UCOMMON_LIBC = @UCOMMON_LIBC@ UCOMMON_LIBS = @UCOMMON_LIBS@ UCOMMON_LINKED = @UCOMMON_LINKED@ UCOMMON_LOCALE = @UCOMMON_LOCALE@ UCOMMON_MODEL = @UCOMMON_MODEL@ UCOMMON_PREFIX = @UCOMMON_PREFIX@ UCOMMON_VARPATH = @UCOMMON_VARPATH@ UCOMMON_VISIBILITY = @UCOMMON_VISIBILITY@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ includes = @includes@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libs = @libs@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = -version-info $(LT_VERSION) AM_CXXFLAGS = -I$(top_srcdir)/inc $(UCOMMON_FLAGS) lib_LTLIBRARIES = libcommoncpp.la libcommoncpp_la_LDFLAGS = ../corelib/libucommon.la @UCOMMON_LIBS@ $(RELEASE) libcommoncpp_la_SOURCES = strchar.cpp slog.cpp exception.cpp thread.cpp \ address.cpp socket.cpp tcp.cpp udp.cpp dccp.cpp applog.cpp mime.cpp \ process.cpp serial.cpp tokenizer.cpp file.cpp dso.cpp linked.cpp \ pointer.cpp map.cpp all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu commoncpp/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu commoncpp/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libcommoncpp.la: $(libcommoncpp_la_OBJECTS) $(libcommoncpp_la_DEPENDENCIES) $(EXTRA_libcommoncpp_la_DEPENDENCIES) $(AM_V_CXXLD)$(libcommoncpp_la_LINK) -rpath $(libdir) $(libcommoncpp_la_OBJECTS) $(libcommoncpp_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/address.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/applog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dccp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dso.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linked.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pointer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/serial.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strchar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tokenizer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udp.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ucommon-6.0.7/commoncpp/tcp.cpp0000644000175000017500000007316712163025062013422 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include #ifdef _MSWINDOWS_ #include #define _IOLEN64 (unsigned) #define _IORET64 (int) typedef int socklen_t; #define socket_errno WSAGetLastError() #else #include #include #ifdef HAVE_NET_IP6_H #include #endif #define socket_errno errno # ifndef O_NONBLOCK # define O_NONBLOCK O_NDELAY # endif # ifdef IPPROTO_IP # ifndef SOL_IP # define SOL_IP IPPROTO_IP # endif // !SOL_IP # endif // IPPROTO_IP #endif // !WIN32 #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK (unsigned long)0x7f000001 #endif #ifdef HAVE_NETINET_IN_H #include #endif #if defined(__hpux) #define _XOPEN_SOURCE_EXTENDED #endif #ifdef HAVE_NET_IF_H #include #endif #ifndef _IOLEN64 #define _IOLEN64 #endif #ifndef _IORET64 #define _IORET64 #endif using namespace COMMONCPP_NAMESPACE; using namespace std; void TCPSocket::setSegmentSize(unsigned mss) { #ifdef TCP_MAXSEG if(mss > 1) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif segsize = mss; } #ifdef HAVE_GETADDRINFO TCPSocket::TCPSocket(const char *name, unsigned backlog, unsigned mss) : Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) { char namebuf[128], *cp; struct addrinfo hint, *list = NULL, *first; snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { cp = namebuf; name = NULL; } else { name = namebuf; *(cp++) = 0; if(!strcmp(name, "*")) name = NULL; } memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_INET; hint.ai_socktype = SOCK_STREAM; hint.ai_protocol = IPPROTO_TCP; hint.ai_flags = AI_PASSIVE; if(getaddrinfo(name, cp, &hint, &list) || !list) { endSocket(); error(errBindingFailed, (char *)"Could not find service", errno); return; } #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif first = list; while(list) { if(!bind(so, list->ai_addr, (socklen_t)list->ai_addrlen)) { state = BOUND; break; } list = list->ai_next; } freeaddrinfo(first); if(state != BOUND) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } setSegmentSize(mss); if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } } #else TCPSocket::TCPSocket(const char *name, unsigned backlog, unsigned mss) : Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) { char namebuf[128], *cp; struct sockaddr_in addr; struct servent *svc; memset(&addr, 0, sizeof(addr)); snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { cp = namebuf; name = "*"; } else { name = namebuf; *(cp++) = 0; } addr.sin_family = AF_INET; if(isdigit(*cp)) addr.sin_port = htons(atoi(cp)); else { mutex.enter(); svc = getservbyname(cp, "tcp"); if(svc) addr.sin_port = svc->s_port; mutex.leave(); if(!svc) { endSocket(); error(errBindingFailed, "Could not find service", errno); return; } } IPV4Address ia(name); addr.sin_addr = getaddress(ia); #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&addr, sizeof(addr))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } setSegmentSize(mss); if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket", socket_errno); return; } state = BOUND; } #endif TCPSocket::TCPSocket(const IPV4Address &ia, tpport_t port, unsigned backlog, unsigned mss) : Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr = getaddress(ia); addr.sin_port = htons(port); #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&addr, sizeof(addr))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } setSegmentSize(mss); if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } state = BOUND; } bool TCPSocket::onAccept(const IPV4Host &ia, tpport_t port) { return true; } TCPSocket::~TCPSocket() { endSocket(); } #ifdef CCXX_IPV6 void TCPV6Socket::setSegmentSize(unsigned mss) { #ifdef TCP_MAXSEG if(mss > 1) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif segsize = mss; } TCPV6Socket::TCPV6Socket(const char *name, unsigned backlog, unsigned mss) : Socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP) { char namebuf[128], *cp; struct addrinfo hint, *list = NULL, *first; snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) { cp = namebuf; name = NULL; } else { name = namebuf; *(cp++) = 0; if(!strcmp(name, "*")) name = NULL; } memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_INET6; hint.ai_socktype = SOCK_STREAM; hint.ai_protocol = IPPROTO_TCP; hint.ai_flags = AI_PASSIVE; if(getaddrinfo(name, cp, &hint, &list) || !list) { endSocket(); error(errBindingFailed, (char *)"Could not find service", errno); return; } #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif first = list; while(list) { if(!bind(so, list->ai_addr, (socklen_t)list->ai_addrlen)) { state = BOUND; break; } list = list->ai_next; } freeaddrinfo(first); if(state != BOUND) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } setSegmentSize(mss); if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } } TCPV6Socket::TCPV6Socket(const IPV6Address &ia, tpport_t port, unsigned backlog, unsigned mss) : Socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP) { struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_addr = getaddress(ia); addr.sin6_port = htons(port); #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&addr, sizeof(addr))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } setSegmentSize(mss); if(listen(so, backlog)) { endSocket(); error(errBindingFailed,(char *)"Could not listen on socket",socket_errno); return; } state = BOUND; } bool TCPV6Socket::onAccept(const IPV6Host &ia, tpport_t port) { return true; } TCPV6Socket::~TCPV6Socket() { endSocket(); } #endif void TCPSocket::reject(void) { SOCKET rej = accept(so, NULL, NULL); ::shutdown(rej, 2); release(rej); } #ifdef CCXX_IPV6 void TCPV6Socket::reject(void) { SOCKET rej = accept(so, NULL, NULL); ::shutdown(rej, 2); release(rej); } #endif TCPStream::TCPStream(TCPSocket &server, bool throwflag, timeout_t to) : streambuf(), Socket(accept(server.getSocket(), NULL, NULL)), #ifdef OLD_IOSTREAM iostream() #else iostream((streambuf *)this) #endif ,bufsize(0) ,gbuf(NULL) ,pbuf(NULL) { tpport_t port; family = IPV4; #ifdef OLD_IOSTREAM init((streambuf *)this); #endif timeout = to; setError(throwflag); IPV4Host host = getPeer(&port); if(!server.onAccept(host, port)) { endSocket(); error(errConnectRejected); iostream::clear(ios::failbit | rdstate()); return; } segmentBuffering(server.getSegmentSize()); Socket::state = CONNECTED; } #ifdef CCXX_IPV6 TCPStream::TCPStream(TCPV6Socket &server, bool throwflag, timeout_t to) : streambuf(), Socket(accept(server.getSocket(), NULL, NULL)), #ifdef OLD_IOSTREAM iostream() #else iostream((streambuf *)this) #endif ,bufsize(0) ,gbuf(NULL) ,pbuf(NULL) { tpport_t port; family = IPV6; #ifdef OLD_IOSTREAM init((streambuf *)this); #endif timeout = to; setError(throwflag); IPV6Host host = getIPV6Peer(&port); if(!server.onAccept(host, port)) { endSocket(); error(errConnectRejected); iostream::clear(ios::failbit | rdstate()); return; } segmentBuffering(server.getSegmentSize()); Socket::state = CONNECTED; } #endif TCPStream::TCPStream(const IPV4Host &host, tpport_t port, unsigned size, bool throwflag, timeout_t to) : streambuf(), Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP), #ifdef OLD_IOSTREAM iostream(), #else iostream((streambuf *)this), #endif bufsize(0),gbuf(NULL),pbuf(NULL) { #ifdef OLD_IOSTREAM init((streambuf *)this); #endif family = IPV4; timeout = to; setError(throwflag); connect(host, port, size); } #ifdef CCXX_IPV6 TCPStream::TCPStream(const IPV6Host &host, tpport_t port, unsigned size, bool throwflag, timeout_t to) : streambuf(), Socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP), #ifdef OLD_IOSTREAM iostream(), #else iostream((streambuf *)this), #endif bufsize(0),gbuf(NULL),pbuf(NULL) { family = IPV6; #ifdef OLD_IOSTREAM init((streambuf *)this); #endif timeout = to; setError(throwflag); connect(host, port, size); } #endif TCPStream::~TCPStream() { #ifdef CCXX_EXCEPTIONS try { endStream(); } catch( ... ) { if ( ! std::uncaught_exception()) throw;}; #else endStream(); #endif } #ifdef HAVE_GETADDRINFO void TCPStream::connect(const char *target, unsigned mss) { char namebuf[128]; char *cp; struct addrinfo hint, *list = NULL, *next, *first; bool connected = false; snprintf(namebuf, sizeof(namebuf), "%s", target); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { endStream(); connectError(); return; } *(cp++) = 0; memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = SOCK_STREAM; hint.ai_protocol = IPPROTO_TCP; if(getaddrinfo(namebuf, cp, &hint, &list) || !list) { endStream(); connectError(); return; } first = list; #ifdef TCP_MAXSEG if(mss) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif while(list) { if(!::connect(so, list->ai_addr, (socklen_t)list->ai_addrlen)) { connected = true; break; } next = list->ai_next; list = next; } freeaddrinfo(first); if(!connected) { endStream(); connectError(); return; } segmentBuffering(mss); Socket::state = CONNECTED; } #else void TCPStream::connect(const char *target, unsigned mss) { char namebuf[128]; char *cp; struct servent *svc; tpport_t port; snprintf(namebuf, sizeof(namebuf), "%s", target); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) { endStream(); connectError(); return; } *(cp++) = 0; if(isdigit(*cp)) port = atoi(cp); else { mutex.enter(); svc = getservbyname(cp, "tcp"); if(svc) port = ntohs(svc->s_port); mutex.leave(); if(!svc) { endStream(); connectError(); return; } } switch(family) { case IPV4: connect(IPV4Host(namebuf), port, mss); break; #ifdef CCXX_IPV6 case IPV6: connect(IPV6Host(namebuf), port, mss); break; #endif default: endStream(); connectError(); } } #endif void TCPStream::connect(const IPV4Host &host, tpport_t port, unsigned mss) { size_t i; fd_set fds; struct timeval to; bool connected = false; int rtn; int sockopt; socklen_t len = sizeof(sockopt); #ifdef TCP_MAXSEG if(mss) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif for(i = 0 ; i < host.getAddressCount(); i++) { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr = host.getAddress(i); addr.sin_port = htons(port); if(timeout) setCompletion(false); // Win32 will crash if you try to connect to INADDR_ANY. if ( INADDR_ANY == addr.sin_addr.s_addr ) addr.sin_addr.s_addr = INADDR_LOOPBACK; rtn = ::connect(so, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)); if(!rtn) { connected = true; break; } #ifndef _MSWINDOWS_ if(errno == EINPROGRESS) #else if(WSAGetLastError() == WSAEINPROGRESS) #endif { FD_ZERO(&fds); FD_SET(so, &fds); to.tv_sec = timeout / 1000; to.tv_usec = timeout % 1000 * 1000; // timeout check for connect completion if(::select((int)so + 1, NULL, &fds, NULL, &to) < 1) continue; getsockopt(so, SOL_SOCKET, SO_ERROR, (char *)&sockopt, &len); if(!sockopt) { connected = true; break; } endSocket(); so = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(so == INVALID_SOCKET) break; } } setCompletion(true); if(!connected) { rtn = errno; endStream(); errno = rtn; connectError(); return; } segmentBuffering(mss); Socket::state = CONNECTED; } #ifdef CCXX_IPV6 void TCPStream::connect(const IPV6Host &host, tpport_t port, unsigned mss) { size_t i; fd_set fds; struct timeval to; bool connected = false; int rtn; int sockopt; socklen_t len = sizeof(sockopt); #ifdef TCP_MAXSEG if(mss) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif for(i = 0 ; i < host.getAddressCount(); i++) { struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_addr = host.getAddress(i); addr.sin6_port = htons(port); if(timeout) setCompletion(false); // Win32 will crash if you try to connect to INADDR_ANY. if ( !memcmp(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any))) memcpy(&addr.sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)); rtn = ::connect(so, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)); if(!rtn) { connected = true; break; } #ifndef _MSWINDOWS_ if(errno == EINPROGRESS) #else if(WSAGetLastError() == WSAEINPROGRESS) #endif { FD_ZERO(&fds); FD_SET(so, &fds); to.tv_sec = timeout / 1000; to.tv_usec = timeout % 1000 * 1000; // timeout check for connect completion if(::select((int)so + 1, NULL, &fds, NULL, &to) < 1) continue; getsockopt(so, SOL_SOCKET, SO_ERROR, (char *)&sockopt, &len); if(!sockopt) { connected = true; break; } endSocket(); so = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); if(so == INVALID_SOCKET) break; } } setCompletion(true); if(!connected) { rtn = errno; endStream(); errno = rtn; connectError(); return; } segmentBuffering(mss); Socket::state = CONNECTED; } #endif TCPStream::TCPStream(const char *target, Family fam, unsigned mss, bool throwflag, timeout_t to) : streambuf(), Socket(PF_INET, SOCK_STREAM, IPPROTO_TCP), #ifdef OLD_IOSTREAM iostream(), #else iostream((streambuf *)this), #endif timeout(to), bufsize(0),gbuf(NULL),pbuf(NULL) { family = fam; #ifdef OLD_IOSTREAM init((streambuf *)this); #endif setError(throwflag); connect(target, mss); } TCPStream::TCPStream(Family fam, bool throwflag, timeout_t to) : streambuf(), Socket(PF_INET, SOCK_STREAM, IPPROTO_TCP), #ifdef OLD_IOSTREAM iostream(), #else iostream((streambuf *)this), #endif timeout(to), bufsize(0),gbuf(NULL),pbuf(NULL) { family = fam; #ifdef OLD_IOSTREAM init((streambuf *)this); #endif setError(throwflag); } void TCPStream::connect(TCPSocket &tcpip) { tpport_t port; endStream(); family = IPV4; so = accept(tcpip.getSocket(), NULL, NULL); if(so == INVALID_SOCKET) return; IPV4Host host = getPeer(&port); if(!tcpip.onAccept(host, port)) { endSocket(); iostream::clear(ios::failbit | rdstate()); return; } segmentBuffering(tcpip.getSegmentSize()); Socket::state = CONNECTED; } #ifdef CCXX_IPV6 void TCPStream::connect(TCPV6Socket &tcpip) { tpport_t port; endStream(); family = IPV6; so = accept(tcpip.getSocket(), NULL, NULL); if(so == INVALID_SOCKET) return; IPV6Host host = getIPV6Peer(&port); if(!tcpip.onAccept(host, port)) { endSocket(); iostream::clear(ios::failbit | rdstate()); return; } segmentBuffering(tcpip.getSegmentSize()); Socket::state = CONNECTED; } #endif void TCPStream::segmentBuffering(unsigned mss) { unsigned max = 0; if(mss == 1) { // special interactive allocate(1); return; } #ifdef TCP_MAXSEG socklen_t alen = sizeof(max); if(mss) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&max, sizeof(max)); getsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&max, &alen); #endif if(max && max < mss) mss = max; if(!mss) { if(max) mss = max; else mss = 536; allocate(mss); return; } #ifdef TCP_MAXSEG setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif if(mss < 80) mss = 80; if(mss * 7 < 64000) bufferSize(mss * 7); else if(mss * 6 < 64000) bufferSize(mss * 6); else bufferSize(mss * 5); if(mss < 512) sendLimit(mss * 4); allocate(mss); } int TCPStream::getSegmentSize(void) { unsigned mss = 0; #ifdef TCP_MAXSEG socklen_t alen = sizeof(mss); getsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, &alen); #endif if(!mss) return (int)bufsize; return mss; } void TCPStream::disconnect(void) { if(Socket::state == AVAILABLE) return; endStream(); so = socket(family, SOCK_STREAM, IPPROTO_TCP); if(so != INVALID_SOCKET) Socket::state = AVAILABLE; } void TCPStream::endStream(void) { if(bufsize) sync(); if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; bufsize = 0; iostream::clear(); endSocket(); } void TCPStream::allocate(size_t size) { if(size < 2) { bufsize = 1; gbuf = pbuf = 0; return; } gbuf = new char[size]; pbuf = new char[size]; if(!pbuf || !gbuf) { error(errResourceFailure, (char *)"Could not allocate socket stream buffers"); return; } bufsize = size; iostream::clear(); #if (defined(__GNUC__) && (__GNUC__ < 3)) && !defined(_MSWINDOWS_) && !defined(STLPORT) setb(gbuf, gbuf + size, 0); #endif setg(gbuf, gbuf + size, gbuf + size); setp(pbuf, pbuf + size); } int TCPStream::doallocate() { if(bufsize) return 0; allocate(1); return 1; } int TCPStream::uflow() { int ret = underflow(); if (ret == EOF) return EOF; if (bufsize != 1) gbump(1); return ret; } int TCPStream::underflow() { ssize_t rlen = 1; unsigned char ch; if(bufsize == 1) { if(Socket::state == STREAM) rlen = ::read((int)so, (char *)&ch, 1); else if(timeout && !Socket::isPending(pendingInput, timeout)) { iostream::clear(ios::failbit | rdstate()); error(errTimeout,(char *)"Socket read timed out",socket_errno); return EOF; } else rlen = readData(&ch, 1); if(rlen < 1) { if(rlen < 0) { iostream::clear(ios::failbit | rdstate()); error(errInput,(char *)"Could not read from socket",socket_errno); } return EOF; } return ch; } if(!gptr()) return EOF; if(gptr() < egptr()) return (unsigned char)*gptr(); rlen = (ssize_t)((gbuf + bufsize) - eback()); if(Socket::state == STREAM) rlen = ::read((int)so, (char *)eback(), _IOLEN64 rlen); else if(timeout && !Socket::isPending(pendingInput, timeout)) { iostream::clear(ios::failbit | rdstate()); error(errTimeout,(char *)"Socket read timed out",socket_errno); return EOF; } else rlen = readData(eback(), rlen); if(rlen < 1) { // clear(ios::failbit | rdstate()); if(rlen < 0) error(errNotConnected,(char *)"Connection error",socket_errno); else { error(errInput,(char *)"Could not read from socket",socket_errno); iostream::clear(ios::failbit | rdstate()); } return EOF; } error(errSuccess); setg(eback(), eback(), eback() + rlen); return (unsigned char) *gptr(); } bool TCPStream::isPending(Pending pending, timeout_t timer) { if(pending == pendingInput && in_avail()) return true; else if(pending == pendingOutput) flush(); return Socket::isPending(pending, timer); } int TCPStream::sync(void) { overflow(EOF); setg(gbuf, gbuf + bufsize, gbuf + bufsize); return 0; } size_t TCPStream::printf(const char *format, ...) { va_list args; size_t len; char *buf; va_start(args, format); overflow(EOF); len = pptr() - pbase(); buf = pptr(); vsnprintf(buf, len, format, args); va_end(args); len = strlen(buf); if(Socket::state == STREAM) return ::write((int)so, buf, _IOLEN64 len); else return writeData(buf, len); } int TCPStream::overflow(int c) { unsigned char ch; ssize_t rlen, req; if(bufsize == 1) { if(c == EOF) return 0; ch = (unsigned char)(c); if(Socket::state == STREAM) rlen = ::write((int)so, (const char *)&ch, 1); else rlen = writeData(&ch, 1); if(rlen < 1) { if(rlen < 0) { iostream::clear(ios::failbit | rdstate()); error(errOutput,(char *)"Could not write to socket",socket_errno); } return EOF; } else return c; } if(!pbase()) return EOF; req = (ssize_t)(pptr() - pbase()); if(req) { if(Socket::state == STREAM) rlen = ::write((int)so, (const char *)pbase(), req); else rlen = writeData(pbase(), req); if(rlen < 1) { if(rlen < 0) { iostream::clear(ios::failbit | rdstate()); error(errOutput,(char *)"Could not write to socket",socket_errno); } return EOF; } req -= rlen; } // if write "partial", rebuffer remainder if(req) // memmove(pbuf, pptr() + rlen, req); memmove(pbuf, pbuf + rlen, req); setp(pbuf, pbuf + bufsize); pbump(req); if(c != EOF) { *pptr() = (unsigned char)c; pbump(1); } return c; } TCPSession::TCPSession(const IPV4Host &ia, tpport_t port, size_t size, int pri, size_t stack) : Thread(pri, stack), TCPStream(IPV4) { setCompletion(false); setError(false); allocate(size); size_t i; for(i = 0 ; i < ia.getAddressCount(); i++) { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr = ia.getAddress(i); addr.sin_port = htons(port); // Win32 will crash if you try to connect to INADDR_ANY. if ( INADDR_ANY == addr.sin_addr.s_addr ) addr.sin_addr.s_addr = INADDR_LOOPBACK; if(::connect(so, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)) == 0) break; #ifdef _MSWINDOWS_ if(WSAGetLastError() == WSAEISCONN || WSAGetLastError() == WSAEWOULDBLOCK) #else if(errno == EINPROGRESS) #endif { Socket::state = CONNECTING; return; } } if(i == ia.getAddressCount()) { endSocket(); Socket::state = INITIAL; return; } setCompletion(true); Socket::state = CONNECTED; } #ifdef CCXX_IPV6 TCPSession::TCPSession(const IPV6Host &ia, tpport_t port, size_t size, int pri, size_t stack) : Thread(pri, stack), TCPStream(IPV6) { setCompletion(false); setError(false); allocate(size); size_t i; for(i = 0 ; i < ia.getAddressCount(); i++) { struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_addr = ia.getAddress(i); addr.sin6_port = htons(port); // Win32 will crash if you try to connect to INADDR_ANY. if(!memcmp(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any))) memcpy(&addr.sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)); if(::connect(so, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)) == 0) break; #ifdef _MSWINDOWS_ // if(WSAGetLastError() == WSAEWOULDBLOCK) if(WSAGetLastError() == WSAEISCONN) #else if(errno == EINPROGRESS) #endif { Socket::state = CONNECTING; return; } } if(i == ia.getAddressCount()) { endSocket(); Socket::state = INITIAL; return; } setCompletion(true); Socket::state = CONNECTED; } #endif TCPSession::TCPSession(TCPSocket &s, int pri, size_t stack) : Thread(pri, stack), TCPStream(s) { setCompletion(true); setError(false); } #ifdef CCXX_IPV6 TCPSession::TCPSession(TCPV6Socket &s, int pri, size_t stack) : Thread(pri, stack), TCPStream(s) { setCompletion(true); setError(false); } #endif TCPSession::~TCPSession() { endStream(); } int TCPSession::waitConnection(timeout_t timer) { int sockopt = 0; socklen_t len = sizeof(sockopt); switch(Socket::state) { case INITIAL: return -1; case CONNECTED: break; case CONNECTING: if(!Socket::isPending(pendingOutput, timer)) { endSocket(); Socket::state = INITIAL; return -1; } getsockopt(so, SOL_SOCKET, SO_ERROR, (char *)&sockopt, &len); if(sockopt) { endSocket(); Socket::state = INITIAL; return -1; } default: break; } Socket::state = CONNECTED; return 0; } void TCPSession::initial(void) { if(waitConnection(60000)) exit(); } ucommon-6.0.7/commoncpp/address.cpp0000644000175000017500000007116612164016165014263 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #ifdef HAVE_ENDIAN_H #include #endif #include #include #include #include #include #ifndef _MSWINDOWS_ #include #include #include #endif #if defined(_MSWINDOWS_) && !defined(__BIG_ENDIAN) #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __PDP_ENDIAN 3412 #define __BYTE_ORDER __LITTLE_ENDIAN #endif using namespace COMMONCPP_NAMESPACE; #if __BYTE_ORDER == __BIG_ENDIAN enum { MCAST_VALID_MASK = 0xF0000000, MCAST_VALID_VALUE = 0xE0000000 }; #else enum { MCAST_VALID_MASK = 0x000000F0, MCAST_VALID_VALUE = 0x000000E0 }; #endif #ifndef _MSWINDOWS_ Mutex IPV4Address::mutex; #endif IPV4Host IPV4Host::_host_; const IPV4MulticastValidator IPV4Multicast::validator; void IPV4MulticastValidator::operator()(const in_addr address) const { #ifdef CCXX_EXCEPTIONS // "0.0.0.0" is always accepted, as it is an "empty" address. if ( (address.s_addr != INADDR_ANY) && (address.s_addr & MCAST_VALID_MASK) != MCAST_VALID_VALUE ) { throw "Multicast address not in the valid range: from 224.0.0.1 through 239.255.255.255"; } #endif } IPV4Address::IPV4Address(const IPV4Validator *_validator) : validator(_validator), ipaddr(NULL), addr_count(0), hostname(NULL) { *this = (long unsigned int)INADDR_ANY; } IPV4Address::IPV4Address(const char *address, const IPV4Validator *_validator) : validator(_validator), ipaddr(NULL), addr_count(0), hostname(NULL) { if(address == 0 || !strcmp(address, "*")) setAddress(NULL); else setAddress(address); } IPV4Address::IPV4Address(struct in_addr addr, const IPV4Validator *_validator) : validator(_validator), ipaddr(NULL), hostname(NULL) { if ( this->validator ) { (*validator)(addr); } addr_count = 1; ipaddr = new struct in_addr[1]; ipaddr[0] = addr; } IPV4Address::IPV4Address(const IPV4Address &rhs) : validator(rhs.validator), addr_count(rhs.addr_count), hostname(NULL) { ipaddr = new struct in_addr[addr_count]; memcpy(ipaddr, rhs.ipaddr, sizeof(struct in_addr) * addr_count); } IPV4Address::~IPV4Address() { if(ipaddr) { delete[] ipaddr; ipaddr = NULL; } if(hostname) { delString(hostname); hostname = NULL; } } struct in_addr IPV4Address::getAddress(void) const { return ipaddr[0]; } struct in_addr IPV4Address::getAddress(size_t i) const { return (i < addr_count ? ipaddr[i] : ipaddr[0]); } bool IPV4Address::isInetAddress(void) const { struct in_addr addr; memset(&addr, 0, sizeof(addr)); if(memcmp(&addr, &ipaddr[0], sizeof(addr))) return true; return false; } IPV4Address &IPV4Address::operator=(const char *str) { if(str == 0 || !strcmp(str, "*")) str = "0.0.0.0"; setAddress(str); return *this; } IPV4Address &IPV4Address::operator=(struct in_addr addr) { if(ipaddr) delete[] ipaddr; if ( validator ) (*validator)(addr); addr_count = 1; ipaddr = new struct in_addr[1]; ipaddr[0] = addr; if(hostname) delString(hostname); hostname = NULL; return *this; } IPV4Address &IPV4Address::operator=(unsigned long addr) { union { uint32_t addr; struct in_addr in4; } aptr; aptr.addr = addr; if ( validator ) (*validator)(aptr.in4); if(ipaddr) delete[] ipaddr; addr_count = 1; ipaddr = new struct in_addr[1]; memcpy(ipaddr, &aptr.in4, sizeof(struct in_addr)); if(hostname) delString(hostname); hostname = NULL; return *this; } IPV4Address &IPV4Address::operator=(const IPV4Address &rhs) { if(this == &rhs) return *this; addr_count = rhs.addr_count; if(ipaddr) delete[] ipaddr; ipaddr = new struct in_addr[addr_count]; memcpy(ipaddr, rhs.ipaddr, sizeof(struct in_addr) * addr_count); validator = rhs.validator; if(hostname) delString(hostname); hostname = NULL; return *this; } bool IPV4Address::operator==(const IPV4Address &a) const { const IPV4Address *smaller, *larger; size_t s, l; if(addr_count > a.addr_count) { smaller = &a; larger = this; } else { smaller = this; larger = &a; } // Loop through all addr's in the smaller and make sure // that they are all in the larger for(s = 0; s < smaller->addr_count; s++) { // bool found = false; for(l = 0; l < larger->addr_count && memcmp((char *)&smaller->ipaddr[s], (char *)&larger->ipaddr[l], sizeof(struct in_addr)); l++); if(l == larger->addr_count) return false; } return true; } bool IPV4Address::operator!=(const IPV4Address &a) const { // Impliment in terms of operator== return (*this == a ? false : true); } IPV4Host &IPV4Host::operator&=(const IPV4Mask &ma) { for(size_t i = 0; i < addr_count; i++) { struct in_addr mask = ma.getAddress(); unsigned char *a = (unsigned char *)&ipaddr[i]; unsigned char *m = (unsigned char *)&mask; for(size_t j = 0; j < sizeof(struct in_addr); ++j) *(a++) &= *(m++); } if(hostname) delString(hostname); hostname = NULL; return *this; } IPV4Host::IPV4Host(struct in_addr addr) : IPV4Address(addr) {} IPV4Host::IPV4Host(const char *host) : IPV4Address(host) { char namebuf[256]; if(!host) { if(this == &_host_) { gethostname(namebuf, 256); setAddress(namebuf); } else *this = _host_; } } bool IPV4Address::setIPAddress(const char *host) { if(!host) return false; #if defined(_MSWINDOWS_) struct sockaddr_in addr; addr.sin_addr.s_addr = inet_addr(host); if ( validator ) (*validator)(addr.sin_addr); if(addr.sin_addr.s_addr == INADDR_NONE) return false; *this = addr.sin_addr.s_addr; #else struct in_addr l_addr; int ok = inet_aton(host, &l_addr); if ( validator ) (*validator)(l_addr); if ( !ok ) return false; *this = l_addr; #endif return true; } void IPV4Address::setAddress(const char *host) { if(hostname) delString(hostname); hostname = NULL; if(!host) // The way this is currently used, this can never happen { *this = (long unsigned int)htonl(INADDR_ANY); return; } #ifdef _MSWINDOWS_ if(!stricmp(host, "localhost")) { *this = (long unsigned int)inet_addr("127.0.0.1"); return; } #endif if(!setIPAddress(host)) { struct hostent *hp; struct in_addr **bptr; #if defined(__GLIBC__) char hbuf[8192]; struct hostent hb; int rtn; if(gethostbyname_r(host, &hb, hbuf, sizeof(hbuf), &hp, &rtn)) hp = NULL; #elif defined(sun) char hbuf[8192]; struct hostent hb; int rtn; hp = gethostbyname_r(host, &hb, hbuf, sizeof(hbuf), &rtn); #elif (defined(__osf__) || defined(_MSWINDOWS_)) hp = gethostbyname(host); #else mutex.enterMutex(); hp = gethostbyname(host); mutex.leaveMutex(); #endif if(!hp) { if(ipaddr) delete[] ipaddr; ipaddr = new struct in_addr[1]; memset(ipaddr, 0, sizeof(struct in_addr)); return; } // Count the number of IP addresses returned addr_count = 0; for(bptr = (struct in_addr **)hp->h_addr_list; *bptr != NULL; bptr++) { addr_count++; } // Allocate enough memory if(ipaddr) delete[] ipaddr; // Cause this was allocated in base ipaddr = new struct in_addr[addr_count]; // Now go through the list again assigning to // the member ipaddr; bptr = (struct in_addr **)hp->h_addr_list; for(unsigned int i = 0; i < addr_count; i++) { if ( validator ) (*validator)(*bptr[i]); ipaddr[i] = *bptr[i]; } } } IPV4Broadcast::IPV4Broadcast(const char *net) : IPV4Address(net) { } IPV4Mask::IPV4Mask(const char *mask) { unsigned long x = 0xffffffff; int l = 32 - atoi(mask); if(setIPAddress(mask)) return; if(l < 1 || l > 32) { #ifdef CCXX_EXCEPTIONS if(Thread::getException() == Thread::throwObject) throw((IPV4Address *)this); #endif return; } *this = htonl(x << l); } const char *IPV4Address::getHostname(void) const { struct hostent *hp = NULL; struct in_addr addr0; memset(&addr0, 0, sizeof(addr0)); if(!memcmp(&addr0, &ipaddr[0], sizeof(addr0))) return NULL; #ifdef _MSWINDOWS_ memset(&addr0, 0xff, sizeof(addr0)); if(!memcmp(&addr0, &ipaddr[0], sizeof(addr0))) return "255.255.255.255"; long a = inet_addr("127.0.0.1"); if(!memcmp(&a, &ipaddr[0], sizeof(a))) return "localhost"; #endif #if defined(__GLIBC__) char hbuf[8192]; struct hostent hb; int rtn; if(gethostbyaddr_r((char *)&ipaddr[0], sizeof(addr0), AF_INET, &hb, hbuf, sizeof(hbuf), &hp, &rtn)) hp = NULL; #elif defined(sun) char hbuf[8192]; struct hostent hb; int rtn; hp = gethostbyaddr_r((char *)&ipaddr[0], (int)sizeof(addr0), (int)AF_INET, &hb, hbuf, (int)sizeof(hbuf), &rtn); #elif defined(__osf__) || defined(_MSWINDOWS_) hp = gethostbyaddr((char *)&ipaddr[0], sizeof(addr0), AF_INET); #else mutex.enterMutex(); hp = gethostbyaddr((char *)&ipaddr[0], sizeof(addr0), AF_INET); mutex.leaveMutex(); #endif if(hp) { if(hostname) delString(hostname); hostname = newString(hp->h_name); return hostname; } else { return inet_ntoa(ipaddr[0]); } } IPV4Host operator&(const IPV4Host &addr, const IPV4Mask &mask) { IPV4Host temp = addr; temp &= mask; return temp; } IPV4Multicast::IPV4Multicast() : IPV4Address(&validator) {} IPV4Multicast::IPV4Multicast(const struct in_addr address) : IPV4Address(address, &validator) {} IPV4Multicast::IPV4Multicast(const char *address) : IPV4Address(address, &validator) {} #ifdef CCXX_IPV6 #ifndef _MSWINDOWS_ Mutex IPV6Address::mutex; #endif const IPV6MulticastValidator IPV6Multicast::validator; void IPV6MulticastValidator::operator()(const in6_addr address) const { #ifdef CCXX_EXCEPTIONS // "0000:" is always accepted, as it is an "empty" address. if ( (address.s6_addr[0] != 0 || address.s6_addr[1] != 0) && (address.s6_addr[0] != 0xff || address.s6_addr[1] < 0x1f)) { throw "Multicast address not in the valid prefix ff00-ff1f:"; } #endif } IPV6Address::IPV6Address(const IPV6Validator *_validator) : validator(_validator), hostname(NULL) { addr_count = 1; ipaddr = new struct in6_addr[1]; memcpy(ipaddr, &in6addr_any, sizeof(struct in6_addr)); } IPV6Address::IPV6Address(const char *address, const IPV6Validator *_validator) : validator(_validator), ipaddr(NULL), addr_count(0), hostname(NULL) { if(address == 0 || !strcmp(address, "*")) setAddress(NULL); else setAddress(address); } IPV6Address::IPV6Address(struct in6_addr addr, const IPV6Validator *_validator) : validator(_validator), ipaddr(NULL), hostname(NULL) { if ( this->validator ) { (*validator)(addr); } addr_count = 1; ipaddr = new struct in6_addr[1]; memcpy(&ipaddr, &addr, sizeof(struct in6_addr)); } IPV6Address::IPV6Address(const IPV6Address &rhs) : validator(rhs.validator), addr_count(rhs.addr_count), hostname(NULL) { ipaddr = new struct in6_addr[addr_count]; memcpy(ipaddr, rhs.ipaddr, sizeof(struct in6_addr) * addr_count); } IPV6Address::~IPV6Address() { if(ipaddr) { delete[] ipaddr; ipaddr = NULL; } if(hostname) { delString(hostname); hostname = NULL; } } struct in6_addr IPV6Address::getAddress(void) const { return ipaddr[0]; } struct in6_addr IPV6Address::getAddress(size_t i) const { return (i < addr_count ? ipaddr[i] : ipaddr[0]); } bool IPV6Address::isInetAddress(void) const { struct in6_addr addr; memset(&addr, 0, sizeof(addr)); if(!ipaddr) return false; if(memcmp(&addr, &ipaddr[0], sizeof(addr))) return true; return false; } IPV6Address &IPV6Address::operator=(const char *str) { if(str == 0 || !strcmp(str, "*")) str = "::"; setAddress(str); return *this; } IPV6Address &IPV6Address::operator=(struct in6_addr addr) { if(ipaddr) delete[] ipaddr; if ( validator ) (*validator)(addr); addr_count = 1; ipaddr = new struct in6_addr[1]; ipaddr[0] = addr; if(hostname) delString(hostname); hostname = NULL; return *this; } IPV6Address &IPV6Address::operator=(const IPV6Address &rhs) { if(this == &rhs) return *this; addr_count = rhs.addr_count; if(ipaddr) delete[] ipaddr; ipaddr = new struct in6_addr[addr_count]; memcpy(ipaddr, rhs.ipaddr, sizeof(struct in6_addr) * addr_count); validator = rhs.validator; if(hostname) delString(hostname); hostname = NULL; return *this; } bool IPV6Address::operator==(const IPV6Address &a) const { const IPV6Address *smaller, *larger; size_t s, l; if(addr_count > a.addr_count) { smaller = &a; larger = this; } else { smaller = this; larger = &a; } // Loop through all addr's in the smaller and make sure // that they are all in the larger for(s = 0; s < smaller->addr_count; s++) { // bool found = false; for(l = 0; l < larger->addr_count && memcmp((char *)&smaller->ipaddr[s], (char *)&larger->ipaddr[l], sizeof(struct in6_addr)); l++); if(l == larger->addr_count) return false; } return true; } bool IPV6Address::operator!=(const IPV6Address &a) const { // Impliment in terms of operator== return (*this == a ? false : true); } IPV6Host &IPV6Host::operator&=(const IPV6Mask &ma) { for(size_t i = 0; i < addr_count; i++) { struct in6_addr mask = ma.getAddress(); unsigned char *a = (unsigned char *)&ipaddr[i]; unsigned char *m = (unsigned char *)&mask; for(size_t j = 0; j < sizeof(struct in6_addr); ++j) *(a++) &= *(m++); } if(hostname) delString(hostname); hostname = NULL; return *this; } IPV6Host::IPV6Host(struct in6_addr addr) : IPV6Address(addr) {} IPV6Host::IPV6Host(const char *host) : IPV6Address(host) { char namebuf[256]; if(!host) { gethostname(namebuf, 256); setAddress(namebuf); } } bool IPV6Address::setIPAddress(const char *host) { if(!host) return false; struct in6_addr l_addr; #ifdef _MSWINDOWS_ struct sockaddr saddr; int slen = sizeof(saddr); struct sockaddr_in6 *paddr = (struct sockaddr_in6 *)&saddr; int ok = WSAStringToAddress((LPSTR)host, AF_INET6, NULL, &saddr, &slen); l_addr = paddr->sin6_addr; #else int ok = inet_pton(AF_INET6, host, &l_addr); #endif if ( validator ) (*validator)(l_addr); if ( !ok ) return false; *this = l_addr; return true; } #if defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME2) void IPV6Address::setAddress(const char *host) { if(hostname) delString(hostname); hostname = NULL; if(!host) // The way this is currently used, this can never happen host = "::"; #ifdef _MSWINDOWS_ if(!stricmp(host, "localhost")) host = "::1"; #endif if(!setIPAddress(host)) { struct addrinfo hint, *list = NULL, *first; memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_INET6; struct in6_addr *addr; struct sockaddr_in6 *ip6addr; if(getaddrinfo(host, NULL, &hint, &list) || !list) { if(ipaddr) delete[] ipaddr; ipaddr = new struct in6_addr[1]; memset((void *)&ipaddr[0], 0, sizeof(struct in6_addr)); return; } // Count the number of IP addresses returned addr_count = 0; first = list; while(list) { ++addr_count; list = list->ai_next; } // Allocate enough memory if(ipaddr) delete[] ipaddr; // Cause this was allocated in base ipaddr = new struct in6_addr[addr_count]; // Now go through the list again assigning to // the member ipaddr; list = first; int i = 0; while(list) { ip6addr = (struct sockaddr_in6 *)list->ai_addr; addr = &ip6addr->sin6_addr; if(validator) (*validator)(*addr); ipaddr[i++] = *addr; list = list->ai_next; } freeaddrinfo(first); } } #else void IPV6Address::setAddress(const char *host) { if(hostname) delString(hostname); hostname = NULL; if(!host) // The way this is currently used, this can never happen host = "::"; #ifdef _MSWINDOWS_ if(!stricmp(host, "localhost")) host = "::1"; #endif if(!setIPAddress(host)) { struct hostent *hp; struct in6_addr **bptr; #if defined(__GLIBC__) char hbuf[8192]; struct hostent hb; int rtn; if(gethostbyname2_r(host, AF_INET6, &hb, hbuf, sizeof(hbuf), &hp, &rtn)) hp = NULL; #elif defined(sun) char hbuf[8192]; struct hostent hb; int rtn; hp = gethostbyname2_r(host, AF_INET6, &hb, hbuf, sizeof(hbuf), &rtn); #elif (defined(__osf__) || defined(_OSF_SOURCE) || defined(__hpux)) hp = gethostbyname(host); #elif defined(_MSWINDOWS_) && (!defined(_MSC_VER) || _MSC_VER < 1300) hp = gethostbyname(host); #elif defined(_MSWINDOWS_) hp = gethostbyname2(host, AF_INET6); #else mutex.enterMutex(); hp = gethostbyname2(host, AF_INET6); mutex.leaveMutex(); #endif if(!hp) { if(ipaddr) delete[] ipaddr; ipaddr = new struct in6_addr[1]; memset((void *)&ipaddr[0], 0, sizeof(struct in6_addr)); return; } // Count the number of IP addresses returned addr_count = 0; for(bptr = (struct in6_addr **)hp->h_addr_list; *bptr != NULL; bptr++) { addr_count++; } // Allocate enough memory if(ipaddr) delete[] ipaddr; // Cause this was allocated in base ipaddr = new struct in6_addr[addr_count]; // Now go through the list again assigning to // the member ipaddr; bptr = (struct in6_addr **)hp->h_addr_list; for(unsigned int i = 0; i < addr_count; i++) { if ( validator ) (*validator)(*bptr[i]); ipaddr[i] = *bptr[i]; } } } #endif IPV6Broadcast::IPV6Broadcast(const char *net) : IPV6Address(net) { } IPV6Mask::IPV6Mask(const char *mask) : IPV6Address(mask) { } const char *IPV6Address::getHostname(void) const { struct hostent *hp = NULL; struct in6_addr addr0; static char strbuf[64]; memset(&addr0, 0, sizeof(addr0)); if(!memcmp(&addr0, &ipaddr[0], sizeof(addr0))) return NULL; if(!memcmp(&in6addr_loopback, &ipaddr[0], sizeof(addr0))) return "localhost"; #if defined(__GLIBC__) char hbuf[8192]; struct hostent hb; int rtn; if(gethostbyaddr_r((char *)&ipaddr[0], sizeof(addr0), AF_INET6, &hb, hbuf, sizeof(hbuf), &hp, &rtn)) hp = NULL; #elif defined(sun) char hbuf[8192]; struct hostent hb; int rtn; hp = gethostbyaddr_r((char *)&ipaddr[0], sizeof(addr0), AF_INET6, &hb, hbuf, (int)sizeof(hbuf), &rtn); #elif defined(__osf__) || defined(_MSWINDOWS_) hp = gethostbyaddr((char *)&ipaddr[0], sizeof(addr0), AF_INET6); #else mutex.enterMutex(); hp = gethostbyaddr((char *)&ipaddr[0], sizeof(addr0), AF_INET6); mutex.leaveMutex(); #endif if(hp) { if(hostname) delString(hostname); hostname = newString(hp->h_name); return hostname; } else { #ifdef _MSWINDOWS_ struct sockaddr saddr; struct sockaddr_in6 *paddr = (struct sockaddr_in6 *)&saddr; DWORD slen = sizeof(strbuf); memset(&saddr, 0, sizeof(saddr)); paddr->sin6_family = AF_INET6; paddr->sin6_addr = ipaddr[0]; WSAAddressToString(&saddr, sizeof(saddr), NULL, strbuf, &slen); return strbuf; #else return inet_ntop(AF_INET6, &ipaddr[0], strbuf, sizeof(strbuf)); #endif } } IPV6Host operator&(const IPV6Host &addr, const IPV6Mask &mask) { IPV6Host temp = addr; temp &= mask; return temp; } IPV6Multicast::IPV6Multicast() : IPV6Address(&validator) {} IPV6Multicast::IPV6Multicast(const char *address) : IPV6Address(address,&validator) {} #endif NAMESPACE_COMMONCPP using namespace std; ostream& operator<<(ostream &os, const IPV4Address &ia) { os << inet_ntoa(getaddress(ia)); return os; } END_NAMESPACE typedef unsigned char bit_t; static void bitmask(bit_t *bits, bit_t *mask, unsigned len) { while(len--) *(bits++) &= *(mask++); } static void bitimask(bit_t *bits, bit_t *mask, unsigned len) { while(len--) *(bits++) |= ~(*(mask++)); } static void bitset(bit_t *bits, unsigned blen) { bit_t mask; while(blen) { mask = (bit_t)(1 << 7); while(mask && blen) { *bits |= mask; mask >>= 1; --blen; } ++bits; } } static unsigned bitcount(bit_t *bits, unsigned len) { unsigned count = 0; bit_t mask, test; while(len--) { mask = (bit_t)(1<<7); test = *bits++; while(mask) { if(!(mask & test)) return count; ++count; mask >>= 1; } } return count; } IPV4Cidr::IPV4Cidr() { memset(&network, 0, sizeof(network)); memset(&netmask, 0, sizeof(netmask)); } IPV4Cidr::IPV4Cidr(const char *cp) { set(cp); } IPV4Cidr::IPV4Cidr(IPV4Cidr &cidr) { memcpy(&network, &cidr.network, sizeof(network)); memcpy(&netmask, &cidr.netmask, sizeof(netmask)); } bool IPV4Cidr::isMember(const struct in_addr &addr) const { struct in_addr host = addr; bitmask((bit_t *)&host, (bit_t *)&netmask, sizeof(host)); if(!memcmp(&host, &network, sizeof(host))) return true; return false; } bool IPV4Cidr::isMember(const struct sockaddr *saddr) const { struct sockaddr_in *addr = (struct sockaddr_in *)saddr; struct in_addr host; if(saddr->sa_family != AF_INET) return false; memcpy(&host, &addr->sin_addr.s_addr, sizeof(host)); bitmask((bit_t *)&host, (bit_t *)&netmask, sizeof(host)); if(!memcmp(&host, &network, sizeof(host))) return true; return false; } struct in_addr IPV4Cidr::getBroadcast(void) const { struct in_addr bcast; memcpy(&bcast, &network, sizeof(network)); bitimask((bit_t *)&bcast, (bit_t *)&netmask, sizeof(bcast)); return bcast; } unsigned IPV4Cidr::getMask(const char *cp) const { unsigned dcount = 0; const char *gp = cp; const char *mp = strchr(cp, '/'); unsigned char dots[4]; #ifdef _MSWINDOWS_ DWORD mask; #else uint32_t mask; #endif if(mp) { if(!strchr(++mp, '.')) return atoi(mp); mask = inet_addr(mp); return bitcount((bit_t *)&mask, sizeof(mask)); } memset(dots, 0, sizeof(dots)); dots[0] = atoi(cp); while(*gp && dcount < 3) { if(*(gp++) == '.') dots[++dcount] = atoi(gp); } if(dots[3]) return 32; if(dots[2]) return 24; if(dots[1]) return 16; return 8; } void IPV4Cidr::set(const char *cp) { char cbuf[INET_IPV4_ADDRESS_SIZE]; char *ep; unsigned dots = 0; #ifdef _MSWINDOWS_ DWORD addr; #endif memset(&netmask, 0, sizeof(netmask)); bitset((bit_t *)&netmask, getMask(cp)); setString(cbuf, sizeof(cbuf), cp); ep = (char *)strchr(cp, '/'); if(ep) *ep = 0; cp = cbuf; while(NULL != (cp = strchr(cp, '.'))) { ++dots; ++cp; } while(dots++ < 3) addString(cbuf, sizeof(cbuf), ".0"); #ifdef _MSWINDOWS_ addr = inet_addr(cbuf); memcpy(&network, &addr, sizeof(network)); #else inet_aton(cbuf, &network); #endif bitmask((bit_t *)&network, (bit_t *)&netmask, sizeof(network)); } #ifdef CCXX_IPV6 IPV6Cidr::IPV6Cidr() { memset(&network, 0, sizeof(network)); memset(&netmask, 0, sizeof(netmask)); } IPV6Cidr::IPV6Cidr(const char *cp) { set(cp); } IPV6Cidr::IPV6Cidr(IPV6Cidr &cidr) { memcpy(&network, &cidr.network, sizeof(network)); memcpy(&netmask, &cidr.netmask, sizeof(netmask)); } bool IPV6Cidr::isMember(const struct in6_addr &addr) const { struct in6_addr host = addr; bitmask((bit_t *)&host, (bit_t *)&netmask, sizeof(host)); if(!memcmp(&host, &network, sizeof(host))) return true; return false; } bool IPV6Cidr::isMember(const struct sockaddr *saddr) const { struct sockaddr_in6 *addr = (struct sockaddr_in6 *)saddr; struct in6_addr host; if(saddr->sa_family != AF_INET6) return false; memcpy(&host, &addr->sin6_addr, sizeof(host)); bitmask((bit_t *)&host, (bit_t *)&netmask, sizeof(host)); if(!memcmp(&host, &network, sizeof(host))) return true; return false; } struct in6_addr IPV6Cidr::getBroadcast(void) const { struct in6_addr bcast; memcpy(&bcast, &network, sizeof(network)); bitimask((bit_t *)&bcast, (bit_t *)&netmask, sizeof(bcast)); return bcast; } unsigned IPV6Cidr::getMask(const char *cp) const { unsigned count = 0, rcount = 0; const char *sp = strchr(cp, '/'); int flag = 0; if(sp) return atoi(++sp); if(!strncmp(cp, "ff00:", 5)) return 8; if(!strncmp(cp, "fe80:", 5)) return 10; if(!strncmp(cp, "2002:", 5)) return 16; sp = strrchr(cp, ':'); while(*(++sp) == '0') ++sp; if(*sp) return 128; while(*cp && count < 128) { if(*(cp++) == ':') { count+= 16; while(*cp == '0') ++cp; if(*cp == ':') { if(!flag) rcount = count; flag = 1; } else flag = 0; } } return rcount; } void IPV6Cidr::set(const char *cp) { char cbuf[INET_IPV6_ADDRESS_SIZE]; char *ep; memset(&netmask, 0, sizeof(netmask)); bitset((bit_t *)&netmask, getMask(cp)); setString(cbuf, sizeof(cbuf), cp); ep = (char *)strchr(cp, '/'); if(ep) *ep = 0; #ifdef _MSWINDOWS_ int slen = sizeof(network); WSAStringToAddressA(cbuf, AF_INET6, NULL, (struct sockaddr*)&network, &slen); #else inet_pton(AF_INET6, cbuf, &network); #endif bitmask((bit_t *)&network, (bit_t *)&netmask, sizeof(network)); } #endif ucommon-6.0.7/commoncpp/applog.cpp0000644000175000017500000006730612163025062014114 00000000000000// Copyright (C) 2005-2009 Angelo Naselli, Penta Engineering s.r.l. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #ifdef NEW_STDCPP #include #include #include #include #ifndef _MSWINDOWS_ #include #include #endif #include #include #include #include #include #include #include #include // TODO sc: test if has to move up now that it is into commoncpp // NOTE: the order of inclusion is important do not move following include line // redefinition of __EXPORT needed if we're compiling our dll #include // local includes #include using namespace std; using namespace COMMONCPP_NAMESPACE; class logStruct { public: string _ident; int _priority; Slog::Level _level; bool _enable; bool _clogEnable; bool _slogEnable; size_t _msgpos; enum logEnum { BUFF_SIZE = 512, LAST_CHAR = BUFF_SIZE - 1 }; char _msgbuf[BUFF_SIZE]; logStruct() : _ident("") , _priority(Slog::levelDebug), _level(Slog::levelDebug), _enable(false), _clogEnable(false), _slogEnable(false), _msgpos(0) { memset(_msgbuf, 0, BUFF_SIZE); }; ~logStruct() {}; }; struct levelNamePair { const char *name; Slog::Level level; }; #ifdef _MSWINDOWS_ template class std::map; #endif class LevelName : public std::map { public: LevelName(const levelNamePair initval[], int num) { for (int i = 0; i < num; i++) insert(make_pair(initval[i].name, initval[i].level)); }; }; class logger : public ost::ThreadQueue { private: string _nomeFile; std::fstream _logfs; bool _usePipe; bool _closedByApplog; protected: // to dequeue log messages and write them to file if not log_directly virtual void runQueue(void *data); virtual void startQueue(void); virtual void stopQueue(void); virtual void onTimer(void); virtual void final(void); void _openFile(); public: logger(const char* logFileName = NULL, bool usePipe = false); virtual ~logger(); // To change log file name void logFileName(const char* FileName, bool usePipe = false); void openFile(); void closeFile(); }; // mapping thread ID <-> logStruct (buffer) typedef std::map LogPrivateData; // map ident <-> levels typedef std::map IdentLevel; NAMESPACE_COMMONCPP class AppLogPrivate { public: // subscription and unsubsciption must be protected as well ost::Mutex _subMutex; // mapping thread ID <-> logStruct (buffer) LogPrivateData _logs; // map ident <-> levels IdentLevel _identLevel; // log directly into file bool _logDirectly; bool _logPipe; // log spooler logger *_pLogger; string _nomeFile; Mutex _lock; std::fstream _logfs; static const levelNamePair _values[]; static LevelName _assoc; AppLogPrivate() : _pLogger(NULL) {} ~AppLogPrivate() { if (_pLogger) delete _pLogger; } }; END_NAMESPACE const levelNamePair AppLogPrivate::_values[] = { { "emerg", Slog::levelEmergency }, { "alert", Slog::levelAlert }, { "critical", Slog::levelCritical }, { "error", Slog::levelError }, { "warn", Slog::levelWarning }, { "notice", Slog::levelNotice }, { "info", Slog::levelInfo }, { "debug", Slog::levelDebug } }; AppLog alog; LevelName AppLogPrivate::_assoc(_values, sizeof AppLogPrivate::_values / sizeof *AppLogPrivate::_values); std::map *AppLog::assoc = &AppLogPrivate::_assoc; #if defined(CCXX_EXCEPTIONS) HEXdump::HEXdump(const unsigned char *buffer, int len, int max_len) : _str() { std::stringstream sstr; if (buffer == NULL || len <= 0) return ; long buf_len = (max_len > 0 && len > max_len) ? max_len : len; long int addr = 0; int cnt2 = 0; int n; int i; sstr.str(""); // get exception from ifstream failures sstr.exceptions(ifstream::failbit | ifstream::badbit); try { sstr << std::endl; sstr << "dump " << len << " byte." << std::endl; for (n = 0; n < buf_len; n++) { if (cnt2 == 0) { // Print address. sstr << std::setw(7) << std::setfill('0') << int (addr) << " - "; addr = addr + 16; } cnt2 = (cnt2 + 1) % 18; if (cnt2 <= 16) { // print hex value sstr << std::hex << std::setw(2) << std::setfill('0') << int (buffer[n]) << " "; } else { sstr << " "; sstr << std::setfill(' '); for (i = n - cnt2 + 1; i < n; i++) { // print ascii value if (buffer[i] < 32 || 126 < buffer[i]) { sstr << '.'; } else { sstr << buffer[i]; } } sstr << std::endl; sstr << std::dec; cnt2 = 0; n--; } } sstr << std::setfill(' '); for (i = cnt2 + 1; i <= 16 ; i++) { sstr << std::setw(2) << "--" << " "; } sstr << " "; for (i = n - cnt2; cnt2 <= 16 && i < n; i++) { if (buffer[i] < 32 || 126 < buffer[i]) { sstr << '.'; } else { sstr << buffer[i]; } } sstr << std::dec; if (max_len > 0 && len > max_len) sstr << std::endl << "dump troncato a " << max_len << " byte." << std::endl; } catch (...) { sstr.str("HEXdump failed!"); } _str = sstr.str(); } #endif // class logger logger::logger(const char* logFileName, bool usePipe) : ThreadQueue(NULL, 0, 0), _usePipe(usePipe), _closedByApplog(false) { _nomeFile = ""; if (logFileName) _nomeFile = logFileName; openFile(); } logger::~logger() { Semaphore::post(); Thread::terminate(); _logfs.flush(); _logfs.close(); } // New log file name void logger::logFileName(const char* FileName, bool usePipe) { if (!FileName) return; _usePipe = usePipe; _nomeFile = FileName; if (_logfs.is_open()) _logfs.close(); openFile(); } /// open also logger if applog->open() is invoked void logger::openFile() { _closedByApplog=false; } ///internal logger openFile needed to use pipe and avoid stream buffering in the case /// the consumer is not connected to pipe void logger::_openFile() { if (!_closedByApplog && !_logfs.is_open()) { if (!_nomeFile.empty()) { _logfs.clear(); if (!_usePipe) { _logfs.open(_nomeFile.c_str(), std::ofstream::out | std::ofstream::app | std::ofstream::ate); } #ifndef _MSWINDOWS_ else { // create pipe int err = mkfifo(_nomeFile.c_str(), S_IREAD | S_IWRITE); if (err == 0 || errno == EEXIST) { // and open it _logfs.open(_nomeFile.c_str(), std::fstream::in | std::fstream::out); } else THROW(AppLogException("Can't create pipe")); } #endif if (_logfs.fail()) THROW(AppLogException("Can't open log file name")); } } } /// close also logger if applog->close() is invoked void logger::closeFile() { _closedByApplog = true; } // writes into filename enqueued messages void logger::runQueue(void * data) { char *str = (char *) data; // if for some internal reasons file has been closed // reopen it try { _openFile(); } catch (AppLogException e) { std::cerr << e.what() << std::endl; slog.emerg("%s\n", e.what()); std::cerr.flush(); } if (_logfs.is_open()) { _logfs << str; _logfs.flush(); } //if we use a pipe to avoid increasing of stream buffer // without a consumer, we open, use and close it if ((_usePipe || _closedByApplog) && _logfs.is_open()) { _logfs.flush(); _logfs.close(); } } void logger::startQueue() { } void logger::stopQueue() { } void logger::onTimer() { } void logger::final() { if (started) { data_t *pFirst = first; while (pFirst) { runQueue(pFirst->data); pFirst = pFirst->next; } } } #ifndef _MSWINDOWS_ AppLog::AppLog(const char* logFileName, bool logDirectly, bool usePipe) : streambuf(), ostream((streambuf*) this) #else AppLog::AppLog(const char* logFileName, bool logDirectly) : streambuf(), ostream((streambuf*) this) #endif { d= NULL; // pedantic fussy about initing members before base classes... d = new AppLogPrivate(); if (!d) THROW(AppLogException("Memory allocation problem")); d->_nomeFile = ""; d->_logDirectly = logDirectly; #ifndef _MSWINDOWS_ d->_logPipe = usePipe; #else d->_logPipe = false; #endif // level string to level value // assoc["emerg"] = levelEmergency; // assoc["alert"] = levelAlert; // assoc["critical"] = levelCritical; // assoc["error"] = levelError; // assoc["warn"] = levelWarning; // assoc["notice"] = levelNotice; // assoc["info"] = levelInfo; // assoc["debug"] = levelDebug; if (logFileName) d->_nomeFile = logFileName; if (!d->_logDirectly && logFileName) d->_pLogger = new logger(logFileName, d->_logPipe); else d->_pLogger = NULL; // writes to file directly if (!d->_nomeFile.empty() && d->_logDirectly) { if (!d->_logPipe) { d->_logfs.open(d->_nomeFile.c_str(), std::fstream::in | std::fstream::out); if (!d->_logfs.is_open()) { d->_logfs.open(d->_nomeFile.c_str(), std::fstream::out | std::fstream::app); } else d->_logfs.seekg(0, std::fstream::end); } // on Windows pipe are not used as they are not supported on WinNT #ifndef _MSWINDOWS_ else { // create pipe int err = mkfifo(d->_nomeFile.c_str(), S_IREAD | S_IWRITE); if (err == 0 || errno == EEXIST) { // and open it d->_logfs.open(d->_nomeFile.c_str(), std::fstream::in | std::fstream::out); } else THROW(AppLogException("Can't create pipe")); } #endif if (d->_logfs.fail()) THROW(AppLogException("Can't open log file name")); } //from Error level on write to syslog also slog.level(Slog::levelError); slog.clogEnable(false); } AppLog::~AppLog() { // if _logDirectly close(); if (d) delete d; } void AppLog::subscribe() { ost::MutexLock mtx(d->_subMutex); Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) { // subscribes new thread d->_logs[tid]; } } } void AppLog::unsubscribe() { ost::MutexLock mtx(d->_subMutex); Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt != d->_logs.end()) { // unsubscribes thread d->_logs.erase(logIt); } } } #ifndef _MSWINDOWS_ void AppLog::logFileName(const char* FileName, bool logDirectly, bool usePipe) #else void AppLog::logFileName(const char* FileName, bool logDirectly) #endif { if (!FileName) { slog.error("Null file name!"); return; } d->_lock.enterMutex(); d->_nomeFile = FileName; close(); d->_logDirectly = logDirectly; #ifndef _MSWINDOWS_ d->_logPipe = usePipe; #else d->_logPipe = false; #endif if (!d->_logDirectly) { if (d->_pLogger) d->_pLogger->logFileName(FileName, d->_logPipe); else d->_pLogger = new logger(FileName, d->_logPipe); d->_lock.leaveMutex(); return; } // log directly if (!d->_nomeFile.empty()) { if (!d->_logPipe) { d->_logfs.open(d->_nomeFile.c_str(), std::fstream::out | std::fstream::app); } #ifndef _MSWINDOWS_ else { // create pipe int err = mkfifo(d->_nomeFile.c_str(), S_IREAD | S_IWRITE); if (err == 0 || errno == EEXIST) { // and open it d->_logfs.open(d->_nomeFile.c_str(), std::fstream::in | std::fstream::out); } else THROW(AppLogException("Can't create pipe")); } #endif if (d->_logfs.fail()) THROW(AppLogException("Can't open log file name")); } d->_lock.leaveMutex(); } // writes to log void AppLog::writeLog(bool endOfLine) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; if ((d->_logDirectly && !d->_logfs.is_open() && !logIt->second._clogEnable) || (!d->_logDirectly && !d->_pLogger && !logIt->second._clogEnable)) { logIt->second._msgpos = 0; logIt->second._msgbuf[0] = '\0'; return; } if (logIt->second._enable) { time_t now; struct tm *dt; time(&now); struct timeval detail_time; gettimeofday(&detail_time, NULL); dt = localtime(&now); char buf[50]; const char *p = "unknown"; switch (logIt->second._priority) { case Slog::levelEmergency: p = "emerg"; break; case Slog::levelInfo: p = "info"; break; case Slog::levelError: p = "error"; break; case Slog::levelAlert: p = "alert"; break; case Slog::levelDebug: p = "debug"; break; case Slog::levelNotice: p = "notice"; break; case Slog::levelWarning: p = "warn"; break; case Slog::levelCritical: p = "crit"; break; } snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d.%03d ", dt->tm_year + 1900, dt->tm_mon + 1, dt->tm_mday, dt->tm_hour, dt->tm_min, dt->tm_sec, (int)(detail_time.tv_usec / 1000)); buf[sizeof(buf)-1] = 0; // per sicurezza if (d->_logDirectly) { d->_lock.enterMutex(); if (d->_logfs.is_open()) { d->_logfs << buf; if (!logIt->second._ident.empty()) d->_logfs << logIt->second._ident.c_str() << ": "; d->_logfs << "[" << p << "] "; d->_logfs << logIt->second._msgbuf; if (endOfLine) d->_logfs << endl; d->_logfs.flush(); } } else if (d->_pLogger) { // ThreadQueue std::stringstream sstr; sstr.str(""); // reset contents sstr << buf; if (!logIt->second._ident.empty()) sstr << logIt->second._ident.c_str() << ": "; sstr << "[" << p << "] "; sstr << logIt->second._msgbuf; if (endOfLine) sstr << endl; sstr.flush(); if (sstr.fail()) cerr << "stringstream failed!!!! " << endl; // enqueues log message d->_pLogger->post((void *) sstr.str().c_str(), sstr.str().length() + 1); d->_lock.enterMutex(); } // slog it if error level is right if (logIt->second._slogEnable && logIt->second._priority <= Slog::levelError) { slog((Slog::Level) logIt->second._priority) << logIt->second._msgbuf; if (endOfLine) slog << endl; } if (logIt->second._clogEnable #ifndef _MSWINDOWS_ && (getppid() > 1) #endif ) { clog << logIt->second._msgbuf; if (endOfLine) clog << endl; } d->_lock.leaveMutex(); } logIt->second._msgpos = 0; logIt->second._msgbuf[0] = '\0'; } } void AppLog::close(void) { if (d->_logDirectly) { d->_lock.enterMutex(); if (d->_logfs.is_open()) { d->_logfs.flush(); d->_logfs.close(); } d->_lock.leaveMutex(); } else { if (d->_pLogger) d->_pLogger->closeFile(); } } void AppLog::open(const char *ident) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; if (d->_nomeFile.empty()) { std::cerr << "Empty file name" << std::endl; slog.emerg("Empty file nane!\n"); } if (d->_logDirectly) { d->_lock.enterMutex(); if (!d->_logfs.is_open()) { d->_logfs.open(d->_nomeFile.c_str(), std::fstream::out | std::fstream::app); } if (!d->_logfs.is_open()) { std::cerr << "Can't open file name!" << std::endl; slog.emerg("Can't open file name!\n"); } d->_lock.leaveMutex(); } else { if (d->_pLogger) d->_pLogger->openFile(); } if (ident != NULL) logIt->second._ident = ident; } } void AppLog::identLevel(const char *ident, Slog::Level level) { if (!ident) return; string id = ident; IdentLevel::iterator idLevIt = d->_identLevel.find(id); if (idLevIt == d->_identLevel.end()) { d->_identLevel[id] = level; } else idLevIt->second = level; } void AppLog::level(Slog::Level enable) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; logIt->second._level = enable; } } void AppLog::clogEnable(bool f) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; logIt->second._clogEnable = f; } } void AppLog::slogEnable(bool en) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; logIt->second._slogEnable = en; } } int AppLog::sync() { int retVal = (pbase() != pptr()); if (fail()) { slog(Slog::levelNotice) << "fail() is true, calling clear()" << endl; clear(); } Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt != d->_logs.end()) { retVal = (logIt->second._msgpos > 0); if (retVal) { slog(Slog::levelNotice) << "sync called and msgpos > 0" << endl; } } } overflow(EOF); return retVal; } int AppLog::overflow(int c) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return c; if (!logIt->second._enable) return c; if (c == '\n' || !c || c == EOF) { if (!logIt->second._msgpos) { if (c == '\n') writeLog(true); return c; } if (logIt->second._msgpos < (int)(sizeof(logIt->second._msgbuf) - 1)) logIt->second._msgbuf[logIt->second._msgpos] = 0; else logIt->second._msgbuf[logIt->second._msgpos-1] = 0; writeLog(c == '\n'); //reset buffer logIt->second._msgpos = 0; return c; } if (logIt->second._msgpos < (int)(sizeof(logIt->second._msgbuf) - 1)) logIt->second._msgbuf[logIt->second._msgpos++] = c; } return c; } void AppLog::error(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; error(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); if (logIt->second._slogEnable) slog.error(logIt->second._msgbuf); va_end(args); } } void AppLog::warn(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; warn(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); if (logIt->second._slogEnable) slog.warn(logIt->second._msgbuf); va_end(args); } } void AppLog::debug(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; debug(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); va_end(args); } } void AppLog::emerg(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; emerg(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); if (logIt->second._slogEnable) slog.emerg(logIt->second._msgbuf); va_end(args); } } void AppLog::alert(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; alert(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); if (logIt->second._slogEnable) slog.alert(logIt->second._msgbuf); va_end(args); } } void AppLog::critical(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; critical(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); if (logIt->second._slogEnable) slog.critical(logIt->second._msgbuf); va_end(args); } } void AppLog::notice(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; notice(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); if (logIt->second._slogEnable) slog.notice(logIt->second._msgbuf); va_end(args); } } void AppLog::info(const char *format, ...) { va_list args; Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return; info(); if (!logIt->second._enable) return; overflow(EOF); va_start(args, format); logIt->second._msgbuf[logStruct::BUFF_SIZE-1] = '\0'; logIt->second._msgpos = vsnprintf(logIt->second._msgbuf, logStruct::BUFF_SIZE, format, args); if (logIt->second._msgpos > logStruct::BUFF_SIZE - 1) logIt->second._msgpos = logStruct::BUFF_SIZE - 1; overflow(EOF); va_end(args); } } AppLog &AppLog::operator()(Slog::Level lev) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return *this; // needed? overflow(EOF); // enables log Slog::Level th_lev = logIt->second._level; logIt->second._enable = (th_lev >= lev); // is there a log level per module? if (!logIt->second._ident.empty()) { std::string st = logIt->second._ident; IdentLevel::iterator idLevIt = d->_identLevel.find(st); if (idLevIt != d->_identLevel.end()) { th_lev = idLevIt->second; logIt->second._enable = (th_lev >= lev); } } logIt->second._priority = lev; } return *this; } AppLog &AppLog::operator()(const char *ident, Slog::Level lev) { Thread *pThr = getThread(); if (pThr) { cctid_t tid = pThr->getId(); LogPrivateData::iterator logIt = d->_logs.find(tid); if (logIt == d->_logs.end()) return this->operator()(lev); logIt->second._enable = true; open(ident); } return this->operator()(lev); } AppLog& AppLog::operator<< (AppLog& (*pfManipulator)(AppLog&)) { return (*pfManipulator)(*this); } AppLog& AppLog::operator<< (ostream& (*pfManipulator)(ostream&)) { (*pfManipulator)(*(dynamic_cast(this))); return *this ; } #endif ucommon-6.0.7/commoncpp/pointer.cpp0000644000175000017500000000572712163025062014311 00000000000000// Copyright (C) 2004-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include using namespace COMMONCPP_NAMESPACE; RefObject::~RefObject() {} void RefPointer::enterLock(void) {} void RefPointer::leaveLock(void) {} void RefPointer::detach(void) { if(ref) { enterLock(); --(ref->refCount); if(!ref->refCount) delete ref; leaveLock(); ref = NULL; } } RefPointer::RefPointer(RefObject *obj) { enterLock(); ++obj->refCount; leaveLock(); ref = obj; } RefPointer::RefPointer(const RefPointer &ptr) { detach(); ref = ptr.ref; if(ref) { enterLock(); ++ref->refCount; leaveLock(); } } RefPointer::~RefPointer() { detach(); } void *RefPointer::getObject() const { if(ref) return ref->getObject(); return NULL; } bool RefPointer::operator!() const { if(ref && ref->refCount == 1) return true; return false; } ucommon-6.0.7/commoncpp/file.cpp0000644000175000017500000010170512163025062013541 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #ifndef _MSC_VER #include #endif // needed for GNU/LINUX glibc otherwise pread/pwrite wont work #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 #endif /* * on old glibc's, this has to be * defined explicitly */ #ifndef _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE_EXTENDED #endif #include // broken BSD; XOPEN should not imply _POSIX_C_SOURCE, // _POSIX_C_SOURCE should not stop __BSD_VISIBLE #define u_int unsigned int #define u_short unsigned short #define u_long unsigned long #define u_char unsigned char #include #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_FILE_H #include #endif #ifdef HAVE_SYS_LOCKF_H #include #endif #include #include #include #include #include #include #ifdef __BORLANDC__ #include #include #else #include #include #endif #include #include #ifndef _MSWINDOWS_ #ifdef COMMON_AIX_FIXES #undef LOCK_EX #undef LOCK_SH #endif #ifdef MACOSX #define MISSING_LOCKF #endif #ifndef F_LOCK #define MISSING_LOCKF enum { F_ULOCK = 1, F_LOCK, F_TLOCK, F_TEST }; #endif #endif // ndef WIN32 #if defined(_OSF_SOURCE) && defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 1 #undef LOCK_EX #undef LOCK_SH #endif #if 0 /* * not used anymore ? (hen) */ static const char *clearfile(const char *pathname) { remove(pathname); return pathname; } static const char *clearfifo(const char *pathname, int mode) { remove(pathname); mkfifo(pathname, mode); return pathname; } #endif NAMESPACE_COMMONCPP RandomFile::RandomFile(const char *name) : Mutex() { #ifdef _MSWINDOWS_ fd = INVALID_HANDLE_VALUE; // immediate is not defined on Win32 #else fd = -1; flags.immediate = false; #endif flags.thrown = flags.initial = flags.temp = false; flags.count = 0; pathname = NULL; } RandomFile::RandomFile(const RandomFile &rf) : Mutex() { // first, `dup'-licate the file descriptor/handle #ifdef _MSWINDOWS_ HANDLE pidHandle = GetCurrentProcess(); HANDLE dupHandle; if(rf.fd != INVALID_HANDLE_VALUE) { if(!DuplicateHandle(pidHandle, rf.fd, pidHandle, &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) fd = INVALID_HANDLE_VALUE; else fd = dupHandle; } else fd = INVALID_HANDLE_VALUE; #else if(rf.fd > -1) fd = dup(rf.fd); else fd = -1; #endif flags = rf.flags; flags.count = 0; if(rf.pathname) pathname = newString(rf.pathname); else pathname = NULL; } RandomFile::~RandomFile() { final(); } File::Error RandomFile::restart(void) { return errOpenFailed; } File::Attr RandomFile::initialize(void) { return attrPublic; } void RandomFile::final(void) { #ifdef _MSWINDOWS_ if(fd != INVALID_HANDLE_VALUE) { CloseHandle(fd); if(flags.temp && pathname) DeleteFile(pathname); } #else if(fd > -1) { close(fd); if(flags.temp && pathname) remove(pathname); } #endif if(pathname) { delString(pathname); pathname = NULL; } #ifdef _MSWINDOWS_ fd = INVALID_HANDLE_VALUE; #else fd = -1; #endif flags.count = 0; flags.initial = false; } RandomFile::Error RandomFile::error(Error id, char *str) { errstr = str; errid = id; if(!flags.thrown) { flags.thrown = true; #ifdef CCXX_EXCEPTIONS if(Thread::getException() == Thread::throwObject) throw(this); #ifdef COMMON_STD_EXCEPTION else if(Thread::getException() == Thread::throwException) { if(!str) str = (char *)""; throw FileException(str); } #endif #endif } return id; } bool RandomFile::initial(void) { bool init; #ifdef _MSWINDOWS_ if(fd == INVALID_HANDLE_VALUE) #else if(fd < 0) #endif return false; enterMutex(); init = flags.initial; flags.initial = false; if(!init) { leaveMutex(); return false; } #ifdef _MSWINDOWS_ Attr access = initialize(); if(access == attrInvalid) { CloseHandle(fd); if(pathname) DeleteFile(pathname); fd = INVALID_HANDLE_VALUE; leaveMutex(); error(errInitFailed); return false; } #else int mode = (int)initialize(); if(!mode) { close(fd); fd = -1; if(pathname) remove(pathname); leaveMutex(); error(errInitFailed); return false; } fchmod(fd, mode); #endif leaveMutex(); return init; } #ifndef _MSWINDOWS_ RandomFile::Error RandomFile::setCompletion(Complete mode) { long flag = fcntl(fd, F_GETFL); if(fd < 0) return errNotOpened; flags.immediate = false; #ifdef O_SYNC flag &= ~(O_SYNC | O_NONBLOCK); #else flag &= ~O_NONBLOCK; #endif switch(mode) { case completionImmediate: #ifdef O_SYNC flag |= O_SYNC; #endif flags.immediate = true; break; case completionDelayed: flag |= O_NONBLOCK; //completionDeferred: ? (hen) case completionDeferred: break; } fcntl(fd, F_SETFL, flag); return errSuccess; } #endif off_t RandomFile::getCapacity(void) { off_t eof, pos = 0; #ifdef _MSWINDOWS_ if(!fd) #else if(fd < 0) #endif return 0; enterMutex(); #ifdef _MSWINDOWS_ pos = SetFilePointer(fd, 0l, NULL, FILE_CURRENT); eof = SetFilePointer(fd, 0l, NULL, FILE_END); SetFilePointer(fd, pos, NULL, FILE_BEGIN); #else lseek(fd, pos, SEEK_SET); pos = lseek(fd, 0l, SEEK_CUR); eof = lseek(fd, 0l, SEEK_END); #endif leaveMutex(); return eof; } bool RandomFile::operator!(void) { #ifdef _MSWINDOWS_ return fd == INVALID_HANDLE_VALUE; #else if(fd < 0) return true; return false; #endif } SharedFile::SharedFile(const char *path) : RandomFile(path) { fcb.address = NULL; fcb.len = 0; fcb.pos = 0; open(path); } SharedFile::SharedFile(const SharedFile &sh) : RandomFile(sh) { } SharedFile::~SharedFile() { final(); } SharedFile::Error SharedFile::open(const char *path) { #ifdef _MSWINDOWS_ if(fd != INVALID_HANDLE_VALUE) #else if(fd > -1) #endif final(); if(path != pathname) { if(pathname) delString(pathname); pathname = newString(path); } flags.initial = false; #ifdef _MSWINDOWS_ fd = CreateFile(pathname, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if(fd == INVALID_HANDLE_VALUE) { flags.initial = true; fd = CreateFile(pathname, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); } if(fd == INVALID_HANDLE_VALUE) return errOpenFailed; return errSuccess; #else fd = ::open(pathname, O_RDWR); if(fd < 0) { flags.initial = true; fd = ::open(pathname, O_CREAT | O_RDWR | O_TRUNC, (int)attrPrivate); } if(fd < 0) return error(errOpenFailed); #ifdef LOCK_SH if(::flock(fd, LOCK_SH | LOCK_NB)) { close(fd); fd = -1; return error(errOpenInUse); } #endif return errSuccess; #endif // WIN32 } SharedFile::Error SharedFile::fetch(caddr_t address, ccxx_size_t len, off_t pos) { #ifdef _MSWINDOWS_ if(fd == INVALID_HANDLE_VALUE) #else if(fd < 0) #endif return errNotOpened; enterMutex(); if(address) fcb.address = address; if(len) fcb.len = len; if(pos != -1) fcb.pos = pos; #ifdef _MSWINDOWS_ OVERLAPPED over; SetFilePointer(fd, fcb.pos, NULL, FILE_BEGIN); over.hEvent = 0; over.Offset = fcb.pos; over.OffsetHigh = 0; LockFileEx(fd, LOCKFILE_EXCLUSIVE_LOCK, 0, fcb.len, 0, &over); DWORD count; if(!ReadFile(fd, fcb.address, fcb.len, &count, NULL)) { leaveMutex(); return errReadFailure; } leaveMutex(); if(count < fcb.len) return errReadIncomplete; return errSuccess; #else lseek(fd, fcb.pos, SEEK_SET); if(lockf(fd, F_LOCK, fcb.len)) { leaveMutex(); return errLockFailure; } int io = ::read(fd, fcb.address, fcb.len); leaveMutex(); if((size_t) io == fcb.len) return errSuccess; if(io > -1) return errReadIncomplete; switch(errno) { case EINTR: return errReadInterrupted; default: return errReadFailure; } #endif } #ifndef _MSWINDOWS_ SharedFile::Error SharedFile::clear(ccxx_size_t len, off_t pos) { if(fd < 0) return errNotOpened; enterMutex(); if(len) fcb.len = len; if(pos != -1) fcb.pos = pos; lseek(fd, fcb.pos, SEEK_SET); if(lockf(fd, F_ULOCK, fcb.len)) { leaveMutex(); return errLockFailure; } leaveMutex(); return errSuccess; } #endif // ndef WIN32 SharedFile::Error SharedFile::update(caddr_t address, ccxx_size_t len, off_t pos) { #ifdef _MSWINDOWS_ if(fd == INVALID_HANDLE_VALUE) #else if(fd < 0) #endif return errNotOpened; enterMutex(); if(address) fcb.address = address; if(len) fcb.len = len; if(pos != -1) fcb.pos = pos; #ifdef _MSWINDOWS_ OVERLAPPED over; SetFilePointer(fd, fcb.pos, NULL, FILE_BEGIN); over.hEvent = 0; over.Offset = pos; over.OffsetHigh = 0; DWORD count; if(!WriteFile(fd, fcb.address, fcb.len, &count, NULL)) { SetFilePointer(fd, fcb.pos, NULL, FILE_CURRENT); UnlockFileEx(fd, 0, len, 0, &over); leaveMutex(); return errWriteFailure; } SetFilePointer(fd, fcb.pos, NULL, FILE_CURRENT); UnlockFileEx(fd, 0, len, 0, &over); leaveMutex(); if(count < fcb.len) return errWriteIncomplete; return errSuccess; #else lseek(fd, fcb.pos, SEEK_SET); int io = ::write(fd, fcb.address, fcb.len); if(lockf(fd, F_ULOCK, fcb.len)) { leaveMutex(); return errLockFailure; } leaveMutex(); if((size_t) io == fcb.len) return errSuccess; if(io > -1) return errWriteIncomplete; switch(errno) { case EINTR: return errWriteInterrupted; default: return errWriteFailure; } #endif // WIN32 } SharedFile::Error SharedFile::append(caddr_t address, ccxx_size_t len) { #ifdef _MSWINDOWS_ if(fd == INVALID_HANDLE_VALUE) #else if(fd < 0) #endif return errNotOpened; enterMutex(); if(address) fcb.address = address; if(len) fcb.len = len; #ifdef _MSWINDOWS_ fcb.pos = SetFilePointer(fd, 0l, NULL, FILE_END); OVERLAPPED over; over.hEvent = 0; over.Offset = fcb.pos; over.OffsetHigh = 0; LONG eof = fcb.pos; LockFileEx(fd, LOCKFILE_EXCLUSIVE_LOCK, 0, 0x7fffffff, 0, &over); fcb.pos = SetFilePointer(fd, 0l, NULL, FILE_END); DWORD count; if(!WriteFile(fd, fcb.address, fcb.len, &count, NULL)) { SetFilePointer(fd, eof, NULL, FILE_CURRENT); UnlockFileEx(fd, 0, 0x7fffffff, 0, &over); leaveMutex(); return errWriteFailure; } SetFilePointer(fd, eof, NULL, FILE_CURRENT); UnlockFileEx(fd, 0, 0x7fffffff, 0, &over); leaveMutex(); if(count < fcb.len) return errWriteIncomplete; return errSuccess; #else fcb.pos = lseek(fd, 0l, SEEK_END); if(lockf(fd, F_LOCK, -1)) { leaveMutex(); return errLockFailure; } fcb.pos = lseek(fd, 0l, SEEK_END); int io = ::write(fd, fcb.address, fcb.len); lseek(fd, fcb.pos, SEEK_SET); if(lockf(fd, F_ULOCK, -1)) { leaveMutex(); return errLockFailure; } leaveMutex(); if((size_t) io == fcb.len) return errSuccess; if(io > -1) return errWriteIncomplete; switch(errno) { case EINTR: return errWriteInterrupted; default: return errWriteFailure; } #endif // WIN32 } off_t SharedFile::getPosition(void) { return fcb.pos; } bool SharedFile::operator++(void) { off_t eof; enterMutex(); fcb.pos += fcb.len; #ifdef _MSWINDOWS_ eof = SetFilePointer(fd, 0l, NULL, FILE_END); #else eof = lseek(fd, 0l, SEEK_END); #endif if(fcb.pos >= eof) { fcb.pos = eof; leaveMutex(); return true; } leaveMutex(); return false; } bool SharedFile::operator--(void) { enterMutex(); fcb.pos -= fcb.len; if(fcb.pos <= 0) { fcb.pos = 0; leaveMutex(); return true; } leaveMutex(); return false; } size_t MappedFile::pageAligned(size_t size) { size_t pages = size / Process::getPageSize(); if(size % Process::getPageSize()) ++pages; return pages * Process::getPageSize(); } #ifdef _MSWINDOWS_ static void makemapname(const char *source, char *target) { unsigned count = 60; while(*source && count--) { if(*source == '/' || *source == '\\') *(target++) = '_'; else *(target++) = toupper(*source); ++source; } *target = 0; } MappedFile::MappedFile(const char *fname, Access mode, size_t size) : RandomFile(fname) { DWORD share = 0, page = 0; map = INVALID_HANDLE_VALUE; fcb.address = NULL; switch(mode) { case accessReadOnly: share = FILE_SHARE_READ; page = PAGE_READONLY; prot = FILE_MAP_READ; break; case accessWriteOnly: share = FILE_SHARE_WRITE; page = PAGE_WRITECOPY; prot = FILE_MAP_COPY; break; case accessReadWrite: share = FILE_SHARE_READ|FILE_SHARE_WRITE; page = PAGE_READWRITE; prot = FILE_MAP_WRITE; } if(share || page) fd = CreateFile(pathname, mode, share, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); else fd = INVALID_HANDLE_VALUE; if(fd == INVALID_HANDLE_VALUE) { error(errOpenFailed); return; } SetFilePointer(fd, (LONG)size, 0, FILE_BEGIN); SetEndOfFile(fd); makemapname(fname, mapname); map = CreateFileMapping(fd, NULL, page, 0, 0, mapname); if(!map) error(errMapFailed); fcb.address = (caddr_t)MapViewOfFile(map, prot, 0, 0, size); fcb.len = (ccxx_size_t)size; fcb.pos = 0; if(!fcb.address) error(errMapFailed); } MappedFile::MappedFile(const char *fname, Access mode) : RandomFile(fname) { DWORD share = 0, page = 0; map = INVALID_HANDLE_VALUE; fcb.address = NULL; switch(mode) { case accessReadOnly: share = FILE_SHARE_READ; page = PAGE_READONLY; prot = FILE_MAP_READ; break; case accessWriteOnly: share = FILE_SHARE_WRITE; page = PAGE_WRITECOPY; prot = FILE_MAP_COPY; break; case accessReadWrite: share = FILE_SHARE_READ|FILE_SHARE_WRITE; page = PAGE_READWRITE; prot = FILE_MAP_WRITE; } if(share || page) fd = CreateFile(pathname, mode, share, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); else fd = INVALID_HANDLE_VALUE; if(fd == INVALID_HANDLE_VALUE) { error(errOpenFailed); return; } makemapname(fname, mapname); map = CreateFileMapping(fd, NULL, page, 0, 0, mapname); if(!map) error(errMapFailed); } MappedFile::MappedFile(const char *fname, pos_t pos, size_t len, Access mode) : RandomFile(fname) { DWORD share = 0, page = 0; map = INVALID_HANDLE_VALUE; fcb.address = NULL; switch(mode) { case accessReadOnly: share = FILE_SHARE_READ; page = PAGE_READONLY; prot = FILE_MAP_READ; break; case accessWriteOnly: share = FILE_SHARE_WRITE; page = PAGE_WRITECOPY; prot = FILE_MAP_COPY; break; case accessReadWrite: share = FILE_SHARE_READ|FILE_SHARE_WRITE; page = PAGE_READWRITE; prot = FILE_MAP_WRITE; } if(share || page) fd = CreateFile(pathname, mode, share, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); else fd = INVALID_HANDLE_VALUE; if(fd == INVALID_HANDLE_VALUE) { error(errOpenFailed); return; } makemapname(fname, mapname); map = CreateFileMapping(fd, NULL, page, 0, 0, mapname); if(!map) { error(errMapFailed); return; } fcb.address = (caddr_t)MapViewOfFile(map, prot, 0, pos, len); fcb.len = (ccxx_size_t)len; fcb.pos = pos; if(!fcb.address) error(errMapFailed); } MappedFile::~MappedFile() { if(fcb.address) { unlock(); UnmapViewOfFile(fcb.address); } if(map != INVALID_HANDLE_VALUE) CloseHandle(map); final(); } void MappedFile::sync(void) { } void MappedFile::sync(caddr_t address, size_t len) { } void MappedFile::release(caddr_t address, size_t len) { if(fcb.address) { unlock(); UnmapViewOfFile(fcb.address); } fcb.address = NULL; } caddr_t MappedFile::fetch(off_t pos, size_t len) { if(fcb.address) { unlock(); UnmapViewOfFile(fcb.address); } fcb.address = (caddr_t)MapViewOfFile(map, prot, 0, pos, len); fcb.len = (ccxx_size_t)len; fcb.pos = pos; if(!fcb.address) error(errMapFailed); return fcb.address; } void MappedFile::update(size_t offset, size_t len) { } void MappedFile::update(caddr_t address, size_t len) { } bool MappedFile::lock(void) { unlock(); if(VirtualLock(fcb.address, fcb.len)) fcb.locked = true; return fcb.locked; } void MappedFile::unlock(void) { if(!fcb.address) fcb.locked = false; if(!fcb.locked) return; VirtualUnlock(fcb.address, fcb.len); fcb.locked = false; } #else #ifdef HAVE_MLOCK MappedFile::MappedFile(const char *fname, Access mode) : RandomFile(fname) { fd = open(fname, (int)mode); if(fd < 0 && mode != accessReadOnly) fd = ::open(pathname, O_CREAT | O_RDWR | O_TRUNC, (int)attrPrivate); if(fd < 0) { error(errOpenFailed); return; } switch(mode) { case O_RDONLY: prot = PROT_READ; break; case O_WRONLY: prot = PROT_WRITE; break; default: prot = PROT_READ | PROT_WRITE; } } MappedFile::MappedFile(const char *fname, Access mode, size_t size) : RandomFile(fname) { fd = open(fname, (int)mode | O_CREAT, 0660); if(fd < 0) { error(errOpenFailed); return; } switch(mode) { case O_RDONLY: prot = PROT_READ; break; case O_WRONLY: prot = PROT_WRITE; break; default: prot = PROT_READ | PROT_WRITE; } enterMutex(); lseek(fd, size, SEEK_SET); fcb.address = (caddr_t)mmap(NULL, size, prot, MAP_SHARED, fd, 0); fcb.len = size; fcb.pos = 0; leaveMutex(); if((caddr_t)(fcb.address) == (caddr_t)(MAP_FAILED)) { close(fd); fd = -1; error(errMapFailed); } } MappedFile::MappedFile(const char *fname, pos_t pos, size_t len, Access mode) : RandomFile(fname) { fd = open(fname, (int)mode); if(fd < 0) { error(errOpenFailed); return; } switch(mode) { case O_RDONLY: prot = PROT_READ; break; case O_WRONLY: prot = PROT_WRITE; break; default: prot = PROT_READ | PROT_WRITE; } enterMutex(); lseek(fd, pos + len, SEEK_SET); fcb.address = (caddr_t)mmap(NULL, len, prot, MAP_SHARED, fd, pos); fcb.len = len; fcb.pos = pos; leaveMutex(); if((caddr_t)(fcb.address) == (caddr_t)(MAP_FAILED)) { close(fd); fd = -1; error(errMapFailed); } } MappedFile::~MappedFile() { unlock(); final(); } void MappedFile::sync(void) { msync(fcb.address, fcb.len, MS_SYNC); } void MappedFile::release(caddr_t address, size_t len) { enterMutex(); if(address) fcb.address = address; if(len) fcb.len = len; if(fcb.locked) unlock(); munmap(fcb.address, fcb.len); leaveMutex(); } caddr_t MappedFile::fetch(off_t pos, size_t len) { enterMutex(); unlock(); fcb.len = len; fcb.pos = pos; lseek(fd, fcb.pos + len, SEEK_SET); fcb.address = (caddr_t)mmap(NULL, len, prot, MAP_SHARED, fd, pos); leaveMutex(); return fcb.address; } bool MappedFile::lock(void) { unlock(); if(!mlock(fcb.address, fcb.len)) fcb.locked = true; return fcb.locked; } void MappedFile::unlock(void) { if(!fcb.address) fcb.locked = false; if(!fcb.locked) return; munlock(fcb.address, fcb.len); fcb.locked = false; } void MappedFile::update(size_t offset, size_t len) { int mode = MS_ASYNC; caddr_t address; if(flags.immediate) mode = MS_SYNC; enterMutex(); address = fcb.address; address += offset; if(!len) len = fcb.len; leaveMutex(); msync(address, len, mode); } void MappedFile::update(caddr_t address, size_t len) { int mode = MS_ASYNC; if(flags.immediate) mode = MS_SYNC; msync(address, len, mode); } #endif #endif // ndef WIN32 #ifdef _MSWINDOWS_ #ifndef SECS_BETWEEN_EPOCHS #define SECS_BETWEEN_EPOCHS 11644473600LL #endif #ifndef SECS_TO_100NS #define SECS_TO_100NS 10000000LL #endif #endif time_t lastAccessed(const char *path) { #ifdef _MSWINDOWS_ __int64 ts; WIN32_FILE_ATTRIBUTE_DATA ino; if(!GetFileAttributesEx(path, GetFileExInfoStandard, &ino)) return 0; ts = ((__int64)ino.ftLastAccessTime.dwHighDateTime << 32) + ino.ftLastAccessTime.dwLowDateTime; ts -= (SECS_BETWEEN_EPOCHS * SECS_TO_100NS); ts /= SECS_TO_100NS; return(time_t)ts; #else struct stat ino; if(stat(path, &ino)) return 0; return ino.st_atime; #endif } time_t lastModified(const char *path) { #ifdef _MSWINDOWS_ __int64 ts; WIN32_FILE_ATTRIBUTE_DATA ino; if(!GetFileAttributesEx(path, GetFileExInfoStandard, &ino)) return 0; ts = ((__int64)ino.ftLastWriteTime.dwHighDateTime << 32) + ino.ftLastWriteTime.dwLowDateTime; ts -= (SECS_BETWEEN_EPOCHS * SECS_TO_100NS); ts /= SECS_TO_100NS; return(time_t)ts; #else struct stat ino; if(stat(path, &ino)) return 0; return ino.st_mtime; #endif } bool isDir(const char *path) { #ifdef _MSWINDOWS_ DWORD attr = GetFileAttributes(path); if(attr == (DWORD)~0l) return false; if(attr & FILE_ATTRIBUTE_DIRECTORY) return true; return false; #else struct stat ino; if(stat(path, &ino)) return false; if(S_ISDIR(ino.st_mode)) return true; return false; #endif // WIN32 } bool isFile(const char *path) { #ifdef _MSWINDOWS_ DWORD attr = GetFileAttributes(path); if(attr == (DWORD)~0l) return false; if(attr & FILE_ATTRIBUTE_DIRECTORY) return false; return true; #else struct stat ino; if(stat(path, &ino)) return false; if(S_ISREG(ino.st_mode)) return true; return false; #endif // WIN32 } #ifndef _MSWINDOWS_ // the Win32 version is given in line in the header bool isDevice(const char *path) { struct stat ino; if(stat(path, &ino)) return false; if(S_ISCHR(ino.st_mode)) return true; return false; } #endif bool canAccess(const char *path) { #ifdef _MSWINDOWS_ DWORD attr = GetFileAttributes(path); if(attr == (DWORD)~0l) return false; if(attr & FILE_ATTRIBUTE_SYSTEM) return false; if(attr & FILE_ATTRIBUTE_HIDDEN) return false; return true; #else if(!access(path, R_OK)) return true; return false; #endif } bool canModify(const char *path) { #ifdef _MSWINDOWS_ DWORD attr = GetFileAttributes(path); if(!canAccess(path)) return false; if(attr & FILE_ATTRIBUTE_READONLY) return false; if(attr & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_NORMAL)) return true; return false; #else if(!access(path, W_OK | R_OK)) return true; return false; #endif } #ifdef _MSWINDOWS_ const char *File::getExtension(const char *path) { const char *cp = strrchr(path, '\\'); if(!cp) cp = strrchr(path, '/'); if(!cp) cp = strrchr(path, ':'); if(cp) ++cp; else cp = path; if(*cp == '.') return ""; cp = strrchr(cp, '.'); if(!cp) cp = ""; return cp; } const char *File::getFilename(const char *path) { const char *cp = strrchr(path, '\\'); if(cp) return ++cp; cp = strrchr(path, '/'); if(cp) return ++cp; cp = strrchr(path, ':'); if(cp) ++cp; return path; } char *File::getFilename(const char *path, char *buffer, size_t size) { const char *cp = strrchr(path, '\\'); if(!cp) cp = strrchr(path, '/'); if(!cp) cp = strrchr(path, ':'); if(cp) snprintf(buffer, size, "%s", ++cp); else snprintf(buffer, size, "%s", path); return buffer; } char *File::getDirname(const char *path, char *buffer, size_t size) { size_t len; const char *cp = strrchr(path, '\\'); snprintf(buffer, size, "%s", path); if(!cp) cp = strrchr(path, '/'); if(!cp) cp = strrchr(path, ':'); if(!cp) return buffer; if(cp) len = cp - path; if(len >= size) len = size - 1; buffer[len] = 0; return buffer; } #else const char *File::getExtension(const char *path) { const char *cp = strrchr(path, '/'); if(cp) ++cp; else cp = path; if(*cp == '.') return ""; cp = strrchr(cp, '.'); if(cp) return cp; return ""; } char *File::getDirname(const char *path, char *buffer, size_t size) { unsigned len; const char *cp = strrchr(path, '/'); snprintf(buffer, size, "%s", path); if(!cp) return buffer; if(cp) len = cp - path; if(len >= size) len = size - 1; buffer[len] = 0; return buffer; } const char *File::getFilename(const char *path) { const char *cp = strrchr(path, '/'); if(cp) return ++cp; return path; } char *File::getFilename(const char *path, char *buffer, size_t size) { const char *cp = strrchr(path, '/'); if(cp) snprintf(buffer, size, "%s", ++cp); else snprintf(buffer, size, "%s", path); return buffer; } #endif #ifdef HAVE_REALPATH char *File::getRealpath(const char *path, char *buffer, size_t size) { char temp[PATH_MAX]; setString(buffer, size, "."); if(!realpath(path, temp)) return NULL; if(strlen(temp) >= size) return NULL; setString(buffer, size, temp); return buffer; } #else #ifdef _MSWINDOWS_ static char *getFile(char *path) { char *cp = strchr(path, '\\'); if(!cp) cp = strchr(path, '/'); if(!cp) cp = strchr(path, ':'); return cp; } #else static char *getFile(char *path) { return strchr(path, '/'); } #endif char *File::getRealpath(const char *path, char *buffer, size_t size) { if(size > PATH_MAX) size = PATH_MAX; #ifdef HAVE_LSTAT unsigned symlinks = 0; #endif #if !defined(DYNAMCIC_LOCAL_ARRAYS) char left[PATH_MAX]; #else char left[size]; #endif size_t left_len, buffer_len; #ifdef _MSWINDOWS_ if(path[1] == ':') #else if(path[0] == '/') #endif { buffer[0] = '/'; buffer[1] = 0; if(!path[1]) return buffer; buffer_len = 1; snprintf(left, size, "%s", path + 1); left_len = strlen(left); } else { if(!Dir::getPrefix(buffer, size)) { snprintf(buffer, size, "%s", "."); return NULL; } buffer_len = strlen(buffer); snprintf(left, size, "%s", path); left_len = strlen(left); } if(left_len >= size || buffer_len >= size) return NULL; while(left_len > 0) { #ifdef HAVE_LSTAT struct stat ino; #endif #if !defined(DYNAMIC_LOCAL_ARRAYS) char next_token[PATH_MAX]; #else char next_token[size]; #endif char *p; const char *s = (p = getFile(left)) ? p : left + left_len; memmove(next_token, left, s - left); left_len -= s - left; if(p != NULL) memmove(left, s + 1, left_len + 1); next_token[s - left] = 0; if(buffer[buffer_len - 1] != '/') { if(buffer_len +1 >= size) return NULL; buffer[buffer_len++] = '/'; buffer[buffer_len] = 0; } if(!next_token[0]) continue; else if(!strcmp(next_token, ".")) continue; else if(!strcmp(next_token, "..")) { if(buffer_len > 1) { char *q; buffer[buffer_len - 1] = 0; #ifdef _MSWINDOWS_ q = strrchr(buffer, '\\'); if(!q) q = strrchr(buffer, '/'); if(!q) q = strchr(buffer, ':'); #else q = strrchr(buffer, '/'); #endif *q = 0; buffer_len = q - buffer; } continue; } snprintf(next_token, size, "%s", buffer); buffer_len = strlen(buffer); if(buffer_len >= size) return NULL; #ifndef HAVE_LSTAT if(!isFile(buffer) && !isDir(buffer)) return buffer; continue; #else if(lstat(buffer, &ino) < 0) { if(errno == ENOENT && !p) return buffer; return NULL; } if((ino.st_mode & S_IFLNK) == S_IFLNK) { char symlink[size]; int slen; if (symlinks++ > MAXSYMLINKS) return NULL; slen = readlink(buffer, symlink, size); if (slen < 0) return NULL; symlink[slen] = 0; if (symlink[0] == '/') { buffer[1] = 0; buffer_len = 1; } else if (buffer_len > 1) { char *q; buffer[buffer_len - 1] = 0; q = strrchr(buffer, '/'); *q = 0; buffer_len = q - buffer; } if (symlink[slen - 1] != '/' && p) { if (slen >= size) return NULL; symlink[slen] = '/'; symlink[slen + 1] = 0; } if(p) { snprintf(symlink, size, "%s", left); left_len = strlen(symlink); } if(left_len >= size) return NULL; snprintf(left, size, "%s", symlink); left_len = strlen(left); } #endif } #ifdef _MSWINDOWS_ if(buffer_len > 1 && buffer[buffer_len - 1] == '\\') buffer[buffer_len - 1] = 0; else if(buffer_len > 1 && buffer[buffer_len - 1] == '/') buffer[buffer_len - 1] = 0; #else if(buffer_len > 1 && buffer[buffer_len - 1] == '/') buffer[buffer_len - 1] = 0; #endif return buffer; } #endif END_NAMESPACE ucommon-6.0.7/commoncpp/dso.cpp0000644000175000017500000001771112163025062013412 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include #include using namespace COMMONCPP_NAMESPACE; DSO *DSO::first = NULL; DSO *DSO::last = NULL; Mutex DSO::mutex; #if defined(HAVE_DLFCN_H) extern "C" { #include } #ifndef RTLD_GLOBAL #define RTLD_GLOBAL 0 #endif #endif // HAVE_DLFN_H #ifdef HAVE_SHL_LOAD #include #endif #ifdef HAVE_MACH_O_DYLD_H #include #define oModule ((oModule)(image)) #endif #ifdef _MSWINDOWS_ #define hImage ((HMODULE)(image)) #endif void DSO::dynunload(void) { while(DSO::last) delete DSO::last; } DSO::~DSO() { #if defined(HAVE_MACH_DYLD) NSSymbol sym; void (*fini)(void); #endif MutexLock lock(mutex); #if defined(_MSWINDOWS_) if(image) FreeLibrary(hImage); #elif defined(HAVE_MACH_DYLD) if(image == NULL) return; sym = NSLookupSymbolInModule(oModule, "__fini"); if(sym != NULL) { fini = (void (*)(void))NSAddressOfSymbol(sym); fini(); } NSUnLinkModule(oModule, NSUNLINKMODULE_OPTION_NONE); #elif defined(HAVE_SHL_LOAD) if(image) shl_unload(image); #elif defined(HAVE_DLFCN_H) if(image) dlclose(image); #endif if(first == this && last == this) first = last = NULL; if(!next && !prev) return; if(prev) prev->next = next; if(next) next->prev = prev; if(first == this) first = next; if(last == this) last = prev; } void DSO::loader(const char *filename, bool flag) { #if defined(HAVE_MACH_DYLD) NSObjectFileImage oImage; NSSymbol sym = NULL; void (*init)(void); #endif id = strrchr(filename, '/'); if(id) ++id; else id = filename; next = prev = NULL; #if defined(_MSWINDOWS_) image = LoadLibrary(filename); err = "none"; #elif defined(HAVE_MACH_DYLD) err = "none"; image = NULL; fprintf(stderr, "**** HERE %s\n", filename); switch(NSCreateObjectFileImageFromFile(filename, &oImage)) { case NSObjectFileImageSuccess: break; default: err = "unknown error"; return; } if(flag) image = NSLinkModule(oImage, filename, NSLINKMODULE_OPTION_BINDNOW | NSLINKMODULE_OPTION_RETURN_ON_ERROR); else image = NSLinkModule(oImage, filename, NSLINKMODULE_OPTION_RETURN_ON_ERROR); NSDestroyObjectFileImage(oImage); if(oModule != NULL) sym = NSLookupSymbolInModule(oModule, "__init"); if(sym) { init = (void (*)(void))NSAddressOfSymbol(sym); init(); } #elif defined(HAVE_SHL_LOAD) err = "none"; if(flag) image = shl_load(filename, BIND_IMMEDIATE, 0L); else image = shl_load(filename, BIND_DEFERRED, 0L); #elif defined(HAVE_DLFCN_H) if(flag) image = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); else image = dlopen(filename, RTLD_LAZY | RTLD_GLOBAL); #endif #if defined(_MSWINDOWS_) if(!image) { err = "load failed"; #elif defined(HAVE_MACH_DYLD) if(image == NULL) { err = "load failed"; #elif defined(HAVE_SHL_LOAD) if(!image) { err = "load failed"; #elif defined(HAVE_DLFCN_H) if(!image) { err = dlerror(); #else if(1) { err = "load unsupported"; #endif // since generally failure to map or load a plugin is fatel in most // cases, we should generally log the error to syslog as well as notify // the upper level system of the failure through exception. slog.error() << "dso: " << id << ": " << err << std::endl; #ifdef CCXX_EXCEPTIONS if(Thread::getException() == Thread::throwObject) throw(this); #ifdef COMMON_STD_EXCEPTION else if(Thread::getException() == Thread::throwException) throw(DSOException(String(id) + err)); #endif #endif return; } if(!last) { last = first = this; return; } mutex.enterMutex(); last->next = this; prev = last; last = this; mutex.leaveMutex(); } DSO *DSO::getObject(const char *id) { const char *chk = strrchr(id, '/'); DSO *dso; if(chk) ++chk; else chk = id; mutex.enterMutex(); dso = first; while(dso) { if(!stricmp(dso->id, chk)) break; dso = dso->next; } mutex.leaveMutex(); return dso; } bool DSO::isValid(void) { #if defined(_MSWINDOWS_) if(!image) #elif defined(HAVE_MACH_DYLD) if(image == NULL) #else if(!image) #endif return false; return true; } DSO::addr_t DSO::operator[](const char *sym) { #if defined(HAVE_SHL_LOAD) int value; shl_t handle = (shl_t)image; if(shl_findsym(&handle, sym, 0, &value) == 0) return (DSO::addr_t)value; else return NULL; #elif defined(HAVE_MACH_DYLD) NSSymbol oSymbol = NSLookupSymbolInModule(oModule, sym); if(oSymbol) return (DSO::addr_t)NSAddressOfSymbol(oSymbol); else return (DSO::addr_t)NULL; #elif defined(_MSWINDOWS_) DSO::addr_t addr = (DSO::addr_t)GetProcAddress(hImage, sym); if(!addr) err = "symbol missing"; return addr; #elif defined(HAVE_DLFCN_H) return (DSO::addr_t)dlsym(image, (char *)sym); #else return (DSO::addr_t)NULL; #endif } #ifdef HAVE_MACH_DYLD static void MyLinkError(NSLinkEditErrors c, int errorNumber, const char *filename, const char *errstr) { slog.error() << "dyld: " << filename << ": " << errstr << std::endl; } static void MyUndefined(const char *symname) { slog.error() << "dyld: undefined: " << symname << std::endl; } static NSModule MyMultiple(NSSymbol s, NSModule oMod, NSModule nMod) { slog.error() << "dyld: multiply defined symbols" << std::endl; } void DSO::setDebug(void) { static NSLinkEditErrorHandlers handlers = { &MyUndefined, &MyMultiple, &MyLinkError}; NSInstallLinkEditErrorHandlers(&handlers); } #else void DSO::setDebug(void) { } #endif ucommon-6.0.7/commoncpp/serial.cpp0000644000175000017500000011517412163025062014106 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include #include #ifdef _MSWINDOWS_ #define B256000 CBR_256000 #define B128000 CBR_128000 #define B115200 CBR_115200 #define B57600 CBR_57600 #define B56000 CBR_56000 #define B38400 CBR_38400 #define B19200 CBR_19200 #define B14400 CBR_14400 #define B9600 CBR_9600 #define B4800 CBR_4800 #define B2400 CBR_2400 #define B1200 CBR_1200 #define B600 CBR_600 #define B300 CBR_300 #define B110 CBR_110 #include #else #include #ifdef HAVE_TERMIOS_H #include #endif #endif #include #include #include NAMESPACE_COMMONCPP using std::streambuf; using std::iostream; using std::ios; #ifndef MAX_INPUT #define MAX_INPUT 255 #endif #ifndef MAX_CANON #define MAX_CANON MAX_INPUT #endif #ifdef __FreeBSD__ #undef _PC_MAX_INPUT #undef _PC_MAX_CANON #endif #if defined(__QNX__) #define CRTSCTS (IHFLOW | OHFLOW) #endif #if defined(_THR_UNIXWARE) || defined(__hpux) || defined(_AIX) #include #define CRTSCTS (CTSXON | RTSXOFF) #endif // IRIX #ifndef CRTSCTS #ifdef CNEW_RTSCTS #define CRTSCTS (CNEW_RTSCTS) #endif #endif #if defined(CTSXON) && defined(RTSXOFF) && !defined(CRTSCTS) #define CRTSCTS (CTSXON | RTSXOFF) #endif #ifndef CRTSCTS #define CRTSCTS 0 #endif Serial::Serial(const char *fname) { initSerial(); #if defined(_MSWINDOWS_) || defined(HAVE_TERMIOS_H) open(fname); #endif #ifdef _MSWINDOWS_ if(dev == INVALID_HANDLE_VALUE) #elif defined(HAVE_TERMIOS_H) if(dev < 0) #else if(1) #endif { error(errOpenFailed); return; } #ifdef _MSWINDOWS_ COMMTIMEOUTS CommTimeOuts ; GetCommTimeouts(dev, &CommTimeOuts); // CommTimeOuts.ReadIntervalTimeout = MAXDWORD; CommTimeOuts.ReadIntervalTimeout = 0; CommTimeOuts.ReadTotalTimeoutMultiplier = 0 ; CommTimeOuts.ReadTotalTimeoutConstant = 0; CommTimeOuts.WriteTotalTimeoutMultiplier = 0 ; CommTimeOuts.WriteTotalTimeoutConstant = 1000; SetCommTimeouts(dev, &CommTimeOuts) ; #elif defined(HAVE_TERMIOS_H) if(!isatty(dev)) { Serial::close(); error(errOpenNoTty); return; } #endif } Serial::~Serial() { endSerial(); } void Serial::initConfig(void) { #ifdef _MSWINDOWS_ #define ASCII_XON 0x11 #define ASCII_XOFF 0x13 DCB * attr = (DCB *)current; DCB * orig = (DCB *)original; attr->DCBlength = sizeof(DCB); orig->DCBlength = sizeof(DCB); GetCommState(dev, orig); GetCommState(dev, attr); attr->DCBlength = sizeof(DCB); attr->BaudRate = 1200; attr->Parity = NOPARITY; attr->ByteSize = 8; attr->XonChar = ASCII_XON; attr->XoffChar = ASCII_XOFF; attr->XonLim = 100; attr->XoffLim = 100; attr->fOutxDsrFlow = 0; attr->fDtrControl = DTR_CONTROL_ENABLE; attr->fOutxCtsFlow = 1; attr->fRtsControl = RTS_CONTROL_ENABLE; attr->fInX = attr->fOutX = 0; attr->fBinary = true; attr->fParity = true; SetCommState(dev, attr); #elif defined(HAVE_TERMIOS_H) struct termios *attr = (struct termios *)current; struct termios *orig = (struct termios *)original; long ioflags = fcntl(dev, F_GETFL); tcgetattr(dev, (struct termios *)original); tcgetattr(dev, (struct termios *)current); attr->c_oflag = attr->c_lflag = 0; attr->c_cflag = CLOCAL | CREAD | HUPCL; attr->c_iflag = IGNBRK; memset(attr->c_cc, 0, sizeof(attr->c_cc)); attr->c_cc[VMIN] = 1; // inherit original settings, maybe we should keep more?? cfsetispeed(attr, cfgetispeed(orig)); cfsetospeed(attr, cfgetospeed(orig)); attr->c_cflag |= orig->c_cflag & (CRTSCTS | CSIZE | PARENB | PARODD | CSTOPB); attr->c_iflag |= orig->c_iflag & (IXON | IXANY | IXOFF); tcsetattr(dev, TCSANOW, attr); fcntl(dev, F_SETFL, ioflags & ~O_NDELAY); #if defined(TIOCM_RTS) && defined(TIOCMODG) int mcs = 0; ioctl(dev, TIOCMODG, &mcs); mcs |= TIOCM_RTS; ioctl(dev, TIOCMODS, &mcs); #endif #ifdef _COHERENT ioctl(dev, TIOCSRTS, 0); #endif #endif // WIN32 } void Serial::restore(void) { #ifdef _MSWINDOWS_ memcpy(current, original, sizeof(DCB)); SetCommState(dev, (DCB *)current); #elif defined(HAVE_TERMIOS_H) memcpy(current, original, sizeof(struct termios)); tcsetattr(dev, TCSANOW, (struct termios *)current); #endif } void Serial::initSerial(void) { flags.thrown = false; flags.linebuf = false; errid = errSuccess; errstr = NULL; dev = INVALID_HANDLE_VALUE; #ifdef _MSWINDOWS_ current = new DCB; original = new DCB; #elif defined(HAVE_TERMIOS_H) current = new struct termios; original = new struct termios; #endif } void Serial::endSerial(void) { #ifdef _MSWINDOWS_ if(dev == INVALID_HANDLE_VALUE && original) SetCommState(dev, (DCB *)original); if(current) delete (DCB *)current; if(original) delete (DCB *)original; #elif defined(HAVE_TERMIOS_H) if(dev < 0 && original) tcsetattr(dev, TCSANOW, (struct termios *)original); if(current) delete (struct termios *)current; if(original) delete (struct termios *)original; #endif Serial::close(); current = NULL; original = NULL; } Serial::Error Serial::error(Error err, char *errs) { errid = err; errstr = errs; if(!err) return err; if(flags.thrown) return err; // prevents recursive throws flags.thrown = true; #ifdef CCXX_EXCEPTIONS if(Thread::getException() == Thread::throwObject) throw((Serial *)this); #ifdef COMMON_STD_EXCEPTION else if(Thread::getException() == Thread::throwException) { if(!errs) errs = (char *)""; throw SerException(String(errs)); } #endif #endif return err; } int Serial::setPacketInput(int size, unsigned char btimer) { #ifdef _MSWINDOWS_ // Still to be done...... return 0; #elif defined(HAVE_TERMIOS_H) #ifdef _PC_MAX_INPUT int max = fpathconf(dev, _PC_MAX_INPUT); #else int max = MAX_INPUT; #endif struct termios *attr = (struct termios *)current; if(size > max) size = max; attr->c_cc[VEOL] = attr->c_cc[VEOL2] = 0; attr->c_cc[VMIN] = (unsigned char)size; attr->c_cc[VTIME] = btimer; attr->c_lflag &= ~ICANON; tcsetattr(dev, TCSANOW, attr); bufsize = size; return size; #endif } int Serial::setLineInput(char newline, char nl1) { #ifdef _MSWINDOWS_ // Still to be done...... return 0; #elif defined(HAVE_TERMIOS_H) struct termios *attr = (struct termios *)current; attr->c_cc[VMIN] = attr->c_cc[VTIME] = 0; attr->c_cc[VEOL] = newline; attr->c_cc[VEOL2] = nl1; attr->c_lflag |= ICANON; tcsetattr(dev, TCSANOW, attr); #ifdef _PC_MAX_CANON bufsize = fpathconf(dev, _PC_MAX_CANON); #else bufsize = MAX_CANON; #endif return bufsize; #endif } void Serial::flushInput(void) { #ifdef _MSWINDOWS_ PurgeComm(dev, PURGE_RXABORT | PURGE_RXCLEAR); #elif defined(HAVE_TERMIOS_H) tcflush(dev, TCIFLUSH); #endif } void Serial::flushOutput(void) { #ifdef _MSWINDOWS_ PurgeComm(dev, PURGE_TXABORT | PURGE_TXCLEAR); #elif defined(HAVE_TERMIOS_H) tcflush(dev, TCOFLUSH); #endif } void Serial::waitOutput(void) { #ifdef _MSWINDOWS_ #elif defined(HAVE_TERMIOS_H) tcdrain(dev); #endif } Serial &Serial::operator=(const Serial &ser) { Serial::close(); if(ser.dev < 0) return *this; #ifdef _MSWINDOWS_ HANDLE process = GetCurrentProcess(); int result = DuplicateHandle(process, ser.dev, process, &dev, DUPLICATE_SAME_ACCESS, 0, 0); if (0 == result) { memcpy(current, ser.current, sizeof(DCB)); memcpy(original, ser.original, sizeof(DCB)); } #elif defined(HAVE_TERMIOS_H) dev = dup(ser.dev); memcpy(current, ser.current, sizeof(struct termios)); memcpy(original, ser.original, sizeof(struct termios)); #endif return *this; } void Serial::open(const char * fname) { #ifndef _MSWINDOWS_ int cflags = O_RDWR | O_NDELAY; dev = ::open(fname, cflags); if(dev > -1) initConfig(); #elif defined(HAVE_TERMIOS_H) // open COMM device dev = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, 0, // exclusive access NULL, // no security attrs OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL); if(dev != INVALID_HANDLE_VALUE) initConfig(); #endif } #ifdef _MSWINDOWS_ int Serial::aRead(char * Data, const int Length) { unsigned long dwLength = 0, dwError, dwReadLength; COMSTAT cs; OVERLAPPED ol; // Return zero if handle is invalid if(dev == INVALID_HANDLE_VALUE) return 0; // Read max length or only what is available ClearCommError(dev, &dwError, &cs); // If not requiring an exact byte count, get whatever is available if(Length > (int)cs.cbInQue) dwReadLength = cs.cbInQue; else dwReadLength = Length; memset(&ol, 0, sizeof(OVERLAPPED)); ol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if(dwReadLength > 0) { if(ReadFile(dev, Data, dwReadLength, &dwLength, &ol) == FALSE) { if(GetLastError() == ERROR_IO_PENDING) { WaitForSingleObject(ol.hEvent, INFINITE); GetOverlappedResult(dev, &ol, &dwLength, TRUE); } else ClearCommError(dev, &dwError, &cs); } } if(ol.hEvent != INVALID_HANDLE_VALUE) CloseHandle(ol.hEvent); return dwLength; } int Serial::aWrite(const char * Data, const int Length) { COMSTAT cs; unsigned long dwError = 0; OVERLAPPED ol; // Clear the com port of any error condition prior to read ClearCommError(dev, &dwError, &cs); unsigned long retSize = 0; memset(&ol, 0, sizeof(OVERLAPPED)); ol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if(WriteFile(dev, Data, Length, &retSize, &ol) == FALSE) { if(GetLastError() == ERROR_IO_PENDING) { WaitForSingleObject(ol.hEvent, INFINITE); GetOverlappedResult(dev, &ol, &retSize, TRUE); } else ClearCommError(dev, &dwError, &cs); } if(ol.hEvent != INVALID_HANDLE_VALUE) CloseHandle(ol.hEvent); return retSize; } #else int Serial::aRead(char *Data, const int Length) { return ::read(dev, Data, Length); } int Serial::aWrite(const char *Data, const int Length) { return ::write(dev, Data, Length); } #endif void Serial::close() { #ifdef _MSWINDOWS_ CloseHandle(dev); #else ::close(dev); #endif dev = INVALID_HANDLE_VALUE; } /* const int iAsync::getTimeOuts(unsigned long & readTimeout, unsigned long & writeTimeout) { return GetCommTimeouts(_TheHandle, &CommTimeOuts); } const int iAsync::setTimeOuts(unsigned long readTimeout, unsigned long writeTimeout) { COMMTIMEOUTS CommTimeOuts ; getTimeOuts(CommTimeOuts); CommTimeOuts.ReadIntervalTimeout = readTimeout; CommTimeOuts.ReadTotalTimeoutMultiplier = 0 ; CommTimeOuts.ReadTotalTimeoutConstant = 0; CommTimeOuts.WriteTotalTimeoutMultiplier = 0 ; CommTimeOuts.WriteTotalTimeoutConstant = 1000; return GetCommTimeouts(_TheHandle, &CommTimeOuts); } return SetCommTimeouts(_TheHandle, &CommTimeOuts) ; { DCB dcb ; dcb.DCBlength = sizeof(DCB) ; GetCommState(_TheHandle, &dcb) ; // hardcode this stuff for now..... dcb.BaudRate = _TheBaudrate; dcb.ByteSize = 8; dcb.Parity = NOPARITY; dcb.StopBits = ONESTOPBIT; dcb.fOutxDsrFlow = 0; dcb.fDtrControl = DTR_CONTROL_ENABLE ; dcb.fOutxCtsFlow = 1; dcb.fRtsControl = RTS_CONTROL_HANDSHAKE ; dcb.fInX = dcb.fOutX = 0; dcb.XonChar = ASCII_XON; dcb.XoffChar = ASCII_XOFF; dcb.XonLim = 100; dcb.XoffLim = 100; // other various settings dcb.fBinary = TRUE; dcb.fParity = TRUE; GetCommState(_TheHandle, &dcb) ; dcb.DCBlength = sizeof(DCB) ; dcb.BaudRate = _TheBaudrate; SetCommState(_TheHandle, &dcb) ; } */ Serial::Error Serial::setSpeed(unsigned long speed) { unsigned long rate; switch(speed) { #ifdef B115200 case 115200: rate = B115200; break; #endif #ifdef B57600 case 57600: rate = B57600; break; #endif #ifdef B38400 case 38400: rate = B38400; break; #endif case 19200: rate = B19200; break; case 9600: rate = B9600; break; case 4800: rate = B4800; break; case 2400: rate = B2400; break; case 1200: rate = B1200; break; case 600: rate = B600; break; case 300: rate = B300; break; case 110: rate = B110; break; #ifdef B0 case 0: rate = B0; break; #endif default: return error(errSpeedInvalid); } #ifdef _MSWINDOWS_ DCB * dcb = (DCB *)current; dcb->DCBlength = sizeof(DCB); GetCommState(dev, dcb); dcb->BaudRate = rate; SetCommState(dev, dcb) ; #else struct termios *attr = (struct termios *)current; cfsetispeed(attr, rate); cfsetospeed(attr, rate); tcsetattr(dev, TCSANOW, attr); #endif return errSuccess; } Serial::Error Serial::setFlowControl(Flow flow) { #ifdef _MSWINDOWS_ DCB * attr = (DCB *)current; attr->XonChar = ASCII_XON; attr->XoffChar = ASCII_XOFF; attr->XonLim = 100; attr->XoffLim = 100; switch(flow) { case flowSoft: attr->fInX = attr->fOutX = 1; break; case flowBoth: attr->fInX = attr->fOutX = 1; case flowHard: attr->fOutxCtsFlow = 1; attr->fRtsControl = RTS_CONTROL_HANDSHAKE; break; case flowNone: break; default: return error(errFlowInvalid); } SetCommState(dev, attr); #else struct termios *attr = (struct termios *)current; attr->c_cflag &= ~CRTSCTS; attr->c_iflag &= ~(IXON | IXANY | IXOFF); switch(flow) { case flowSoft: attr->c_iflag |= (IXON | IXANY | IXOFF); break; case flowBoth: attr->c_iflag |= (IXON | IXANY | IXOFF); case flowHard: attr->c_cflag |= CRTSCTS; break; case flowNone: break; default: return error(errFlowInvalid); } tcsetattr(dev, TCSANOW, attr); #endif return errSuccess; } Serial::Error Serial::setStopBits(int bits) { #ifdef _MSWINDOWS_ DCB * attr = (DCB *)current; switch(bits) { case 1: attr->StopBits = ONESTOPBIT; break; case 2: attr->StopBits = TWOSTOPBITS; break; default: return error(errStopbitsInvalid); } SetCommState(dev, attr); #else struct termios *attr = (struct termios *)current; attr->c_cflag &= ~CSTOPB; switch(bits) { case 1: break; case 2: attr->c_cflag |= CSTOPB; break; default: return error(errStopbitsInvalid); } tcsetattr(dev, TCSANOW, attr); #endif return errSuccess; } Serial::Error Serial::setCharBits(int bits) { #ifdef _MSWINDOWS_ DCB * attr = (DCB *)current; switch(bits) { case 5: case 6: case 7: case 8: attr->ByteSize = bits; break; default: return error(errCharsizeInvalid); } SetCommState(dev, attr); #else struct termios *attr = (struct termios *)current; attr->c_cflag &= ~CSIZE; switch(bits) { case 5: attr->c_cflag |= CS5; break; case 6: attr->c_cflag |= CS6; break; case 7: attr->c_cflag |= CS7; break; case 8: attr->c_cflag |= CS8; break; default: return error(errCharsizeInvalid); } tcsetattr(dev, TCSANOW, attr); #endif return errSuccess; } Serial::Error Serial::setParity(Parity parity) { #ifdef _MSWINDOWS_ DCB * attr = (DCB *)current; switch(parity) { case parityEven: attr->Parity = EVENPARITY; break; case parityOdd: attr->Parity = ODDPARITY; break; case parityNone: attr->Parity = NOPARITY; break; default: return error(errParityInvalid); } SetCommState(dev, attr); #else struct termios *attr = (struct termios *)current; attr->c_cflag &= ~(PARENB | PARODD); switch(parity) { case parityEven: attr->c_cflag |= PARENB; break; case parityOdd: attr->c_cflag |= (PARENB | PARODD); break; case parityNone: break; default: return error(errParityInvalid); } tcsetattr(dev, TCSANOW, attr); #endif return errSuccess; } void Serial::sendBreak(void) { #ifdef _MSWINDOWS_ SetCommBreak(dev); Thread::sleep(100L); ClearCommBreak(dev); #else tcsendbreak(dev, 0); #endif } void Serial::toggleDTR(timeout_t millisec) { #ifdef _MSWINDOWS_ EscapeCommFunction(dev, CLRDTR); if(millisec) { Thread::sleep(millisec); EscapeCommFunction(dev, SETDTR); } #else struct termios tty, old; tcgetattr(dev, &tty); tcgetattr(dev, &old); cfsetospeed(&tty, B0); cfsetispeed(&tty, B0); tcsetattr(dev, TCSANOW, &tty); if(millisec) { Thread::sleep(millisec); tcsetattr(dev, TCSANOW, &old); } #endif } bool Serial::isPending(Pending pending, timeout_t timeout) { #ifdef _MSWINDOWS_ unsigned long dwError; COMSTAT cs; ClearCommError(dev, &dwError, &cs); if(timeout == 0 || ((pending == pendingInput) && (0 != cs.cbInQue)) || ((pending == pendingOutput) && (0 != cs.cbOutQue)) || (pending == pendingError)) { switch(pending) { case pendingInput: return (0 != cs.cbInQue); case pendingOutput: return (0 != cs.cbOutQue); case pendingError: return false; } } else { OVERLAPPED ol; DWORD dwMask; DWORD dwEvents = 0; BOOL suc; memset(&ol, 0, sizeof(OVERLAPPED)); ol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if(pending == pendingInput) dwMask = EV_RXCHAR; else if(pending == pendingOutput) dwMask = EV_TXEMPTY; else // on error dwMask = EV_ERR; SetCommMask(dev, dwMask); // let's wait for event or timeout if((suc = WaitCommEvent(dev, &dwEvents, &ol)) == FALSE) { if(GetLastError() == ERROR_IO_PENDING) { DWORD transferred; dwError = WaitForSingleObject(ol.hEvent, timeout); if (dwError != WAIT_OBJECT_0) SetCommMask(dev, 0); suc = GetOverlappedResult(dev, &ol, &transferred, TRUE); if (suc) suc = (dwEvents & dwMask) ? TRUE : FALSE; } else ClearCommError(dev, &dwError, &cs); } if(ol.hEvent != INVALID_HANDLE_VALUE) CloseHandle(ol.hEvent); if(suc == FALSE) return false; return true; } #else int status = 0; #ifdef HAVE_POLL struct pollfd pfd; pfd.fd = dev; pfd.revents = 0; switch(pending) { case pendingInput: pfd.events = POLLIN; break; case pendingOutput: pfd.events = POLLOUT; break; case pendingError: pfd.events = POLLERR | POLLHUP; break; } status = 0; while(status < 1) { if(timeout == TIMEOUT_INF) status = poll(&pfd, 1, -1); else status = poll(&pfd, 1, timeout); if(status < 1) { if(status == -1 && errno == EINTR) continue; return false; } } if(pfd.revents & pfd.events) return true; #else struct timeval tv; fd_set grp; struct timeval *tvp = &tv; if(timeout == TIMEOUT_INF) tvp = NULL; else { tv.tv_usec = (timeout % 1000) * 1000; tv.tv_sec = timeout / 1000; } FD_ZERO(&grp); FD_SET(dev, &grp); switch(pending) { case pendingInput: status = select(dev + 1, &grp, NULL, NULL, tvp); break; case pendingOutput: status = select(dev + 1, NULL, &grp, NULL, tvp); break; case pendingError: status = select(dev + 1, NULL, NULL, &grp, tvp); break; } if(status < 1) return false; if(FD_ISSET(dev, &grp)) return true; #endif #endif // WIN32 return false; } TTYStream::TTYStream(const char *filename, timeout_t to) : streambuf(), Serial(filename), #ifdef HAVE_OLD_IOSTREAM iostream() #else iostream((streambuf *)this) #endif { #ifdef HAVE_OLD_IOSTREAM init((streambuf *)this); #endif gbuf = pbuf = NULL; timeout = to; if(INVALID_HANDLE_VALUE != dev) allocate(); } TTYStream::TTYStream() : streambuf(), Serial(), #ifdef HAVE_OLD_IOSTREAM iostream() #else iostream((streambuf *)this) #endif { #ifdef HAVE_OLD_IOSTREAM init((streambuf *)this); #endif timeout = 0; gbuf = pbuf = NULL; } TTYStream::~TTYStream() { endStream(); endSerial(); } void TTYStream::endStream(void) { if(bufsize) sync(); if(gbuf) { delete[] gbuf; gbuf = NULL; } if(pbuf) { delete[] pbuf; pbuf = NULL; } bufsize = 0; clear(); } void TTYStream::allocate(void) { if(INVALID_HANDLE_VALUE == dev) return; #ifdef _PC_MAX_INPUT bufsize = fpathconf(dev, _PC_MAX_INPUT); #else bufsize = MAX_INPUT; #endif gbuf = new char[bufsize]; pbuf = new char[bufsize]; if(!pbuf || !gbuf) { error(errResourceFailure); return; } clear(); #if !(defined(STLPORT) || defined(__KCC)) setg(gbuf, gbuf + bufsize, 0); #endif setg(gbuf, gbuf + bufsize, gbuf + bufsize); setp(pbuf, pbuf + bufsize); } int TTYStream::doallocate() { if(bufsize) return 0; allocate(); return 1; } void TTYStream::interactive(bool iflag) { #ifdef _MSWINDOWS_ if(dev == INVALID_HANDLE_VALUE) #else if(dev < 0) #endif return; if(bufsize >= 1) endStream(); if(iflag) { // setting to unbuffered mode bufsize = 1; gbuf = new char[bufsize]; #if !(defined(STLPORT) || defined(__KCC)) #if defined(__GNUC__) && (__GNUC__ < 3) setb(0,0); #endif #endif setg(gbuf, gbuf+bufsize, gbuf+bufsize); setp(pbuf, pbuf); return; } if(bufsize < 2) allocate(); } int TTYStream::uflow(void) { int rlen; unsigned char ch; if(bufsize < 2) { if(timeout) { if(Serial::isPending(pendingInput, timeout)) rlen = aRead((char *)&ch, 1); else rlen = -1; } else rlen = aRead((char *)&ch, 1); if(rlen < 1) { if(rlen < 0) clear(ios::failbit | rdstate()); return EOF; } return ch; } else { ch = underflow(); gbump(1); return ch; } } int TTYStream::underflow(void) { ssize_t rlen = 1; if(!gptr()) return EOF; if(gptr() < egptr()) return (unsigned char)*gptr(); rlen = (ssize_t)((gbuf + bufsize) - eback()); if(timeout && !Serial::isPending(pendingInput, timeout)) rlen = -1; else rlen = aRead((char *)eback(), rlen); if(rlen < 1) { if(rlen < 0) { clear(ios::failbit | rdstate()); error(errInput); } return EOF; } setg(eback(), eback(), eback() + rlen); return (unsigned char) *gptr(); } int TTYStream::sync(void) { if(bufsize > 1 && pbase() && ((pptr() - pbase()) > 0)) { overflow(0); waitOutput(); setp(pbuf, pbuf + bufsize); } setg(gbuf, gbuf + bufsize, gbuf + bufsize); return 0; } int TTYStream::overflow(int c) { unsigned char ch; ssize_t rlen, req; if(bufsize < 2) { if(c == EOF) return 0; ch = (unsigned char)(c); rlen = aWrite((char *)&ch, 1); if(rlen < 1) { if(rlen < 0) clear(ios::failbit | rdstate()); return EOF; } else return c; } if(!pbase()) return EOF; req = (ssize_t)(pptr() - pbase()); if(req) { rlen = aWrite((char *)pbase(), req); if(rlen < 1) { if(rlen < 0) clear(ios::failbit | rdstate()); return EOF; } req -= rlen; } if(req) // memmove(pptr(), pptr() + rlen, req); memmove(pbuf, pbuf + rlen, req); setp(pbuf + req, pbuf + bufsize); if(c != EOF) { *pptr() = (unsigned char)c; pbump(1); } return c; } bool TTYStream::isPending(Pending pending, timeout_t timer) { // if(pending == pendingInput && in_avail()) // return true; // else if(pending == pendingOutput) // flush(); return Serial::isPending(pending, timer); } ttystream::ttystream() : TTYStream() { setError(false); } ttystream::ttystream(const char *name) : TTYStream() { setError(false); open(name); } void ttystream::close(void) { #ifdef _MSWINDOWS_ if (INVALID_HANDLE_VALUE == dev) #else if(dev < 0) #endif return; endStream(); restore(); TTYStream::close(); } void ttystream::open(const char *name) { const char *cpp; char *cp; char pathname[256]; size_t namelen; long opt; if (INVALID_HANDLE_VALUE != dev) { restore(); close(); } cpp = strrchr(name, ':'); if(cpp) namelen = cpp - name; else namelen = strlen(name); cp = pathname; #ifndef _MSWINDOWS_ if(*name != '/') { strcpy(pathname, "/dev/"); cp += 5; } if((cp - pathname) + namelen > 255) { error(errResourceFailure); return; } #endif setString(cp, pathname - cp + sizeof(pathname), name); cp += namelen; #ifdef _MSWINDOWS_ *cp++ = ':'; #endif *cp = 0; Serial::open(pathname); if(INVALID_HANDLE_VALUE == dev) { error(errOpenFailed); return; } allocate(); setString(pathname, sizeof(pathname), name + namelen); cp = pathname + 1; if(*pathname == ':') cp = strtok(cp, ","); else cp = NULL; while(cp) { switch(*cp) { case 'h': case 'H': setFlowControl(flowHard); break; case 's': case 'S': setFlowControl(flowSoft); break; case 'b': case 'B': setFlowControl(flowBoth); break; case 'n': case 'N': setParity(parityNone); break; case 'O': case 'o': setParity(parityOdd); break; case 'e': case 'E': setParity(parityEven); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': opt = atol(cp); if(opt == 1 || opt == 2) { setStopBits((int)opt); break; } if(opt > 4 && opt < 9) { setCharBits((int)opt); break; } setSpeed(opt); break; default: error(errOptionInvalid); } cp = strtok(NULL, ","); } } TTYSession::TTYSession(const char *filename, int pri, int stack) : Thread(pri, stack), TTYStream(filename) { setError(false); } TTYSession::~TTYSession() { terminate(); endSerial(); } #ifndef _MSWINDOWS_ // Not supporting this right now........ // SerialPort::SerialPort(SerialService *svc, const char *name) : Serial(name), detect_pending(true), detect_output(false), detect_disconnect(true) { next = prev = NULL; service = NULL; #ifdef _MSWINDOWS_ if(INVALID_HANDLE_VALUE != dev) #else if(dev > -1) #endif { setError(false); service = svc; svc->attach(this); } } SerialPort::~SerialPort() { if(service) service->detach(this); endSerial(); } void SerialPort::expired(void) { } void SerialPort::pending(void) { } void SerialPort::disconnect(void) { } void SerialPort::output(void) { } void SerialPort::setTimer(timeout_t ptimer) { TimerPort::setTimer(ptimer); service->update(); } void SerialPort::incTimer(timeout_t ptimer) { TimerPort::incTimer(ptimer); service->update(); } void SerialPort::setDetectPending( bool val ) { if ( detect_pending != val ) { detect_pending = val; #ifdef USE_POLL if ( ufd ) { if ( val ) { ufd->events |= POLLIN; } else { ufd->events &= ~POLLIN; } } #endif service->update(); } } void SerialPort::setDetectOutput( bool val ) { if ( detect_output != val ) { detect_output = val; #ifdef USE_POLL if ( ufd ) { if ( val ) { ufd->events |= POLLOUT; } else { ufd->events &= ~POLLOUT; } } #endif service->update(); } } SerialService::SerialService(int pri, size_t stack, const char *id) : Thread(pri, stack), Mutex() { long opt; first = last = NULL; count = 0; FD_ZERO(&connect); if(::pipe(iosync)) { #ifdef CCXX_EXCEPTIONS switch(Thread::getException()) { case throwObject: throw(this); return; #ifdef COMMON_STD_EXCEPTION case throwException: throw(ThrException("no service pipe")); return; #endif default: return; } #else return; #endif } hiwater = iosync[0] + 1; FD_SET(iosync[0], &connect); opt = fcntl(iosync[0], F_GETFL); fcntl(iosync[0], F_SETFL, opt | O_NDELAY); } SerialService::~SerialService() { update(0); terminate(); while(first) delete first; } void SerialService::onUpdate(unsigned char flag) { } void SerialService::onEvent(void) { } void SerialService::onCallback(SerialPort *port) { } void SerialService::attach(SerialPort *port) { enterMutex(); #ifdef USE_POLL port->ufd = 0; #endif if(last) last->next = port; port->prev = last; last = port; FD_SET(port->dev, &connect); if(port->dev >= hiwater) hiwater = port->dev + 1; if(!first) { first = port; leaveMutex(); ++count; start(); } else { leaveMutex(); update(); ++count; } } void SerialService::detach(SerialPort *port) { enterMutex(); #ifndef USE_POLL FD_CLR(port->dev, &connect); #endif if(port->prev) port->prev->next = port->next; else first = port->next; if(port->next) port->next->prev = port->prev; else last = port->prev; --count; leaveMutex(); update(); } void SerialService::update(unsigned char flag) { if(::write(iosync[1], (char *)&flag, 1) < 1) { #ifdef CCXX_EXCEPTIONS switch(Thread::getException()) { case throwObject: throw(this); return; #ifdef COMMON_STD_EXCEPTION case throwException: throw(ThrException("update failed")); return; #endif default: return; } #else return; #endif } } void SerialService::run(void) { timeout_t timer, expires; SerialPort *port; unsigned char buf; #ifdef USE_POLL Poller mfd; pollfd *p_ufd; int lastcount = 0; // initialize ufd in all attached ports : // probably don't need this but it can't hurt. enterMutex(); port = first; while(port) { port->ufd = 0; port = port->next; } leaveMutex(); #else struct timeval timeout, *tvp; fd_set inp, out, err; int dev; FD_ZERO(&inp); FD_ZERO(&out); FD_ZERO(&err); #endif for(;;) { timer = TIMEOUT_INF; while(1 == ::read(iosync[0], (char *)&buf, 1)) { if(buf) { onUpdate(buf); continue; } Thread::exit(); } #ifdef USE_POLL bool reallocate = false; enterMutex(); onEvent(); port = first; while(port) { onCallback(port); if ( ( p_ufd = port->ufd ) ) { if ( ( POLLHUP | POLLNVAL ) & p_ufd->revents ) { // Avoid infinite loop from disconnected sockets port->detect_disconnect = false; p_ufd->events &= ~POLLHUP; port->disconnect(); } if ( ( POLLIN | POLLPRI ) & p_ufd->revents ) port->pending(); if ( POLLOUT & p_ufd->revents ) port->output(); } else { reallocate = true; } retry: expires = port->getTimer(); if(expires > 0) if(expires < timer) timer = expires; if(!expires) { port->endTimer(); port->expired(); goto retry; } port = port->next; } // // reallocate things if we saw a ServerPort without // ufd set ! if ( reallocate || ( ( count + 1 ) != lastcount ) ) { lastcount = count + 1; p_ufd = mfd.getList( count + 1 ); // Set up iosync polling p_ufd->fd = iosync[0]; p_ufd->events = POLLIN | POLLHUP; p_ufd ++; port = first; while(port) { p_ufd->fd = port->dev; p_ufd->events = ( port->detect_disconnect ? POLLHUP : 0 ) | ( port->detect_output ? POLLOUT : 0 ) | ( port->detect_pending ? POLLIN : 0 ) ; port->ufd = p_ufd; p_ufd ++; port = port->next; } } leaveMutex(); poll( mfd.getList(), count + 1, timer ); #else enterMutex(); onEvent(); port = first; while(port) { onCallback(port); dev = port->dev; if(FD_ISSET(dev, &err)) { port->detect_disconnect = false; port->disconnect(); } if(FD_ISSET(dev, &inp)) port->pending(); if(FD_ISSET(dev, &out)) port->output(); retry: expires = port->getTimer(); if(expires > 0) if(expires < timer) timer = expires; if(!expires) { port->endTimer(); port->expired(); goto retry; } port = port->next; } FD_ZERO(&inp); FD_ZERO(&out); FD_ZERO(&err); int so; port = first; while(port) { so = port->dev; if(port->detect_pending) FD_SET(so, &inp); if(port->detect_output) FD_SET(so, &out); if(port->detect_disconnect) FD_SET(so, &err); port = port->next; } leaveMutex(); if(timer == TIMEOUT_INF) tvp = NULL; else { tvp = &timeout; timeout.tv_sec = timer / 1000; timeout.tv_usec = (timer % 1000) * 1000; } select(hiwater, &inp, &out, &err, tvp); #endif } } #endif END_NAMESPACE /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 8 * End: */ ucommon-6.0.7/commoncpp/socket.cpp0000644000175000017500000007071112163025062014114 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #ifdef _MSWINDOWS_ #include #define _IOLEN64 (unsigned) #define _IORET64 (int) typedef int socklen_t; #define socket_errno WSAGetLastError() #else #include #include #ifdef HAVE_NET_IP6_H #include #endif #define socket_errno errno # ifndef O_NONBLOCK # define O_NONBLOCK O_NDELAY # endif # ifdef IPPROTO_IP # ifndef SOL_IP # define SOL_IP IPPROTO_IP # endif // !SOL_IP # endif // IPPROTO_IP #endif // !WIN32 #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK (unsigned long)0x7f000001 #endif #ifdef HAVE_NETINET_IN_H #include #endif #if defined(__hpux) #define _XOPEN_SOURCE_EXTENDED #endif #ifdef HAVE_NET_IF_H #include #endif #ifndef _IOLEN64 #define _IOLEN64 #endif #ifndef _IORET64 #define _IORET64 #endif using namespace COMMONCPP_NAMESPACE; #if defined(_MSWINDOWS_) && !defined(__MINGW32__) socket_t Socket::dupSocket(socket_t so, enum Socket::State state) { if (state == Socket::STREAM) return dup((int)so); HANDLE pidHandle = GetCurrentProcess(); HANDLE dupHandle; if(DuplicateHandle(pidHandle, reinterpret_cast(so), pidHandle, &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) return reinterpret_cast(dupHandle); return (socket_t)(-1); } # define DUP_SOCK(s,state) dupSocket(s,state) #else socket_t Socket::dupSocket(socket_t so, State state) { return dup(so); } #endif Mutex Socket::mutex; void Socket::setSocket(void) { flags.thrown = false; flags.broadcast = false; flags.route = true; flags.keepalive = false; flags.loopback = true; flags.multicast = false; flags.linger = false; flags.ttl = 1; errid = errSuccess; errstr = NULL; syserr = 0; state = INITIAL; so = INVALID_SOCKET; } void Socket::endSocket(void) { if(Socket::state == STREAM) { state = INITIAL; if(so != INVALID_SOCKET) { SOCKET sosave = so; so = INVALID_SOCKET; release(sosave); } return; } state = INITIAL; if(so == INVALID_SOCKET) return; #ifdef SO_LINGER struct linger linger; if(flags.linger) { linger.l_onoff = 1; linger.l_linger = 60; } else linger.l_onoff = linger.l_linger = 0; setsockopt(so, SOL_SOCKET, SO_LINGER, (char *)&linger, (socklen_t)sizeof(linger)); #endif // shutdown(so, 2); ucommon::Socket::release(); } Socket::Socket() : ucommon::Socket() { setSocket(); } Socket::Socket(int domain, int type, int protocol) : ucommon::Socket() { setSocket(); so = socket(domain, type, protocol); if(so == INVALID_SOCKET) { error(errCreateFailed,(char *)"Could not create socket",socket_errno); return; } #ifdef SO_NOSIGPIPE int opt = 1; setsockopt(so, SOL_SOCKET, SO_NOSIGPIPE, (char *)&opt, sizeof(opt)); #endif state = AVAILABLE; } Socket::Socket(socket_t fd) : ucommon::Socket() { setSocket(); if (fd == INVALID_SOCKET) { error(errCreateFailed,(char *)"Invalid socket handle passed",0); return; } so = fd; state = AVAILABLE; } Socket::Socket(const Socket &orig) : ucommon::Socket() { setSocket(); so = dupSocket(orig.so,orig.state); if(so == INVALID_SOCKET) error(errCopyFailed,(char *)"Could not duplicate socket handle",socket_errno); state = orig.state; } Socket::~Socket() { endSocket(); } Socket::Error Socket::error(Error err, const char *errs, long systemError) const { errid = err; errstr = errs; syserr = systemError; if(!err) return err; if(flags.thrown) return err; // prevents recursive throws flags.thrown = true; #ifdef CCXX_EXCEPTIONS switch(Thread::getException()) { case Thread::throwObject: THROW((Socket *)this); case Thread::throwException: if(!errs) errs = (char *)""; THROW(SockException(String(errs), err, systemError)); case Thread::throwNothing: break; } #endif return err; } #ifdef _MSWINDOWS_ Socket::Error Socket::connectError(void) { const char* str = "Could not connect to remote host"; switch(WSAGetLastError()) { case WSAENETDOWN: return error(errResourceFailure,str,socket_errno); case WSAEINPROGRESS: return error(errConnectBusy,str,socket_errno); case WSAEADDRNOTAVAIL: return error(errConnectInvalid,str,socket_errno); case WSAECONNREFUSED: return error(errConnectRefused,str,socket_errno); case WSAENETUNREACH: return error(errConnectNoRoute,str,socket_errno); default: return error(errConnectFailed,str,socket_errno); } } #else Socket::Error Socket::connectError(void) { char* str = (char *)"Could not connect to remote host"; switch(errno) { #ifdef EHOSTUNREACH case EHOSTUNREACH: return error(errConnectNoRoute,str,socket_errno); #endif #ifdef ENETUNREACH case ENETUNREACH: return error(errConnectNoRoute,str,socket_errno); #endif case EINPROGRESS: return error(errConnectBusy,str,socket_errno); #ifdef EADDRNOTAVAIL case EADDRNOTAVAIL: return error(errConnectInvalid,str,socket_errno); #endif case ECONNREFUSED: return error(errConnectRefused,str,socket_errno); case ETIMEDOUT: return error(errConnectTimeout,str,socket_errno); default: return error(errConnectFailed,str,socket_errno); } } #endif Socket::Error Socket::sendLimit(int limit) { #ifdef SO_SNDLOWAT if(setsockopt(so, SOL_SOCKET, SO_SNDLOWAT, (char *)&limit, sizeof(limit))) return errInvalidValue; return errSuccess; #else return errServiceUnavailable; #endif } Socket::Error Socket::receiveLimit(int limit) { #ifdef SO_RCVLOWAT if(setsockopt(so, SOL_SOCKET, SO_RCVLOWAT, (char *)&limit, sizeof(limit))) return errInvalidValue; return errSuccess; #else return errServiceUnavailable; #endif } Socket::Error Socket::sendTimeout(timeout_t to) { #ifdef SO_SNDTIMEO struct timeval tv; tv.tv_sec = to / 1000; tv.tv_usec = (to % 1000) * 1000; if(setsockopt(so, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv))) return errInvalidValue; return errSuccess; #else return errServiceUnavailable; #endif } Socket::Error Socket::receiveTimeout(timeout_t to) { #ifdef SO_RCVTIMEO struct timeval tv; tv.tv_sec = to / 1000; tv.tv_usec = (to % 1000) * 1000; if(setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv))) return errInvalidValue; return errSuccess; #else return errServiceUnavailable; #endif } Socket::Error Socket::sendBuffer(unsigned bufsize) { #ifdef SO_SNDBUF if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, (char *)&bufsize, sizeof(bufsize))) return errInvalidValue; return errSuccess; #else return errServiceUnavailable; #endif } Socket::Error Socket::bufferSize(unsigned bufsize) { Error err = receiveBuffer(bufsize); if(err == errSuccess) err = sendBuffer(bufsize); return err; } Socket::Error Socket::receiveBuffer(unsigned bufsize) { #ifdef SO_RCVBUF if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize))) return errInvalidValue; return errSuccess; #else return errServiceUnavailable; #endif } Socket::Error Socket::setBroadcast(bool enable) { int opt = (enable ? 1 : 0); if(setsockopt(so, SOL_SOCKET, SO_BROADCAST, (char *)&opt, (socklen_t)sizeof(opt))) return error(errBroadcastDenied,(char *)"Could not set socket broadcast option",socket_errno); flags.broadcast = enable; return errSuccess; } Socket::Error Socket::setMulticastByFamily(bool enable, Family family) { socklen_t len; switch(family) { #ifdef CCXX_IPV6 case IPV6: struct sockaddr_in6 addr; len = sizeof(addr); if(enable == flags.multicast) return errSuccess; flags.multicast = enable; if(enable) getsockname(so, (struct sockaddr *)&addr, &len); else memset(&addr.sin6_addr, 0, sizeof(addr.sin6_addr)); setsockopt(so, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *)&addr.sin6_addr, sizeof(addr.sin6_addr)); return errSuccess; #endif case IPV4: #ifdef IP_MULTICAST_IF struct sockaddr_in addr4; len = sizeof(addr4); if(enable == flags.multicast) return errSuccess; flags.multicast = enable; if(enable) getsockname(so, (struct sockaddr *)&addr4, &len); else memset(&addr4.sin_addr, 0, sizeof(addr4.sin_addr)); setsockopt(so, IPPROTO_IP, IP_MULTICAST_IF, (char *)&addr4.sin_addr, sizeof(addr4.sin_addr)); return errSuccess; #endif default: return error(errServiceUnavailable,(char *)"Multicast not supported"); } } Socket::Error Socket::setTimeToLiveByFamily(unsigned char ttl, Family fam) { if(!flags.multicast) return error(errMulticastDisabled,(char *)"Multicast not enabled on socket"); switch(fam) { #ifdef CCXX_IPV6 case IPV6: flags.ttl = ttl; setsockopt(so, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *)&ttl, sizeof(ttl)); return errSuccess; #endif case IPV4: #ifdef IP_MULTICAST_TTL flags.ttl = ttl; setsockopt(so, IPPROTO_IP, IP_MULTICAST_TTL, (char *)&ttl, sizeof(ttl)); return errSuccess; #endif default: return error(errServiceUnavailable, (char *)"Multicast not supported"); } } Socket::Error Socket::setLoopbackByFamily(bool enable, Family family) { unsigned char loop; if(!flags.multicast) return error(errMulticastDisabled,(char *)"Multicast not enabled on socket"); if(enable) loop = 1; else loop = 0; flags.loopback = enable; switch(family) { #ifdef CCXX_IPV6 case IPV6: setsockopt(so, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *)&loop, sizeof(loop)); return errSuccess; #endif case IPV4: #ifdef IP_MULTICAST_LOOP setsockopt(so, IPPROTO_IP, IP_MULTICAST_LOOP, (char *)&loop, sizeof(loop)); return errSuccess; #endif default: return error(errServiceUnavailable,(char *)"Multicast not supported"); } } Socket::Error Socket::join(const IPV4Multicast &ia) { #ifdef IP_ADD_MEMBERSHIP struct ip_mreq group; struct sockaddr_in myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled,(char *)"Multicast not enabled on socket"); getsockname(so, (struct sockaddr *)&myaddr, &len); group.imr_interface.s_addr = INADDR_ANY; group.imr_multiaddr = ia.getAddress(); setsockopt(so, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #else return error(errServiceUnavailable,(char *)"Multicast not supported"); #endif } #ifdef CCXX_IPV6 Socket::Error Socket::join(const IPV6Multicast &ia) { #ifdef IPV6_ADD_MEMBERSHIP struct ipv6_mreq group; struct sockaddr_in6 myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled,(char *)"Multicast not enabled on socket"); getsockname(so, (struct sockaddr *)&myaddr, &len); group.ipv6mr_interface = 0; group.ipv6mr_multiaddr = ia.getAddress(); setsockopt(so, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #else return error(errServiceUnavailable,(char *)"Multicast not supported"); #endif } #endif Socket::Error Socket::drop(const IPV4Multicast &ia) { #ifdef IP_DROP_MEMBERSHIP struct ip_mreq group; struct sockaddr_in myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled,(char *)"Multicast not enabled on socket"); getsockname(so, (struct sockaddr *)&myaddr, &len); group.imr_interface.s_addr = INADDR_ANY; group.imr_multiaddr = ia.getAddress(); setsockopt(so, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #else return error(errServiceUnavailable,(char *)"Multicast not supported"); #endif } #ifdef CCXX_IPV6 Socket::Error Socket::drop(const IPV6Multicast &ia) { #ifdef IPV6_DROP_MEMBERSHIP struct ipv6_mreq group; struct sockaddr_in6 myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled,(char *)"Multicast not enabled on socket"); getsockname(so, (struct sockaddr *)&myaddr, &len); group.ipv6mr_interface = 0; group.ipv6mr_multiaddr = ia.getAddress(); setsockopt(so, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #else return error(errServiceUnavailable,(char *)"Multicast not supported"); #endif } #endif Socket::Error Socket::setRouting(bool enable) { int opt = (enable ? 1 : 0); #ifdef SO_DONTROUTE if(setsockopt(so, SOL_SOCKET, SO_DONTROUTE, (char *)&opt, (socklen_t)sizeof(opt))) return error(errRoutingDenied,(char *)"Could not set dont-route socket option",socket_errno); #endif flags.route = enable; return errSuccess; } Socket::Error Socket::setNoDelay(bool enable) { int opt = (enable ? 1 : 0); if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, (char *)&opt, (socklen_t)sizeof(opt))) return error(errNoDelay,(char *)"Could not set tcp-nodelay socket option",socket_errno); return errSuccess; } ssize_t Socket::readLine(char *str, size_t request, timeout_t timeout) { bool crlf = false; bool nl = false; size_t nleft = request - 1; // leave also space for terminator int nstat,c; if(request < 1) return 0; str[0] = 0; while(nleft && !nl) { if(timeout) { if(!isPending(pendingInput, timeout)) { error(errTimeout,(char *)"Read timeout", 0); return -1; } } nstat = ::recv(so, str, _IOLEN64 nleft, MSG_PEEK); if(nstat <= 0) { error(errInput,(char *)"Could not read from socket", socket_errno); return -1; } // FIXME: if unique char in buffer is '\r' return "\r" // if buffer end in \r try to read another char? // and if timeout ?? // remember last \r for(c=0; c < nstat; ++c) { if(str[c] == '\n') { if (c > 0 && str[c-1] == '\r') crlf = true; ++c; nl = true; break; } } nstat = ::recv(so, str, _IOLEN64 c, 0); // TODO: correct ??? if(nstat < 0) break; // adjust ending \r\n in \n if(crlf) { --nstat; str[nstat - 1] = '\n'; } str += nstat; nleft -= nstat; } *str = 0; return (ssize_t)(request - nleft - 1); } ssize_t Socket::readData(void *Target, size_t Size, char Separator, timeout_t timeout) { if ((Separator == 0x0D) || (Separator == 0x0A)) return (readLine ((char *) Target, Size, timeout)); if (Size < 1) return (0); ssize_t nstat; if (Separator == 0) { // Flat-out read for a number of bytes. if (timeout) { if (!isPending (pendingInput, timeout)) { error(errTimeout); return (-1); } } nstat =::recv (so, (char *)Target, _IOLEN64 Size, 0); if (nstat < 0) { error (errInput); return (-1); } return (nstat); } ///////////////////////////////////////////////////////////// // Otherwise, we have a special char separator to use ///////////////////////////////////////////////////////////// bool found = false; size_t nleft = Size; int c; char *str = (char *) Target; memset (str, 0, Size); while (nleft && !found) { if (timeout) { if (!isPending (pendingInput, timeout)) { error(errTimeout); return (-1); } } nstat =::recv (so, str, _IOLEN64 nleft, MSG_PEEK); if (nstat <= 0) { error (errInput); return (-1); } for (c = 0; (c < nstat) && !found; ++c) { if (str[c] == Separator) found = true; } memset (str, 0, nleft); nstat =::recv (so, str, c, 0); if (nstat < 0) break; str += nstat; nleft -= nstat; } return (ssize_t)(Size - (ssize_t) nleft); } ssize_t Socket::writeData(const void *Source, size_t Size, timeout_t timeout) { if (Size < 1) return (0); ssize_t nstat; const char *Slide = (const char *) Source; while (true) { if (timeout) { if (!isPending (pendingOutput, timeout)) { error(errOutput); return (-1); } } nstat =::send (so, Slide, _IOLEN64 Size, MSG_NOSIGNAL); if (nstat <= 0) { error(errOutput); return (-1); } Size -= nstat; Slide += nstat; if (Size <= 0) break; } return (nstat); } const char *Socket::getSystemErrorString(void) const { #ifdef CCXX_EXCEPTIONS SockException e(errstr, errid, syserr); return e.getSystemErrorString(); #else return NULL; #endif } bool Socket::isPending(Pending pending, timeout_t timeout) { int status = 0; #ifdef USE_POLL struct pollfd pfd; pfd.fd = so; pfd.revents = 0; if(so == INVALID_SOCKET) return true; switch(pending) { case pendingInput: pfd.events = POLLIN; break; case pendingOutput: pfd.events = POLLOUT; break; case pendingError: pfd.events = POLLERR | POLLHUP; break; } status = 0; while(status < 1) { if(timeout == TIMEOUT_INF) status = poll(&pfd, 1, -1); else status = poll(&pfd, 1, timeout); if(status < 1) { // don't stop polling because of a simple // signal :) if(status == -1 && errno == EINTR) continue; return false; } } if(pfd.revents & pfd.events) return true; return false; #else struct timeval tv; struct timeval *tvp = &tv; fd_set grp; if(timeout == TIMEOUT_INF) tvp = NULL; else { tv.tv_usec = (timeout % 1000) * 1000; tv.tv_sec = timeout / 1000; } FD_ZERO(&grp); SOCKET sosave = so; if(so == INVALID_SOCKET) return true; FD_SET(sosave, &grp); switch(pending) { case pendingInput: status = ::select((int)so + 1, &grp, NULL, NULL, tvp); break; case pendingOutput: status = ::select((int)so + 1, NULL, &grp, NULL, tvp); break; case pendingError: status = ::select((int)so + 1, NULL, NULL, &grp, tvp); break; } if(status < 1) return false; if(FD_ISSET(so, &grp)) return true; return false; #endif } bool Socket::operator!() const { return (Socket::state == INITIAL) ? true : false; } Socket::operator bool() const { return (Socket::state == INITIAL) ? false : true; } Socket &Socket::operator=(const Socket &from) { if(so == from.so) return *this; if(state != INITIAL) endSocket(); so = dupSocket(from.so,from.state); if(so == INVALID_SOCKET) { error(errCopyFailed,(char *)"Could not duplicate socket handle",socket_errno); state = INITIAL; } else state = from.state; return *this; } bool Socket::check(Family fam) { SOCKET so = INVALID_SOCKET; switch(fam) { case IPV4: so = socket(fam, SOCK_DGRAM, IPPROTO_UDP); break; #ifdef CCXX_IPV6 case IPV6: so = socket(fam, SOCK_DGRAM, IPPROTO_UDP); break; #endif default: return false; } if(so == INVALID_SOCKET) return false; release(so); return true; } IPV4Host Socket::getIPV4Sender(tpport_t *port) const { struct sockaddr_in from; char buf; socklen_t len = sizeof(from); int rc = ::recvfrom(so, &buf, 1, MSG_PEEK, (struct sockaddr *)&from, &len); #ifdef _MSWINDOWS_ if(rc < 1 && WSAGetLastError() != WSAEMSGSIZE) { if(port) *port = 0; memset((void*) &from, 0, sizeof(from)); error(errInput,(char *)"Could not read from socket",socket_errno); } #else if(rc < 0) { if(port) *port = 0; memset((void*) &from, 0, sizeof(from)); error(errInput,(char *)"Could not read from socket",socket_errno); } #endif else { if(rc < 1) memset((void*) &from, 0, sizeof(from)); if(port) *port = ntohs(from.sin_port); } return IPV4Host(from.sin_addr); } #ifdef CCXX_IPV6 IPV6Host Socket::getIPV6Sender(tpport_t *port) const { struct sockaddr_in6 from; char buf; socklen_t len = sizeof(from); int rc = ::recvfrom(so, &buf, 1, MSG_PEEK, (struct sockaddr *)&from, &len); #ifdef _MSWINDOWS_ if(rc < 1 && WSAGetLastError() != WSAEMSGSIZE) { if(port) *port = 0; memset((void*) &from, 0, sizeof(from)); error(errInput,(char *)"Could not read from socket",socket_errno); } #else if(rc < 0) { if(port) *port = 0; memset((void*) &from, 0, sizeof(from)); error(errInput,(char *)"Could not read from socket",socket_errno); } #endif else { if(rc < 1) memset((void*) &from, 0, sizeof(from)); if(port) *port = ntohs(from.sin6_port); } return IPV6Host(from.sin6_addr); } #endif IPV4Host Socket::getIPV4Local(tpport_t *port) const { struct sockaddr_in addr; socklen_t len = sizeof(addr); if(getsockname(so, (struct sockaddr *)&addr, &len)) { error(errResourceFailure,(char *)"Could not get socket address",socket_errno); if(port) *port = 0; memset(&addr.sin_addr, 0, sizeof(addr.sin_addr)); } else { if(port) *port = ntohs(addr.sin_port); } return IPV4Host(addr.sin_addr); } #ifdef CCXX_IPV6 IPV6Host Socket::getIPV6Local(tpport_t *port) const { struct sockaddr_in6 addr; socklen_t len = sizeof(addr); if(getsockname(so, (struct sockaddr *)&addr, &len)) { error(errResourceFailure,(char *)"Could not get socket address",socket_errno); if(port) *port = 0; memset(&addr.sin6_addr, 0, sizeof(addr.sin6_addr)); } else { if(port) *port = ntohs(addr.sin6_port); } return IPV6Host(addr.sin6_addr); } #endif IPV4Host Socket::getIPV4Peer(tpport_t *port) const { struct sockaddr_in addr; socklen_t len = sizeof(addr); if(getpeername(so, (struct sockaddr *)&addr, &len)) { #ifndef _MSWINDOWS_ if(errno == ENOTCONN) error(errNotConnected,(char *)"Could not get peer address",socket_errno); else #endif error(errResourceFailure,(char *)"Could not get peer address",socket_errno); if(port) *port = 0; memset(&addr.sin_addr, 0, sizeof(addr.sin_addr)); } else { if(port) *port = ntohs(addr.sin_port); } return IPV4Host(addr.sin_addr); } #ifdef CCXX_IPV6 IPV6Host Socket::getIPV6Peer(tpport_t *port) const { struct sockaddr_in6 addr; socklen_t len = sizeof(addr); if(getpeername(so, (struct sockaddr *)&addr, &len)) { #ifndef _MSWINDOWS_ if(errno == ENOTCONN) error(errNotConnected,(char *)"Could not get peer address",socket_errno); else #endif error(errResourceFailure,(char *)"Could not get peer address",socket_errno); if(port) *port = 0; memset(&addr.sin6_addr, 0, sizeof(addr.sin6_addr)); } else { if(port) *port = ntohs(addr.sin6_port); } return IPV6Host(addr.sin6_addr); } #endif void Socket::setCompletion(bool immediate) { flags.completion = immediate; #ifdef _MSWINDOWS_ unsigned long flag; // note that this will not work on some versions of Windows for Workgroups. Tough. -- jfc switch( immediate ) { case false: // this will not work if you are using WSAAsyncSelect or WSAEventSelect. // -- perhaps I should throw an exception flag = 1; // ioctlsocket( so, FIONBIO, (unsigned long *) 1); break; case true: flag = 0; // ioctlsocket( so, FIONBIO, (unsigned long *) 0); break; } ioctlsocket(so, FIONBIO, &flag); #else int fflags = fcntl(so, F_GETFL); if(immediate) { fflags &=~ O_NONBLOCK; fcntl(so, F_SETFL, fflags); } else { fflags |= O_NONBLOCK; fcntl(so, F_SETFL, fflags); } #endif } Socket::Error Socket::setKeepAlive(bool enable) { int opt = (enable ? ~0: 0); #if (defined(SO_KEEPALIVE) || defined(_MSWINDOWS_)) if(setsockopt(so, SOL_SOCKET, SO_KEEPALIVE, (char *)&opt, (socklen_t)sizeof(opt))) return error(errKeepaliveDenied,(char *)"Could not set socket keep-alive option",socket_errno); #endif flags.keepalive = enable; return errSuccess; } Socket::Error Socket::setLinger(bool linger) { #ifdef SO_LINGER flags.linger = linger; return errSuccess; #else return error(errServiceUnavailable,(char *)"Socket lingering not supported"); #endif } Socket::Error Socket::setTypeOfService(Tos service) { #ifdef SOL_IP unsigned char tos; switch(service) { #ifdef IPTOS_LOWDELAY case tosLowDelay: tos = IPTOS_LOWDELAY; break; #endif #ifdef IPTOS_THROUGHPUT case tosThroughput: tos = IPTOS_THROUGHPUT; break; #endif #ifdef IPTOS_RELIABILITY case tosReliability: tos = IPTOS_RELIABILITY; break; #endif #ifdef IPTOS_MINCOST case tosMinCost: tos = IPTOS_MINCOST; break; #endif default: return error(errServiceUnavailable,(char *)"Unknown type-of-service"); } if(setsockopt(so, SOL_IP, IP_TOS,(char *)&tos, (socklen_t)sizeof(tos))) return error(errServiceDenied,(char *)"Could not set type-of-service",socket_errno); return errSuccess; #else return error(errServiceUnavailable,(char *)"Socket type-of-service not supported",socket_errno); #endif } bool Socket::isConnected(void) const { return (Socket::state == CONNECTED) ? true : false; } bool Socket::isActive(void) const { return (state != INITIAL) ? true : false; } ucommon-6.0.7/commoncpp/thread.cpp0000644000175000017500000004574312163025062014102 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #ifdef _MSWINDOWS_ #define MAX_SEM_VALUE 1000000 #endif using namespace COMMONCPP_NAMESPACE; #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) extern int _posix_clocking; #endif static class __EXPORT MainThread : public Thread { private: void run(void); public: MainThread(); ~MainThread(); } _mainthread; extern "C" { #ifdef _MSWINDOWS_ static unsigned __stdcall exec_thread(void *obj) { assert(obj != NULL); ucommon::Thread *th = static_cast(obj); Thread *cth = static_cast(obj); th->setPriority(); cth->map(); cth->initial(); cth->run(); cth->finalize(); cth->exit(); return 0; } #else static void *exec_thread(void *obj) { assert(obj != NULL); ucommon::Thread *th = static_cast(obj); Thread *cth = static_cast(obj); th->setPriority(); cth->map(); cth->initial(); cth->run(); cth->finalize(); cth->exit(); return NULL; } #endif } MainThread::MainThread() : Thread() { ucommon::Thread::init(); ucommon::Socket::init(); map(); } MainThread::~MainThread() { } void MainThread::run(void) { } Thread::Thread(int pri, size_t stack) : ucommon::JoinableThread(stack) { priority = pri; detached = false; terminated = false; msgpos = 0; if(this == &_mainthread) { parent = this; exceptions = throwObject; } else { parent = Thread::get(); if(!parent) parent = &_mainthread; exceptions = parent->exceptions; } } Thread::~Thread() { if(!detached) join(); finalize(); } bool Thread::isRunning(void) { return !detached && running && !terminated; } void Thread::finalize(void) { if(terminated) return; terminated = true; if(parent) parent->notify(this); final(); } bool Thread::isThread(void) { pthread_t self = pthread_self(); if(equal(tid, self)) return true; return false; } void Thread::terminate(void) { pthread_t self = pthread_self(); if(detached && equal(tid, self)) ucommon::Thread::exit(); else if(!detached) join(); } void Thread::exit(void) { pthread_t self = pthread_self(); if(detached && equal(tid, self)) { delete this; ucommon::Thread::exit(); } terminate(); } void Thread::initial(void) { } void Thread::final(void) { } void Thread::notify(Thread *thread) { } #ifdef _MSWINDOWS_ void Thread::start(void) { if(running != INVALID_HANDLE_VALUE) return; if(stack == 1) stack = 1024; running = (HANDLE)_beginthreadex(NULL, stack, &exec_thread, this, 0, (unsigned int *)&tid); if(!running) running = INVALID_HANDLE_VALUE; else terminated = false; } void Thread::detach(void) { HANDLE hThread;; if(stack == 1) stack = 1024; hThread = (HANDLE)_beginthreadex(NULL, stack, &exec_thread, this, 0, (unsigned int *)&tid); CloseHandle(hThread); } #else void Thread::start(void) { int result; if(running) return; #ifndef __PTH__ pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED); #endif // we typically use "stack 1" for min stack... #ifdef PTHREAD_STACK_MIN if(stack && stack < PTHREAD_STACK_MIN) stack = PTHREAD_STACK_MIN; #else if(stack && stack < 2) stack = 0; #endif #ifdef __PTH__ pth_attr_t attr = PTH_ATTR_DEFAULT; pth_attr_set(attr, PTH_ATTR_JOINABLE); tid = pth_spawn(attr, &exec_thread, this); #else if(stack) pthread_attr_setstacksize(&attr, stack); result = pthread_create(&tid, &attr, &exec_thread, this); pthread_attr_destroy(&attr); if(!result) { terminated = false; running = true; } #endif } void Thread::detach(void) { #ifndef __PTH__ pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED); #endif // we typically use "stack 1" for min stack... #ifdef PTHREAD_STACK_MIN if(stack && stack < PTHREAD_STACK_MIN) stack = PTHREAD_STACK_MIN; #else if(stack && stack < 2) stack = 0; #endif #ifdef __PTH__ tid = pth_spawn(PTH_ATTR_DEFAULT, &exec_thread, this); #else if(stack) pthread_attr_setstacksize(&attr, stack); pthread_create(&tid, &attr, &exec_thread, this); pthread_attr_destroy(&attr); #endif } #endif Thread::Throw Thread::getException(void) { Thread *th = Thread::get(); if(!th) return throwNothing; return th->exceptions; } void Thread::setException(Thread::Throw _throw) { Thread *th = Thread::get(); if(th) th->exceptions = _throw; } void Conditional::signal(bool broadcast) { if(broadcast) ucommon::Conditional::broadcast(); else ucommon::Conditional::signal(); } bool Conditional::wait(timeout_t timeout, bool locked) { bool result; if(!locked) ucommon::Conditional::lock(); result = ucommon::Conditional::wait(timeout); if(!locked) ucommon::Conditional::unlock(); return result; } static pthread_mutex_t mlock; time_t SysTime::getTime(time_t *tloc) { time_t ret; pthread_mutex_lock(&mlock); time_t temp; ::time(&temp); memcpy(&ret, &temp, sizeof(time_t)); if (tloc != NULL) memcpy(tloc, &ret, sizeof(time_t)); pthread_mutex_unlock(&mlock); return ret; } int SysTime::getTimeOfDay(struct timeval *tp) { struct timeval temp; int ret(0); pthread_mutex_lock(&mlock); #ifdef _MSWINDOWS_ // We could use _ftime(), but it is not available on WinCE. // (WinCE also lacks time.h) // Note also that the average error of _ftime is around 20 ms :) time_t now; time(&now); temp.tv_sec = (long)now; temp.tv_usec = (GetTickCount() % 1000) * 1000; memcpy(tp, &temp, sizeof(struct timeval)); #else ret = ::gettimeofday(&temp, NULL); if(ret == 0) memcpy(tp, &temp, sizeof(struct timeval)); #endif pthread_mutex_unlock(&mlock); return ret; } struct tm *SysTime::getLocalTime(const time_t *clock, struct tm* result) { pthread_mutex_lock(&mlock); struct tm *temp = ::localtime(clock); memcpy(result, temp, sizeof(struct tm)); pthread_mutex_unlock(&mlock); return result; } struct tm *SysTime::getGMTTime(const time_t *clock, struct tm* result) { pthread_mutex_lock(&mlock); struct tm *temp = ::gmtime(clock); memcpy(result, temp, sizeof(struct tm)); pthread_mutex_unlock(&mlock); return result; } #ifndef _MSWINDOWS_ #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) TimerPort::TimerPort() { struct timespec ts; active = false; ::clock_gettime(_posix_clocking, &ts); timer.tv_sec = ts.tv_sec; timer.tv_usec = ts.tv_nsec / 1000; } #else TimerPort::TimerPort() { active = false; SysTime::getTimeOfDay(&timer); } #endif void TimerPort::setTimer(timeout_t timeout) { #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) struct timespec ts; ::clock_gettime(_posix_clocking, &ts); timer.tv_sec = ts.tv_sec; timer.tv_usec = ts.tv_nsec / 1000l; #else SysTime::getTimeOfDay(&timer); #endif active = false; if(timeout) incTimer(timeout); } void TimerPort::incTimer(timeout_t timeout) { int secs = timeout / 1000; int usecs = (timeout % 1000) * 1000; timer.tv_usec += usecs; if(timer.tv_usec >= 1000000l) { ++timer.tv_sec; timer.tv_usec %= 1000000l; } timer.tv_sec += secs; active = true; } void TimerPort::decTimer(timeout_t timeout) { int secs = timeout / 1000; int usecs = (timeout % 1000) * 1000; if(timer.tv_usec < usecs) { --timer.tv_sec; timer.tv_usec = 1000000l + timer.tv_usec - usecs; } else timer.tv_usec -= usecs; timer.tv_sec -= secs; active = true; } #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) void TimerPort::sleepTimer(void) { struct timespec ts; ts.tv_sec = timer.tv_sec; ts.tv_nsec = timer.tv_usec * 1000l; ::clock_nanosleep(_posix_clocking, TIMER_ABSTIME, &ts, NULL); } #else void TimerPort::sleepTimer(void) { timeout_t remaining = getTimer(); if(remaining && remaining != TIMEOUT_INF) Thread::sleep(remaining); } #endif void TimerPort::endTimer(void) { active = false; } timeout_t TimerPort::getTimer(void) const { #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) struct timespec now; #else struct timeval now; #endif long diff; if(!active) return TIMEOUT_INF; #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) ::clock_gettime(_posix_clocking, &now); diff = (timer.tv_sec - now.tv_sec) * 1000l; diff += (timer.tv_usec - (now.tv_nsec / 1000)) / 1000l; #else SysTime::getTimeOfDay(&now); diff = (timer.tv_sec - now.tv_sec) * 1000l; diff += (timer.tv_usec - now.tv_usec) / 1000l; #endif if(diff < 0) return 0l; return diff; } timeout_t TimerPort::getElapsed(void) const { #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) struct timespec now; #else struct timeval now; #endif long diff; if(!active) return TIMEOUT_INF; #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) ::clock_gettime(_posix_clocking, &now); diff = (now.tv_sec - timer.tv_sec) * 1000l; diff += ((now.tv_nsec / 1000l) - timer.tv_usec) / 1000l; #else SysTime::getTimeOfDay(&now); diff = (now.tv_sec -timer.tv_sec) * 1000l; diff += (now.tv_usec - timer.tv_usec) / 1000l; #endif if(diff < 0) return 0; return diff; } #else // WIN32 TimerPort::TimerPort() { active = false; timer = GetTickCount(); } void TimerPort::setTimer(timeout_t timeout) { timer = GetTickCount(); active = false; if(timeout) incTimer(timeout); } void TimerPort::incTimer(timeout_t timeout) { timer += timeout; active = true; } void TimerPort::decTimer(timeout_t timeout) { timer -= timeout; active = true; } void TimerPort::sleepTimer(void) { timeout_t remaining = getTimer(); if(remaining && remaining != TIMEOUT_INF) Thread::sleep(remaining); } void TimerPort::endTimer(void) { active = false; } timeout_t TimerPort::getTimer(void) const { DWORD now; long diff; if(!active) return TIMEOUT_INF; now = GetTickCount(); diff = timer - now; if(diff < 0) return 0l; return diff; } timeout_t TimerPort::getElapsed(void) const { DWORD now; long diff; if(!active) return TIMEOUT_INF; now = GetTickCount(); diff = now - timer; if(diff < 0) return 0l; return diff; } #endif MutexCounter::MutexCounter() : Mutex() { counter = 0; } MutexCounter::MutexCounter(int initial) : Mutex() { counter = initial; } int MutexCounter::operator++() { int rtn; enterMutex(); rtn = counter++; leaveMutex(); return rtn; } // ??? why cannot be < 0 ??? int MutexCounter::operator--() { int rtn = 0; enterMutex(); if(counter) { rtn = --counter; if(!rtn) { leaveMutex(); THROW(mc); } } leaveMutex(); return rtn; } #ifndef _MSWINDOWS_ timespec *getTimeout(struct timespec *spec, timeout_t timer) { static struct timespec myspec; if(spec == NULL) spec = &myspec; #ifdef PTHREAD_GET_EXPIRATION_NP struct timespec offset; offset.tv_sec = timer / 1000; offset.tv_nsec = (timer % 1000) * 1000000; pthread_get_expiration_np(&offset, spec); #else struct timeval current; SysTime::getTimeOfDay(¤t); spec->tv_sec = current.tv_sec + ((timer + current.tv_usec / 1000) / 1000); spec->tv_nsec = ((current.tv_usec / 1000 + timer) % 1000) * 1000000; #endif return spec; } #endif const size_t Buffer::timeout = ((size_t)(-1l)); #ifdef _MSWINDOWS_ Buffer::Buffer(size_t capacity) : Mutex() #else Buffer::Buffer(size_t capacity) : Conditional() #endif { #ifdef _MSWINDOWS_ sem_head = ::CreateSemaphore((LPSECURITY_ATTRIBUTES)NULL, 0, MAX_SEM_VALUE, (LPCTSTR)NULL); sem_tail = ::CreateSemaphore((LPSECURITY_ATTRIBUTES)NULL, (LONG)capacity, MAX_SEM_VALUE, (LPCTSTR)NULL); #endif _size = capacity; _used = 0; } Buffer::~Buffer() { #ifdef _MSWINDOWS_ ::CloseHandle(sem_head); ::CloseHandle(sem_tail); #endif } #ifdef _MSWINDOWS_ size_t Buffer::wait(void *buf, timeout_t timeout) { size_t rc; if(!timeout) timeout = INFINITE; if(WaitForSingleObject(sem_head, timeout) != WAIT_OBJECT_0) return Buffer::timeout; enterMutex(); rc = onWait(buf); --_used; leaveMutex(); ::ReleaseSemaphore(sem_tail, 1, (LPLONG)NULL); return rc; } size_t Buffer::post(void *buf, timeout_t timeout) { size_t rc; if(!timeout) timeout = INFINITE; if(WaitForSingleObject(sem_tail, timeout) != WAIT_OBJECT_0) return Buffer::timeout; enterMutex(); rc = onPost(buf); ++_used; leaveMutex(); ::ReleaseSemaphore(sem_head, 1, (LPLONG)NULL); return rc; } #else size_t Buffer::wait(void *buf, timeout_t timeout) { size_t rc = 0; enterMutex(); while(!_used) { if(!Conditional::wait(timeout, true)) { leaveMutex(); return Buffer::timeout; } } rc = (ssize_t)onWait(buf); --_used; Conditional::signal(false); leaveMutex(); return rc; } size_t Buffer::post(void *buf, timeout_t timeout) { size_t rc = 0; enterMutex(); while(_used == _size) { if(!Conditional::wait(timeout, true)) { leaveMutex(); return Buffer::timeout; } } rc = (ssize_t)onPost(buf); ++_used; Conditional::signal(false); leaveMutex(); return rc; } size_t Buffer::peek(void *buf) { size_t rc; enterMutex(); if(!_used) { leaveMutex(); return 0; } rc = onPeek(buf); leaveMutex(); return rc; } #endif bool Buffer::isValid(void) { return true; } FixedBuffer::FixedBuffer(size_t capacity, size_t osize) : Buffer(capacity) { objsize = osize; buf = new char[capacity * objsize]; #ifdef CCXX_EXCEPTIONS if(!buf && Thread::getException() == Thread::throwObject) throw(this); else if(!buf && Thread::getException() == Thread::throwException) throw(SyncException("fixed buffer failure")); #endif head = tail = buf; } FixedBuffer::~FixedBuffer() { if(buf) delete[] buf; } bool FixedBuffer::isValid(void) { if(head && tail) return true; return false; } #define MAXBUF (buf + (getSize() * objsize)) size_t FixedBuffer::onWait(void *data) { memcpy(data, head, objsize); if((head += objsize) >= MAXBUF) head = buf; return objsize; } size_t FixedBuffer::onPost(void *data) { memcpy(tail, data, objsize); if((tail += objsize) >= MAXBUF) tail = buf; return objsize; } size_t FixedBuffer::onPeek(void *data) { memcpy(data, head, objsize); return objsize; } ThreadQueue::ThreadQueue(const char *id, int pri, size_t stack) : Mutex(), Thread(pri, stack), Semaphore(0), name(id) { first = last = NULL; started = false; timeout = 0; } ThreadQueue::~ThreadQueue() { data_t *data, *next; if(started) { started = false; } data = first; while(data) { next = data->next; delete[] data; data = next; } } void ThreadQueue::run(void) { bool posted; data_t *prev; started = true; for(;;) { posted = Semaphore::wait(timeout); if(!posted) { onTimer(); if(!first) continue; } if(!started) sleep((timeout_t)~0); startQueue(); while(first) { runQueue(first->data); enterMutex(); prev = first; first = first->next; delete[] prev; if(!first) last = NULL; leaveMutex(); if(first) Semaphore::wait(); // demark semaphore } stopQueue(); } } void ThreadQueue::final() { } void ThreadQueue::onTimer(void) { } void ThreadQueue::setTimer(timeout_t timed) { enterMutex(); timeout = timed; leaveMutex(); if(!started) { start(); started = true; } else if(!first) Semaphore::post(); } void ThreadQueue::post(const void *dp, unsigned len) { data_t *data = (data_t *)new char[sizeof(data_t) + len]; memcpy(data->data, dp, len); data->len = len; data->next = NULL; enterMutex(); if(!first) first = data; if(last) last->next = data; last = data; if(!started) { start(); started = true; } leaveMutex(); Semaphore::post(); } void ThreadQueue::startQueue(void) { } void ThreadQueue::stopQueue(void) { } ucommon-6.0.7/commoncpp/udp.cpp0000644000175000017500000005554412163025062013423 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #ifdef _MSWINDOWS_ #include #define _IOLEN64 (unsigned) #define _IORET64 (int) typedef int socklen_t; #define socket_errno WSAGetLastError() #else #include #include #ifdef HAVE_NET_IP6_H #include #endif #define socket_errno errno # ifndef O_NONBLOCK # define O_NONBLOCK O_NDELAY # endif # ifdef IPPROTO_IP # ifndef SOL_IP # define SOL_IP IPPROTO_IP # endif // !SOL_IP # endif // IPPROTO_IP #endif // !WIN32 #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK (unsigned long)0x7f000001 #endif #ifdef HAVE_NETINET_IN_H #include #endif #if defined(__hpux) #define _XOPEN_SOURCE_EXTENDED #endif #ifdef HAVE_NET_IF_H #include #endif #ifndef _IOLEN64 #define _IOLEN64 #endif #ifndef _IORET64 #define _IORET64 #endif using namespace COMMONCPP_NAMESPACE; #ifdef HAVE_GETADDRINFO UDPSocket::UDPSocket(const char *name, Family fam) : Socket(fam, SOCK_DGRAM, IPPROTO_UDP) { char namebuf[128], *cp; struct addrinfo hint, *list = NULL, *first; family = fam; switch(fam) { #ifdef CCXX_IPV6 case IPV6: peer.ipv6.sin6_family = family; break; #endif case IPV4: peer.ipv4.sin_family = family; } snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp && family == IPV4) cp = strrchr(namebuf, ':'); if(!cp) { cp = namebuf; name = NULL; } else { name = namebuf; *(cp++) = 0; if(!strcmp(name, "*")) name = NULL; } memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = SOCK_DGRAM; hint.ai_protocol = IPPROTO_UDP; hint.ai_flags = AI_PASSIVE; if(getaddrinfo(name, cp, &hint, &list) || !list) { error(errBindingFailed, (char *)"Could not find service", errno); endSocket(); return; } #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif first = list; while(list) { if(!bind(so, list->ai_addr, (socklen_t)list->ai_addrlen)) { state = BOUND; break; } list = list->ai_next; } freeaddrinfo(first); if(state != BOUND) { endSocket(); error(errBindingFailed, (char *)"Count not bind socket", errno); return; } } #else UDPSocket::UDPSocket(const char *name, Family fam) : Socket(fam, SOCK_DGRAM, IPPROTO_UDP) { char namebuf[128], *cp; tpport_t port = 0; struct servent *svc = NULL; socklen_t alen = 0; struct sockaddr *addr = NULL; family = fam; snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp && family == IPV4) cp = strrchr(namebuf, ':'); if(!cp) { cp = namebuf; name = "*"; } else { name = namebuf; *(cp++) = 0; } if(isdigit(*cp)) port = atoi(cp); else { mutex.enter(); svc = getservbyname(cp, "udp"); if(svc) port = ntohs(svc->s_port); mutex.leave(); if(!svc) { error(errBindingFailed, (char *)"Could not find service", errno); endSocket(); return; } } struct sockaddr_in addr4; IPV4Address ia4(name); #ifdef CCXX_IPV6 struct sockaddr_in6 addr6; IPV6Address ia6(name); #endif switch(family) { #ifdef CCXX_IPV6 case IPV6: peer.ipv6.sin6_family = family; memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = family; addr6.sin6_addr = ia6.getAddress(); addr6.sin6_port = htons(port); alen = sizeof(addr6); addr = (struct sockaddr *)&addr6; break; #endif case IPV4: peer.ipv4.sin_family = family; memset(&addr4, 0, sizeof(addr4)); addr4.sin_family = family; addr4.sin_addr = ia4.getAddress(); addr4.sin_port = htons(port); alen = sizeof(&addr4); addr = (struct sockaddr *)&addr4; } #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(addr && !bind(so, addr, alen)) state = BOUND; if(state != BOUND) { endSocket(); error(errBindingFailed, (char *)"Count not bind socket", errno); return; } } #endif UDPSocket::UDPSocket(Family fam) : Socket(fam, SOCK_DGRAM, IPPROTO_UDP) { family = fam; memset(&peer, 0, sizeof(peer)); switch(fam) { #ifdef CCXX_IPV6 case IPV6: peer.ipv6.sin6_family = family; break; #endif case IPV4: peer.ipv4.sin_family = family; } } UDPSocket::UDPSocket(const IPV4Address &ia, tpport_t port) : Socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) { family = IPV4; memset(&peer.ipv4, 0, sizeof(peer)); peer.ipv4.sin_family = AF_INET; peer.ipv4.sin_addr = ia.getAddress(); peer.ipv4.sin_port = htons(port); #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&peer.ipv4, sizeof(peer.ipv4))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } state = BOUND; } #ifdef CCXX_IPV6 UDPSocket::UDPSocket(const IPV6Address &ia, tpport_t port) : Socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP) { family = IPV6; memset(&peer.ipv6, 0, sizeof(peer)); peer.ipv6.sin6_family = AF_INET6; peer.ipv6.sin6_addr = ia.getAddress(); peer.ipv6.sin6_port = htons(port); #if defined(SO_REUSEADDR) int opt = 1; setsockopt(so, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, (socklen_t)sizeof(opt)); #endif if(bind(so, (struct sockaddr *)&peer.ipv6, sizeof(peer.ipv6))) { endSocket(); error(errBindingFailed,(char *)"Could not bind socket",socket_errno); return; } state = BOUND; } #endif UDPSocket::~UDPSocket() { endSocket(); } ssize_t UDPSocket::send(const void *buf, size_t len) { struct sockaddr *addr = NULL; socklen_t alen = 0; switch(family) { #ifdef CCXX_IPV6 case IPV6: addr = (struct sockaddr *)&peer.ipv6; alen = sizeof(struct sockaddr_in6); break; #endif case IPV4: addr = (struct sockaddr *)&peer.ipv4; alen = sizeof(struct sockaddr_in); break; default: return -1; } if(isConnected()) { addr = NULL; alen = 0; } return _IORET64 ::sendto(so, (const char *)buf, _IOLEN64 len, MSG_NOSIGNAL, addr, alen); } ssize_t UDPSocket::receive(void *buf, size_t len, bool reply) { struct sockaddr *addr = NULL; struct sockaddr_in senderAddress; // DMC 2/7/05 ADD for use below. socklen_t alen = 0; switch(family) { #ifdef CCXX_IPV6 case IPV6: addr = (struct sockaddr *)&peer.ipv6; alen = sizeof(struct sockaddr_in6); break; #endif case IPV4: addr = (struct sockaddr *)&peer.ipv4; alen = sizeof(struct sockaddr_in); break; default: return -1; } if(isConnected() || !reply) { // DMC 2/7/05 MOD to use senderAddress instead of NULL, to prevent 10014 error // from recvfrom. //addr = NULL; //alen = 0; addr = (struct sockaddr*)(&senderAddress); alen = sizeof(struct sockaddr_in); } int bytes = ::recvfrom(so, (char *)buf, _IOLEN64 len, 0, addr, &alen); #ifdef _MSWINDOWS_ if (bytes == SOCKET_ERROR) { WSAGetLastError(); } #endif return _IORET64 bytes; } Socket::Error UDPSocket::join(const IPV4Multicast &ia,int InterfaceIndex) { #if defined(_MSWINDOWS_) && defined(IP_ADD_MEMBERSHIP) // DMC 2/7/05: Added WIN32 block. Win32 does not define the ip_mreqn structure, // so we must use ip_mreq with INADDR_ANY. struct ip_mreq group; struct sockaddr_in myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled); memset(&group, 0, sizeof(group)); getsockname(so, (struct sockaddr *)&myaddr, &len); group.imr_multiaddr.s_addr = ia.getAddress().s_addr; group.imr_interface.s_addr = INADDR_ANY; setsockopt(so, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #elif defined(IP_ADD_MEMBERSHIP) && defined(SIOCGIFINDEX) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(_OSF_SOURCE) && !defined(__hpux) && !defined(__GNU__) struct ip_mreqn group; struct sockaddr_in myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled); getsockname(so, (struct sockaddr *)&myaddr, &len); memset(&group, 0, sizeof(group)); memcpy(&group.imr_address, &myaddr.sin_addr, sizeof(myaddr.sin_addr)); group.imr_multiaddr = ia.getAddress(); group.imr_ifindex = InterfaceIndex; setsockopt(so, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #elif defined(IP_ADD_MEMBERSHIP) // if no by index, use INADDR_ANY struct ip_mreq group; struct sockaddr_in myaddr; socklen_t len = sizeof(myaddr); if(!flags.multicast) return error(errMulticastDisabled); getsockname(so, (struct sockaddr *)&myaddr, &len); memset(&group, sizeof(group), 0); group.imr_multiaddr.s_addr = ia.getAddress().s_addr; group.imr_interface.s_addr = INADDR_ANY; setsockopt(so, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group, sizeof(group)); return errSuccess; #else return error(errServiceUnavailable); #endif } Socket::Error UDPSocket::getInterfaceIndex(const char *DeviceName,int& InterfaceIndex) { #ifndef _MSWINDOWS_ #if defined(IP_ADD_MEMBERSHIP) && defined(SIOCGIFINDEX) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(_OSF_SOURCE) && !defined(__hpux) && !defined(__GNU__) struct ip_mreqn mreqn; struct ifreq m_ifreq; int i; sockaddr_in* in4 = (sockaddr_in*) &peer.ipv4; InterfaceIndex = -1; memset(&mreqn, 0, sizeof(mreqn)); memcpy(&mreqn.imr_multiaddr.s_addr, &in4->sin_addr, sizeof(mreqn.imr_multiaddr.s_addr)); for (i = 0; i < IFNAMSIZ && DeviceName[i]; ++i) m_ifreq.ifr_name[i] = DeviceName[i]; for (; i < IFNAMSIZ; ++i) m_ifreq.ifr_name[i] = 0; if (ioctl (so, SIOCGIFINDEX, &m_ifreq)) return error(errServiceUnavailable); #if defined(__FreeBSD__) || defined(__GNU__) InterfaceIndex = m_ifreq.ifr_ifru.ifru_index; #else InterfaceIndex = m_ifreq.ifr_ifindex; #endif return errSuccess; #else return error(errServiceUnavailable); #endif #else return error(errServiceUnavailable); #endif // WIN32 } #ifdef AF_UNSPEC Socket::Error UDPSocket::disconnect(void) { struct sockaddr_in addr; int len = sizeof(addr); if(so == INVALID_SOCKET) return errSuccess; Socket::state = BOUND; memset(&addr, 0, len); #ifndef _MSWINDOWS_ addr.sin_family = AF_UNSPEC; #else addr.sin_family = AF_INET; memset(&addr.sin_addr, 0, sizeof(addr.sin_addr)); #endif if(::connect(so, (sockaddr *)&addr, len)) return connectError(); return errSuccess; } #else Socket::Error UDPSocket::disconnect(void) { if(so == INVALID_SOCKET) return errSuccess; Socket::state = BOUND; return connect(getLocal()); } #endif void UDPSocket::setPeer(const IPV4Host &ia, tpport_t port) { memset(&peer.ipv4, 0, sizeof(peer.ipv4)); peer.ipv4.sin_family = AF_INET; peer.ipv4.sin_addr = ia.getAddress(); peer.ipv4.sin_port = htons(port); } void UDPSocket::connect(const IPV4Host &ia, tpport_t port) { setPeer(ia, port); if(so == INVALID_SOCKET) return; if(!::connect(so, (struct sockaddr *)&peer.ipv4, sizeof(struct sockaddr_in))) Socket::state = CONNECTED; } #ifdef CCXX_IPV6 void UDPSocket::setPeer(const IPV6Host &ia, tpport_t port) { memset(&peer.ipv6, 0, sizeof(peer.ipv6)); peer.ipv6.sin6_family = AF_INET6; peer.ipv6.sin6_addr = ia.getAddress(); peer.ipv6.sin6_port = htons(port); } void UDPSocket::connect(const IPV6Host &ia, tpport_t port) { setPeer(ia, port); if(so == INVALID_SOCKET) return; if(!::connect(so, (struct sockaddr *)&peer.ipv6, sizeof(struct sockaddr_in6))) Socket::state = CONNECTED; } #endif #ifdef HAVE_GETADDRINFO void UDPSocket::setPeer(const char *name) { char namebuf[128], *cp; struct addrinfo hint, *list; snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) return; memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = SOCK_DGRAM; hint.ai_protocol = IPPROTO_UDP; if(getaddrinfo(namebuf, cp, &hint, &list) || !list) return; switch(family) { #ifdef CCXX_IPV6 case IPV6: memcpy(&peer.ipv6, list->ai_addr, sizeof(peer.ipv6)); break; #endif case IPV4: memcpy(&peer.ipv4, list->ai_addr, sizeof(peer.ipv4)); break; } freeaddrinfo(list); } #else void UDPSocket::setPeer(const char *name) { char namebuf[128], *cp; struct servent *svc; tpport_t port; snprintf(namebuf, sizeof(namebuf), "%s", name); cp = strrchr(namebuf, '/'); if(!cp) cp = strrchr(namebuf, ':'); if(!cp) return; if(isdigit(*cp)) port = atoi(cp); else { mutex.enter(); svc = getservbyname(cp, "udp"); if(svc) port = ntohs(svc->s_port); mutex.leave(); if(!svc) return; } memset(&peer, 0, sizeof(peer)); switch(family) { #ifdef CCXX_IPV6 case IPV6: setPeer(IPV6Host(namebuf), port); break; #endif case IPV4: setPeer(IPV4Host(namebuf), port); break; } } #endif void UDPSocket::connect(const char *service) { int rtn = -1; setPeer(service); if(so == INVALID_SOCKET) return; switch(family) { #ifdef CCXX_IPV6 case IPV6: rtn = ::connect(so, (struct sockaddr *)&peer.ipv6, sizeof(struct sockaddr_in6)); break; #endif case IPV4: rtn = ::connect(so, (struct sockaddr *)&peer.ipv4, sizeof(struct sockaddr_in)); break; } if(!rtn) Socket::state = CONNECTED; } IPV4Host UDPSocket::getIPV4Peer(tpport_t *port) const { // FIXME: insufficient buffer // how to retrieve peer ?? char buf; socklen_t len = sizeof(peer.ipv4); int rtn = ::recvfrom(so, &buf, 1, MSG_PEEK, (struct sockaddr *)&peer.ipv4, &len); #ifdef _MSWINDOWS_ if(rtn < 1 && WSAGetLastError() != WSAEMSGSIZE) { if(port) *port = 0; memset((void*) &peer.ipv4, 0, sizeof(peer.ipv4)); } #else if(rtn < 1) { if(port) *port = 0; memset((void*) &peer.ipv4, 0, sizeof(peer.ipv4)); } #endif else { if(port) *port = ntohs(peer.ipv4.sin_port); } return IPV4Host(peer.ipv4.sin_addr); } #ifdef CCXX_IPV6 IPV6Host UDPSocket::getIPV6Peer(tpport_t *port) const { // FIXME: insufficient buffer // how to retrieve peer ?? char buf; socklen_t len = sizeof(peer.ipv6); int rtn = ::recvfrom(so, &buf, 1, MSG_PEEK, (struct sockaddr *)&peer.ipv6, &len); #ifdef _MSWINDOWS_ if(rtn < 1 && WSAGetLastError() != WSAEMSGSIZE) { if(port) *port = 0; memset((void*) &peer.ipv6, 0, sizeof(peer.ipv6)); } #else if(rtn < 1) { if(port) *port = 0; memset((void*) &peer.ipv6, 0, sizeof(peer.ipv6)); } #endif else { if(port) *port = ntohs(peer.ipv6.sin6_port); } return IPV6Host(peer.ipv6.sin6_addr); } #endif UDPBroadcast::UDPBroadcast(const IPV4Address &ia, tpport_t port) : UDPSocket(ia, port) { if(so != INVALID_SOCKET) setBroadcast(true); } void UDPBroadcast::setPeer(const IPV4Broadcast &ia, tpport_t port) { memset(&peer.ipv4, 0, sizeof(peer.ipv4)); peer.ipv4.sin_family = AF_INET; peer.ipv4.sin_addr = ia.getAddress(); peer.ipv4.sin_port = htons(port); } UDPTransmit::UDPTransmit(const IPV4Address &ia, tpport_t port) : UDPSocket(ia, port) { disconnect(); // assure not started live ::shutdown(so, 0); receiveBuffer(0); } #ifdef CCXX_IPV6 UDPTransmit::UDPTransmit(const IPV6Address &ia, tpport_t port) : UDPSocket(ia, port) { disconnect(); // assure not started live ::shutdown(so, 0); receiveBuffer(0); } #endif UDPTransmit::UDPTransmit(Family family) : UDPSocket(family) { disconnect(); ::shutdown(so, 0); receiveBuffer(0); } Socket::Error UDPTransmit::cConnect(const IPV4Address &ia, tpport_t port) { int len = sizeof(peer.ipv4); peer.ipv4.sin_family = AF_INET; peer.ipv4.sin_addr = ia.getAddress(); peer.ipv4.sin_port = htons(port); // Win32 will crash if you try to connect to INADDR_ANY. if ( INADDR_ANY == peer.ipv4.sin_addr.s_addr ) peer.ipv4.sin_addr.s_addr = INADDR_LOOPBACK; if(::connect(so, (sockaddr *)&peer.ipv4, len)) return connectError(); return errSuccess; } #ifdef CCXX_IPV6 Socket::Error UDPTransmit::connect(const IPV6Address &ia, tpport_t port) { int len = sizeof(peer.ipv6); peer.ipv6.sin6_family = AF_INET6; peer.ipv6.sin6_addr = ia.getAddress(); peer.ipv6.sin6_port = htons(port); // Win32 will crash if you try to connect to INADDR_ANY. if(!memcmp(&peer.ipv6.sin6_addr, &in6addr_any, sizeof(in6addr_any))) memcpy(&peer.ipv6.sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)); if(::connect(so, (struct sockaddr *)&peer.ipv6, len)) return connectError(); return errSuccess; } #endif Socket::Error UDPTransmit::connect(const IPV4Host &ia, tpport_t port) { if(isBroadcast()) setBroadcast(false); return cConnect((IPV4Address)ia,port); } Socket::Error UDPTransmit::connect(const IPV4Broadcast &subnet, tpport_t port) { if(!isBroadcast()) setBroadcast(true); return cConnect((IPV4Address)subnet,port); } Socket::Error UDPTransmit::connect(const IPV4Multicast &group, tpport_t port) { Error err; if(!( err = UDPSocket::setMulticast(true) )) return err; return cConnect((IPV4Address)group,port); } #ifdef CCXX_IPV6 Socket::Error UDPTransmit::connect(const IPV6Multicast &group, tpport_t port) { Error error; if(!( error = UDPSocket::setMulticast(true) )) return error; return connect((IPV6Address)group,port); } #endif UDPReceive::UDPReceive(const IPV4Address &ia, tpport_t port) : UDPSocket(ia, port) { ::shutdown(so, 1); sendBuffer(0); } #ifdef CCXX_IPV6 UDPReceive::UDPReceive(const IPV6Address &ia, tpport_t port) : UDPSocket(ia, port) { ::shutdown(so, 1); sendBuffer(0); } #endif Socket::Error UDPReceive::connect(const IPV4Host &ia, tpport_t port) { int len = sizeof(peer.ipv4); peer.ipv4.sin_family = AF_INET; peer.ipv4.sin_addr = ia.getAddress(); peer.ipv4.sin_port = htons(port); // Win32 will crash if you try to connect to INADDR_ANY. if ( INADDR_ANY == peer.ipv4.sin_addr.s_addr ) peer.ipv4.sin_addr.s_addr = INADDR_LOOPBACK; if(::connect(so, (struct sockaddr *)&peer.ipv4, len)) return connectError(); return errSuccess; } #ifdef CCXX_IPV6 Socket::Error UDPReceive::connect(const IPV6Host &ia, tpport_t port) { int len = sizeof(peer.ipv6); peer.ipv6.sin6_family = AF_INET6; peer.ipv6.sin6_addr = ia.getAddress(); peer.ipv6.sin6_port = htons(port); // Win32 will crash if you try to connect to INADDR_ANY. if(!memcmp(&peer.ipv6.sin6_addr, &in6addr_any, sizeof(in6addr_any))) memcpy(&peer.ipv6.sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)); if(::connect(so, (sockaddr *)&peer.ipv6, len)) return connectError(); return errSuccess; } #endif UDPDuplex::UDPDuplex(const IPV4Address &bind, tpport_t port) : UDPTransmit(bind, port + 1), UDPReceive(bind, port) {} #ifdef CCXX_IPV6 UDPDuplex::UDPDuplex(const IPV6Address &bind, tpport_t port) : UDPTransmit(bind, port + 1), UDPReceive(bind, port) {} #endif Socket::Error UDPDuplex::connect(const IPV4Host &host, tpport_t port) { Error rtn = UDPTransmit::connect(host, port); if(rtn) { UDPTransmit::disconnect(); UDPReceive::disconnect(); return rtn; } return UDPReceive::connect(host, port + 1); } #ifdef CCXX_IPV6 Socket::Error UDPDuplex::connect(const IPV6Host &host, tpport_t port) { Error rtn = UDPTransmit::connect(host, port); if(rtn) { UDPTransmit::disconnect(); UDPReceive::disconnect(); return rtn; } return UDPReceive::connect(host, port + 1); } #endif Socket::Error UDPDuplex::disconnect(void) { Error rtn = UDPTransmit::disconnect(); Error rtn2 = UDPReceive::disconnect(); if (rtn) return rtn; return rtn2; } ucommon-6.0.7/commoncpp/slog.cpp0000644000175000017500000002626012163025062013570 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #ifdef __BORLANDC__ #include #include #else #include #include #endif #ifdef HAVE_SYSLOG_H #include #endif using std::streambuf; using std::ofstream; using std::ostream; using std::clog; using std::endl; using std::ios; using namespace COMMONCPP_NAMESPACE; Slog ost::slog; Slog::Slog(void) : streambuf() #ifdef OLD_IOSTREAM ,ostream() #else ,ostream((streambuf *)this) #endif { #ifdef OLD_IOSTREAM init((streambuf *)this); #endif _enable = true; _level = levelDebug; _clogEnable = true; #ifndef HAVE_SYSLOG_H syslog = NULL; #endif } Slog::~Slog(void) { #ifdef HAVE_SYSLOG_H closelog(); #else if(syslog) fclose(syslog); #endif } void Slog::close(void) { #ifdef HAVE_SYSLOG_H closelog(); #else pthread_mutex_lock(&lock); if(syslog) fclose(syslog); syslog = NULL; pthread_mutex_unlock(&lock); #endif } void Slog::open(const char *ident, Class grp) { const char *cp; #ifdef HAVE_SYSLOG_H cp = strrchr(ident, '/'); if(cp) ident = ++cp; int fac; switch(grp) { case classUser: fac = LOG_USER; break; case classDaemon: fac = LOG_DAEMON; break; case classAudit: #ifdef LOG_AUTHPRIV fac = LOG_AUTHPRIV; break; #endif case classSecurity: fac = LOG_AUTH; break; case classLocal0: fac = LOG_LOCAL0; break; case classLocal1: fac = LOG_LOCAL1; break; case classLocal2: fac = LOG_LOCAL2; break; case classLocal3: fac = LOG_LOCAL3; break; case classLocal4: fac = LOG_LOCAL4; break; case classLocal5: fac = LOG_LOCAL5; break; case classLocal6: fac = LOG_LOCAL6; break; case classLocal7: fac = LOG_LOCAL7; break; default: fac = LOG_USER; break; } openlog(ident, 0, fac); #else char *buf; pthread_mutex_lock(&lock); if(syslog) fclose(syslog); buf = new char[strlen(ident) + 1]; strcpy(buf, ident); cp = (const char *)buf; buf = strrchr(buf, '.'); if(buf) { if(!stricmp(buf, ".exe")) strcpy(buf, ".log"); } syslog = fopen(cp, "a"); delete[] (char *)cp; pthread_mutex_unlock(&lock); #endif } void Slog::error(const char *format, ...) { Thread *thread = Thread::get(); va_list args; va_start(args, format); overflow(EOF); if(!thread) return; error(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::warn(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); warn(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::debug(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); debug(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::emerg(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); emerg(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::alert(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); alert(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::critical(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); critical(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::notice(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); notice(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } void Slog::info(const char *format, ...) { Thread *thread = Thread::get(); va_list args; if(!thread) return; va_start(args, format); overflow(EOF); info(); vsnprintf(thread->msgbuf, sizeof(thread->msgbuf), format, args); thread->msgpos = strlen(thread->msgbuf); overflow(EOF); va_end(args); } int Slog::overflow(int c) { Thread *thread = Thread::get(); if(!thread) return c; if(c == '\n' || !c || c == EOF) { if(!thread->msgpos) return c; thread->msgbuf[thread->msgpos] = 0; if (_enable) #ifdef HAVE_SYSLOG_H ::syslog(priority, "%s", thread->msgbuf); #else { time_t now; struct tm *dt; time(&now); dt = localtime(&now); char buf[256]; const char *p = "unknown"; switch(priority) { case levelEmergency: p = "emerg"; break; case levelInfo: p = "info"; break; case levelError: p = "error"; break; case levelAlert: p = "alert"; break; case levelDebug: p = "debug"; break; case levelNotice: p = "notice"; break; case levelWarning: p = "warn"; break; case levelCritical: p = "crit"; break; } pthread_mutex_lock(&lock); snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d [%s] %s\n", dt->tm_year + 1900, dt->tm_mon + 1, dt->tm_mday, dt->tm_hour, dt->tm_min, dt->tm_sec, p, thread->msgbuf); if(syslog) fputs(buf, syslog); // syslog << "[" << priority << "] " << thread->msgbuf << endl; pthread_mutex_unlock(&lock); } #endif thread->msgpos = 0; if ( _enable && _clogEnable #ifndef _MSWINDOWS_ && (getppid() > 1) #endif ) clog << thread->msgbuf << endl; _enable = true; return c; } if (thread->msgpos < (int)(sizeof(thread->msgbuf) - 1)) thread->msgbuf[thread->msgpos++] = c; return c; } Slog &Slog::operator()(const char *ident, Class grp, Level lev) { Thread *thread = Thread::get(); if(!thread) return *this; thread->msgpos = 0; _enable = true; open(ident, grp); return this->operator()(lev, grp); } Slog &Slog::operator()(Level lev, Class grp) { Thread *thread = Thread::get(); if(!thread) return *this; thread->msgpos = 0; if(_level >= lev) _enable = true; else _enable = false; #ifdef HAVE_SYSLOG_H switch(lev) { case levelEmergency: priority = LOG_EMERG; break; case levelAlert: priority = LOG_ALERT; break; case levelCritical: priority = LOG_CRIT; break; case levelError: priority = LOG_ERR; break; case levelWarning: priority = LOG_WARNING; break; case levelNotice: priority = LOG_NOTICE; break; case levelInfo: priority = LOG_INFO; break; case levelDebug: priority = LOG_DEBUG; break; } switch(grp) { case classAudit: #ifdef LOG_AUTHPRIV priority |= LOG_AUTHPRIV; break; #endif case classSecurity: priority |= LOG_AUTH; break; case classUser: priority |= LOG_USER; break; case classDaemon: priority |= LOG_DAEMON; break; case classDefault: priority |= LOG_USER; break; case classLocal0: priority |= LOG_LOCAL0; break; case classLocal1: priority |= LOG_LOCAL1; break; case classLocal2: priority |= LOG_LOCAL2; break; case classLocal3: priority |= LOG_LOCAL3; break; case classLocal4: priority |= LOG_LOCAL4; break; case classLocal5: priority |= LOG_LOCAL5; break; case classLocal6: priority |= LOG_LOCAL6; break; case classLocal7: priority |= LOG_LOCAL7; break; } #else priority = lev; #endif return *this; } Slog &Slog::operator()(void) { return *this; } ucommon-6.0.7/commoncpp/mime.cpp0000644000175000017500000000766112163025062013557 00000000000000// Copyright (C) 2001-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // #include #include #include #include #include #include #include NAMESPACE_COMMONCPP using namespace std; MIMEMultipart::MIMEMultipart(const char *mt) { const char *cp = strchr(mt, '/'); if(cp) mt = ++cp; first = last = NULL; header[1] = NULL; header[0] = mtype; setString(boundry, sizeof(boundry), "xyzzy"); snprintf(mtype, sizeof(mtype), "Content-Type: multipart/%s, boundry=%s", mt, boundry); } MIMEMultipart::~MIMEMultipart() {} void MIMEMultipart::head(std::ostream *out) { char **list = header; while(**list) *out << *(list++) << "\r\n"; out->flush(); } void MIMEMultipart::body(std::ostream *out) { MIMEItemPart *item = first; while(item) { *out << "--" << boundry << "\r\n"; item->head(out); *out << "\r\n"; item->body(out); item = item->next; } *out << "--" << boundry << "--\r\n"; out->flush(); } MIMEItemPart::MIMEItemPart(MIMEMultipart *m, const char *ct) { if(m->last) { m->last->next = this; m->last = this; } else m->first = m->last = this; next = NULL; ctype = ct; } MIMEItemPart::~MIMEItemPart() {} MIMEMultipartForm::MIMEMultipartForm() : MIMEMultipart("form-data") {} MIMEMultipartForm::~MIMEMultipartForm() {} void MIMEItemPart::head(std::ostream *out) { *out << "Content-Type: " << ctype << "\r" << endl; } MIMEFormData::MIMEFormData(MIMEMultipartForm *m, const char *n, const char *v) : MIMEItemPart(m, "") { name = n; content = v; } MIMEFormData::~MIMEFormData() {} void MIMEFormData::head(std::ostream *out) { *out << "Content-Disposition: form-data; name=\"" << name << "\"\r\n"; } void MIMEFormData::body(std::ostream *out) { *out << content << "\r\n"; } END_NAMESPACE /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 4 * End: */ ucommon-6.0.7/ucommon-config.h.in0000644000175000017500000001616212175171615013634 00000000000000/* ucommon-config.h.in. Generated from configure.ac by autoheader. */ /* has posix clock functions */ #undef HAVE_CLOCK_GETTIME /* has clocked nanosleep */ #undef HAVE_CLOCK_NANOSLEEP /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_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_ENDIAN_H /* has execvp in libc */ #undef HAVE_EXECVP /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* has ftok */ #undef HAVE_FTOK /* can truncate files */ #undef HAVE_FTRUNCATE /* "cannot test in autoconf safely" */ #undef HAVE_GCC_ATOMICS /* have getaddrinfo */ #undef HAVE_GETADDRINFO /* have gethostbyname2 */ #undef HAVE_GETHOSTBYNAME2 /* has gettext in glibc */ #undef HAVE_GETTEXT /* has localtime_r */ #undef HAVE_GMTIME_R /* have inet_ntop */ #undef HAVE_INET_NTOP /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* international headers */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_VERSION_H /* has localtime_r */ #undef HAVE_LOCALTIME_R /* have lstat */ #undef HAVE_LSTAT /* Define to 1 if you have the header file. */ #undef HAVE_MACH_CLOCK_H /* 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_MEMORY_H /* has nanosleep */ #undef HAVE_NANOSLEEP /* 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_NET_IF_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_FIPS_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SSL_H /* Define to 1 if you have the header file. */ #undef HAVE_POLL_H /* can specify access options */ #undef HAVE_POSIX_FADVISE /* posix memory alignment */ #undef HAVE_POSIX_MEMALIGN /* "pthread clocking" */ #undef HAVE_PTHREAD_CONDATTR_SETCLOCK /* "pthread delay" */ #undef HAVE_PTHREAD_DELAY /* "pthread delay np" */ #undef HAVE_PTHREAD_DELAY_NP /* "pthread concurrency" */ #undef HAVE_PTHREAD_SETCONCURRENCY /* "pthread scheduling" */ #undef HAVE_PTHREAD_SETSCHEDPRIO /* "pthread yield" */ #undef HAVE_PTHREAD_YIELD /* can do atomic write with offset */ #undef HAVE_PWRITE /* has readlink in libc */ #undef HAVE_READLINK /* realpath support */ #undef HAVE_REALPATH /* have regex header */ #undef HAVE_REGEX_H /* can set localization */ #undef HAVE_SETLOCALE /* process group control */ #undef HAVE_SETPGRP /* alternate dyn loader */ #undef HAVE_SHL_LOAD /* shared memory open */ #undef HAVE_SHM_OPEN /* have socketpair in libsocket */ #undef HAVE_SOCKETPAIR /* "Socks proxy support" */ #undef HAVE_SOCKS /* Define to 1 if you have the header file. */ #undef HAVE_SOCKS_H /* Define to 1 if you have the header file. */ #undef HAVE_STDEXCEPT /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* string collation */ #undef HAVE_STRCOLL /* has strerror_r */ #undef HAVE_STRERROR_R /* string icmp */ #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 /* string istr */ #undef HAVE_STRISTR /* has symlink in libc */ #undef HAVE_SYMLINK /* system config */ #undef HAVE_SYSCONF /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EVENT_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_FILIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_INOTIFY_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_LOCKF_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_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_SHM_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_TIMEB_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_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIO_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* has wait4 in libc */ #undef HAVE_WAIT4 /* has waitpid in libc */ #undef HAVE_WAITPID /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* 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 to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* config path */ #undef UCOMMON_CFGPATH /* locale path */ #undef UCOMMON_LOCALE /* config path */ #undef UCOMMON_PREFIX /* config path */ #undef UCOMMON_VARPATH /* Version number of package */ #undef VERSION /* 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 the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ #undef restrict /* Work around a bug in Sun C++: it does not support _Restrict or __restrict__, even though the corresponding Sun C compiler ends up with "#define restrict _Restrict" or "#define restrict __restrict__" in the previous line. Perhaps some future version of Sun C++ will work with restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ #if defined __SUNPRO_CC && !defined __RESTRICT # define _Restrict # define __restrict__ #endif /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile #include ucommon-6.0.7/ucommon-config.h.cmake0000644000175000017500000000644412163025062014277 00000000000000/* Copyright (C) 2009 David Sugar, Tycho Softworks This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #define STDC_HEADERS 1 #cmakedefine PACKAGE ${PROJECT_NAME} #cmakedefine VERSION "${VERSION}" #cmakedefine HAVE_CLOCK_NANOSLEEP 1 #cmakedefine HAVE_DIRENT_H 1 #cmakedefine HAVE_DLFCN_H 1 #cmakedefine HAVE_ENDIAN_H 1 #cmakedefine HAVE_INTTYPES_H 1 #cmakedefine HAVE_LINUX_VERSION_H 1 #cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_STDLIB_H 1 #cmakedefine HAVE_SYS_FILIO_H 1 #cmakedefine HAVE_SYS_MMAN_H 1 #cmakedefine HAVE_SYS_POLL_H 1 #cmakedefine HAVE_SYS_RESOURCE_H 1 #cmakedefine HAVE_SYS_SHM_H 1 #cmakedefine HAVE_SYS_STAT_H 1 #cmakedefine HAVE_SYS_TIMEB_H 1 #cmakedefine HAVE_SYS_TYPES_H 1 #cmakedefine HAVE_SYS_WAIT_H 1 #cmakedefine HAVE_UNISTD_H 1 #cmakedefine HAVE_WCHAR_H 1 #cmakedefine HAVE_REGEX_H 1 #cmakedefine HAVE_SYS_INOTIFY_H 1 #cmakedefine HAVE_SYS_EVENT_H 1 #cmakedefine HAVE_SYSLOG_H 1 #cmakedefine HAVE_LIBINTL_H 1 #cmakedefine HAVE_NETINET_IN_H 1 #cmakedefine HAVE_NET_IF_H 1 #cmakedefine HAVE_SYS_PARAM_H 1 #cmakedefine HAVE_SYS_FILE_H 1 #cmakedefine HAVE_SYS_LOCKF_H 1 #cmakedefine HAVE_REGEX_H 1 #cmakedefine HAVE_FTOK 1 #cmakedefine HAVE_GETADDRINFO 1 #cmakedefine HAVE_GETHOSTBYNAME2 1 #cmakedefine HAVE_INET_NTOP 1 #cmakedefine HAVE_GMTIME_R 1 #cmakedefine HAVE_LOCALTIME_R 1 #cmakedefine HAVE_STRERROR_R 1 #cmakedefine HAVE_MACH_CLOCK_H 1 #cmakedefine HAVE_MACH_O_DYLD_H 1 #cmakedefine HAVE_MEMORY_H 1 #cmakedefine HAVE_NANOSLEEP 1 #cmakedefine HAVE_POLL_H 1 #cmakedefine HAVE_CLOCK_GETTIME 1 #cmakedefine HAVE_POSIX_FADVISE 1 #cmakedefine HAVE_POSIX_MEMALIGN 1 #cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 #cmakedefine HAVE_PTHREAD_DELAY 1 #cmakedefine HAVE_PTHREAD_DELAY_NP 1 #cmakedefine HAVE_PTHREAD_SETCONCURRENCY 1 #cmakedefine HAVE_PTHREAD_SETSCHEDPRIO 1 #cmakedefine HAVE_PTHREAD_YIELD 1 #cmakedefine HAVE_PTHREAD_YIELD_NP 1 #cmakedefine HAVE_SHL_LOAD 1 #cmakedefine HAVE_SHM_OPEN 1 #cmakedefine HAVE_SOCKETPAIR 1 #define HAVE_STDEXCEPT 1 /* cannot seem to test in cmake... */ #cmakedefine HAVE_STRICMP 1 #cmakedefine HAVE_STRCOLL 1 #cmakedefine HAVE_STRINGS_H 1 #cmakedefine HAVE_STRISTR 1 #cmakedefine HAVE_SYSCONF 1 #cmakedefine HAVE_FTRUNCATE 1 #cmakedefine HAVE_PWRITE 1 #cmakedefine HAVE_SETPGRP 1 #cmakedefine HAVE_SETLOCALE 1 #cmakedefine HAVE_GETTEXT 1 #cmakedefine HAVE_EXECVP 1 #cmakedefine HAVE_ATEXIT 1 #cmakedefine HAVE_LSTAT 1 #cmakedefine HAVE_REALPATH 1 #cmakedefine HAVE_SYMLINK 1 #cmakedefine HAVE_READLINK 1 #cmakedefine HAVE_WAITPID 1 #cmakedefine HAVE_WAIT4 1 #cmakedefine HAVE_FCNTL_H 1 #cmakedefine HAVE_TERMIOS_H 1 #cmakedefine HAVE_TERMIO_H 1 #cmakedefine HAVE_OPENSSL_FIPS_H 1 #cmakedefine POSIX_TIMERS 1 #cmakedefine GCC_ATOMICS 1 #cmakedefine UCOMMON_LOCALE "${UCOMMON_LOCALE}" #cmakedefine UCOMMON_CFGPATH "${UCOMMON_CFGPATH}" #cmakedefine UCOMMON_VARPATH "${UCOMMON_VARPATH}" #cmakedefine UCOMMON_PREFIX "${UCOMMON_PREFIX}" #ifdef GCC_ATOMICS #define HAVE_GCC_ATOMICS #endif #include ucommon-6.0.7/commoncpp-config.in0000755000175000017500000000426712163025062013721 00000000000000#!/bin/sh # Copyright (C) 2006-2007 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. prefix=@prefix@ exec_prefix=@exec_prefix@ includedir=@includedir@ if [ "`ldd /bin/sh | grep lib64`" = "" ] then libdir=${exec_prefix}/lib else libdir=${exec_prefix}/lib64 fi usage() { cat </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 # 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 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 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'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || 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 test \$(( 1 + 1 )) = 2 || 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 : 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 : $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_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 # 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; } # 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). . "./$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 -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' 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 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'" # 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='ucommon' PACKAGE_TARNAME='ucommon' PACKAGE_VERSION='6.0.7' PACKAGE_STRING='ucommon 6.0.7' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="inc/ucommon/ucommon.h" # 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='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS LT_GENERIC LT_VERSION COMPAT SECURE SECURE_LIBS SECURE_LOCAL UCOMMON_LIBS UCOMMON_LIBC UCOMMON_CLINK UCOMMON_FLAGS UCOMMON_MODEL UCOMMON_LINKED UCOMMON_VISIBILITY CHECKFLAGS DOXYGEN UCOMMON_PREFIX UCOMMON_VARPATH UCOMMON_CFGPATH UCOMMON_LOCALE UCOMMON_INCLUDES GNUTLS_LIBS GNUTLS_CFLAGS OPENSSL_LIBS OPENSSL_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG libs includes AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR am__untar am__tar AMTAR am__leading_dot SET_MAKE mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL AWK RANLIB STRIP ac_ct_AR AR LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED LIBTOOL OBJDUMP DLLTOOL AS CXXCPP ac_ct_CXX CXXFLAGS CXX CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC 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_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock enable_dependency_tracking enable_silent_rules enable_posix_timers enable_stdcpp with_sslstack with_libc enable_debug enable_socks enable_atomics enable_pth with_pkg_config ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR OPENSSL_CFLAGS OPENSSL_LIBS GNUTLS_CFLAGS GNUTLS_LIBS' # 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_TARNAME}' 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 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 ucommon 6.0.7 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/ucommon] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names 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 case $ac_init_help in short | recursive ) echo "Configuration of ucommon 6.0.7:";; esac 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-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-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-posix-timers enable posix timers --disable-stdcpp compile without stdc++ runtime overhead --enable-debug compile for debugging --enable-socks compile with socks proxy support --enable-atomics enable gcc atomic support --enable-pth always use GNU pth for threading 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-sslstack=lib specify which ssl stack to build --with-libc=path specify path to alternate libc --with-pkg-config enable support for pkg-config 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 CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path OPENSSL_CFLAGS C compiler flags for OPENSSL, overriding pkg-config OPENSSL_LIBS linker flags for OPENSSL, overriding pkg-config GNUTLS_CFLAGS C compiler flags for GNUTLS, overriding pkg-config GNUTLS_LIBS linker flags for GNUTLS, overriding pkg-config 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 ucommon configure 6.0.7 generated by GNU Autoconf 2.69 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. _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_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_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_cxx_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_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_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_cxx_preproc_warn_flag$ac_cxx_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_cxx_try_cpp # 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 || 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_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_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_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_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_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_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || 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_cxx_try_link # 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_cxx_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_cxx_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_cxx_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_cxx_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_cxx_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_cxx_check_header_mongrel 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 ucommon $as_me 6.0.7, which was generated by GNU Autoconf 2.69. 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 LT_VERSION="6:3:0" OPENSSL_REQUIRES="0.9.7" ac_aux_dir= for ac_dir in autoconf "$srcdir"/autoconf; 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 autoconf \"$srcdir\"/autoconf" "$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. # 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}- # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` 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 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 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 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 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 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 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 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 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 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 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 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 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 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); 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 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 whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 { $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 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); 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 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 whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" 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 ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC 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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # 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_CXX="$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 CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC 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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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_CXX="$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_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" 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 CXX=$ac_ct_CXX fi fi fi fi # 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 { $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_cxx_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_cxx_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_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_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_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi 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 ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_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; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_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_cxx_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_cxx_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_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_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_cxx_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_cxx_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 \"$CXXCPP\" 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 ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC 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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # 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_CXX="$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 CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC 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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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_CXX="$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_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" 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 CXX=$ac_ct_CXX fi fi fi fi # 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 { $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_cxx_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_cxx_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_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_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_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi 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 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 as_fn_executable_p "$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 as_fn_executable_p "$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 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 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 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 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 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 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" 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 *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 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" 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 *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" 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 *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 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" 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 *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 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 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 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 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; } { $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 # 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 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 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 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 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 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 ${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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 # 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 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 # 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 { $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 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 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 # 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) $(top_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* 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" if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_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; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_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_cxx_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_cxx_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_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_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_cxx_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_cxx_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 \"$CXXCPP\" 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 else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds reload_flag_CXX=$reload_flag reload_cmds_CXX=$reload_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$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. # 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 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* # 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 compiler_CXX=$CC 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-%%"` 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_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # 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 # 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 archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$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' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${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 whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= 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. archive_cmds_CXX='$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 { $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; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=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. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='${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 hardcode_direct_CXX=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_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= 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_CXX='${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_CXX=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_CXX='-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__CXX+:} 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_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`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__CXX"; then lt_cv_aix_libpath__CXX=`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__CXX"; then lt_cv_aix_libpath__CXX="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$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_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$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__CXX+:} 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_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`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__CXX"; then lt_cv_aix_libpath__CXX=`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__CXX"; then lt_cv_aix_libpath__CXX="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='${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_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${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_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$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 allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=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. hardcode_libdir_flag_spec_CXX=' ' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=yes file_list_spec_CXX='@' # 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_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds_CXX='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, CXX)='true' enable_shared_with_static_runtimes_CXX=yes # Don't use ranlib old_postinstall_cmds_CXX='chmod 644 $oldlib' postlink_cmds_CXX='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, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$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... archive_expsym_cmds_CXX='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 ld_shlibs_CXX=no fi ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec_CXX='`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_CXX='' fi link_all_deplibs_CXX=yes allow_undefined_flag_CXX="$_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_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds_CXX="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_CXX="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}" if test "$lt_cv_apple_cc_single_mod" != "yes"; then archive_cmds_CXX="\$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}" archive_expsym_cmds_CXX="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 ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; haiku*) archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=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 ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$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 archive_cmds_CXX='$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 ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=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 ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$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*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$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 ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${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_CXX='$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_CXX='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++ archive_cmds_CXX='$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. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$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 archive_cmds_CXX='$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 link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=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. archive_cmds_CXX='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' archive_expsym_cmds_CXX='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"' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$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."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$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 archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='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`"' old_archive_cmds_CXX='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' archive_cmds_CXX='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' archive_expsym_cmds_CXX='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 archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$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 hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${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++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$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 hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # 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 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds_CXX='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 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='${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_CXX=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. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=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*) ld_shlibs_CXX=yes ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else ld_shlibs_CXX=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. archive_cmds_CXX='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' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$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' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$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' archive_expsym_cmds_CXX='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' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # 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 allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) archive_cmds_CXX='$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' ;; *) archive_cmds_CXX='$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 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # 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 ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='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' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=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?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=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. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$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. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='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. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='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 hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$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. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ '"$reload_cmds_CXX" ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$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 ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$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... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _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 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 # 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 "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${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 "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${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 "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken 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. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; 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 postdeps_CXX='-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 postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-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_CXX='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-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_CXX='-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 lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static_CXX= ;; 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_prog_compiler_pic_CXX=-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_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-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_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--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). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+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_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-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_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-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_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) # IBM XL 8.0, 9.0 on PPC and BlueGene lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -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_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=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_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= 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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=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_CXX=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_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&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_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=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_CXX=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_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = 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; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_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 export_symbols_cmds_CXX='$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_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) export_symbols_cmds_CXX='$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_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' ;; esac ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX 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_CXX+:} 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_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 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_CXX=no else lt_cv_archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$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_CXX" >&5 $as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } 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}' ;; 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_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_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_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_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct_CXX" != 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, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test "$hardcode_action_CXX" = relink || test "$inherit_rpath_CXX" = 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 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_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_commands="$ac_config_commands libtool" # Only expand once: am__api_version='1.14' # 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 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. : 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' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then 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 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 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 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 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 fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P 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. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } { $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 rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='ucommon' VERSION='6.0.7' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi ac_config_headers="$ac_config_headers ucommon-config.h" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 $as_echo_n "checking for C/C++ restrict keyword... " >&6; } if ${ac_cv_c_restrict+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_restrict=no # The order here caters to the fact that C++ does not require restrict. for ac_kw in __restrict __restrict__ _Restrict restrict; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ typedef int * int_ptr; int foo (int_ptr $ac_kw ip) { return ip[0]; } int main () { int s[1]; int * $ac_kw t = s; t[0] = 0; return foo(t) ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_restrict=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_restrict" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 $as_echo "$ac_cv_c_restrict" >&6; } case $ac_cv_c_restrict in restrict) ;; no) $as_echo "#define restrict /**/" >>confdefs.h ;; *) cat >>confdefs.h <<_ACEOF #define restrict $ac_cv_c_restrict _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 $as_echo_n "checking for working volatile... " >&6; } if ${ac_cv_c_volatile+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { volatile int x; int * volatile y = (int *) 0; return !x && !y; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_volatile=yes else ac_cv_c_volatile=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_volatile" >&5 $as_echo "$ac_cv_c_volatile" >&6; } if test $ac_cv_c_volatile = no; then $as_echo "#define volatile /**/" >>confdefs.h 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 UCOMMON_VISIBILITY="0" UCOMMON_FLAGS="" UCOMMON_MODEL="CXX" UCOMMON_CLINK="" UCOMMON_LIBC="-lc" UCOMMON_LIBS="" OPENSSL_LINK="" CHECKFLAGS="$CHECKFLAGS" case "$with_crypto" in ssl|openssl) ssl="openssl" ;; gnutls|gnu) ssl="gnutls" ;; none|nossl) ssl="nossl" ;; *) ssl="detect" ;; esac have_gettext="no" socket_lib="" posix4_lib="" rt_lib="" test -z "$localedir" && localedir='${datadir}/locale' # for very old gcc and for minix we disable full ucommon build by default # we also disable for mingw32 or when no "shared" library support because # libstdc++ is not dll and really bloats in linkage of plugins. Any case, # you can always override with --enable-stdcpp... if test -z "$enable_stdcpp" ; then if test "x$GCC" = "xyes" ; then gccver=`$CC -dumpversion | cut -f1 -d.` fi if test -z "$gccver" ; then gccver="3" fi if test "$gccver" -lt "3" ; then enable_stdcpp="no" fi if test "x$enable_shared" = "xno" ; then enable_stdcpp="no" fi case "$target_os" in *minix*|mingw*) enable_stdcpp="no" ;; esac fi # Check whether --enable-posix-timers was given. if test "${enable_posix_timers+set}" = set; then : enableval=$enable_posix_timers; fi if test "x$enable_posix_timers" = "xyes" ; then UCOMMON_FLAGS="$UCOMMON_FLAGS -DPOSIX_TIMERS" fi # Check whether --enable-stdcpp was given. if test "${enable_stdcpp+set}" = set; then : enableval=$enable_stdcpp; fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking full c++ support and linking model" >&5 $as_echo_n "checking full c++ support and linking model... " >&6; } if test "x$enable_stdcpp" = "xno" ; then UCOMMON_MODEL="CC" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } COMPAT="" else COMPAT="commoncpp" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi # Check whether --with-sslstack was given. if test "${with_sslstack+set}" = set; then : withval=$with_sslstack; if test x$with_sslstack != x ; then ssl="${with_sslstack}" ; fi fi # Check whether --with-libc was given. if test "${with_libc+set}" = set; then : withval=$with_libc; if test x$with_libc != x ; then clib=`echo ${with_libc} | sed s/-l//` UCOMMON_LIBC=-l${clib} ; fi fi # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; fi if test -z "$enable_debug" ; then enable_debug="no" elif test $enable_debug = "yes" ; then CXXFLAGS="${CXXFLAGS} -g -DDEBUG" fi threading="none" clib=`echo ${UCOMMON_LIBC} | sed s/-l//` tlib="" for ac_header in stdint.h poll.h sys/mman.h sys/shm.h sys/poll.h sys/timeb.h endian.h sys/filio.h dirent.h sys/resource.h wchar.h netinet/in.h net/if.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_header in mach/clock.h mach-o/dyld.h linux/version.h sys/inotify.h sys/event.h syslog.h sys/wait.h termios.h termio.h fcntl.h unistd.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_header in sys/param.h sys/lockf.h sys/file.h dlfcn.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 ac_fn_c_check_header_mongrel "$LINENO" "regex.h" "ac_cv_header_regex_h" "$ac_includes_default" if test "x$ac_cv_header_regex_h" = xyes; then : $as_echo "#define HAVE_REGEX_H 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for regfree in -lregex" >&5 $as_echo_n "checking for regfree in -lregex... " >&6; } if ${ac_cv_lib_regex_regfree+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lregex $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 regfree (); int main () { return regfree (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_regex_regfree=yes else ac_cv_lib_regex_regfree=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_regex_regfree" >&5 $as_echo "$ac_cv_lib_regex_regfree" >&6; } if test "x$ac_cv_lib_regex_regfree" = xyes; then : UCOMMON_LIBS="$UCOMMON_LIBS -lregex" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fopen in -lmsvcrt" >&5 $as_echo_n "checking for fopen in -lmsvcrt... " >&6; } if ${ac_cv_lib_msvcrt_fopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmsvcrt $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 fopen (); int main () { return fopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_msvcrt_fopen=yes else ac_cv_lib_msvcrt_fopen=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_msvcrt_fopen" >&5 $as_echo "$ac_cv_lib_msvcrt_fopen" >&6; } if test "x$ac_cv_lib_msvcrt_fopen" = xyes; then : threading="msw" clib="msvcrt" UCOMMON_VISIBILITY="0" UCOMMON_LIBS="--enable-stdcall-fixup $UCOMMON_LIBS -lmingwex -lmingw32 -lcrypt32 -ladvapi32 -luser32 -lws2_32 -lwsock32 -lkernel32" UCOMMON_LIBC="-lmsvcrt -lgcc" OPENSSL_LINK="-lgdi32" $as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __modsi3 in -lgcc" >&5 $as_echo_n "checking for __modsi3 in -lgcc... " >&6; } if ${ac_cv_lib_gcc___modsi3+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgcc $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 __modsi3 (); int main () { return __modsi3 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_gcc___modsi3=yes else ac_cv_lib_gcc___modsi3=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_gcc___modsi3" >&5 $as_echo "$ac_cv_lib_gcc___modsi3" >&6; } if test "x$ac_cv_lib_gcc___modsi3" = xyes; then : UCOMMON_LIBC="$UCOMMON_LIBC -lgcc" fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_socketpair" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socketpair in -l$clib" >&5 $as_echo_n "checking for socketpair in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 socketpair (); int main () { return socketpair (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_SOCKETPAIR 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socketpair in -lsocket" >&5 $as_echo_n "checking for socketpair in -lsocket... " >&6; } if ${ac_cv_lib_socket_socketpair+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $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 socketpair (); int main () { return socketpair (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socketpair=yes else ac_cv_lib_socket_socketpair=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_socket_socketpair" >&5 $as_echo "$ac_cv_lib_socket_socketpair" >&6; } if test "x$ac_cv_lib_socket_socketpair" = xyes; then : $as_echo "#define HAVE_SOCKETPAIR 1" >>confdefs.h fi fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_getaddrinfo" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -l$clib" >&5 $as_echo_n "checking for getaddrinfo in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lsocket" >&5 $as_echo_n "checking for getaddrinfo in -lsocket... " >&6; } if ${ac_cv_lib_socket_getaddrinfo+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $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 if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_getaddrinfo=yes else ac_cv_lib_socket_getaddrinfo=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_socket_getaddrinfo" >&5 $as_echo "$ac_cv_lib_socket_getaddrinfo" >&6; } if test "x$ac_cv_lib_socket_getaddrinfo" = xyes; then : $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h fi fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_gethostbyname2" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname2 in -l$clib" >&5 $as_echo_n "checking for gethostbyname2 in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 gethostbyname2 (); int main () { return gethostbyname2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_GETHOSTBYNAME2 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname2 in -lsocket" >&5 $as_echo_n "checking for gethostbyname2 in -lsocket... " >&6; } if ${ac_cv_lib_socket_gethostbyname2+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $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 gethostbyname2 (); int main () { return gethostbyname2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_gethostbyname2=yes else ac_cv_lib_socket_gethostbyname2=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_socket_gethostbyname2" >&5 $as_echo "$ac_cv_lib_socket_gethostbyname2" >&6; } if test "x$ac_cv_lib_socket_gethostbyname2" = xyes; then : $as_echo "#define HAVE_GETHOSTBYNAME2 1" >>confdefs.h fi fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_inet_ntop" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntop in -l$clib" >&5 $as_echo_n "checking for inet_ntop in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 inet_ntop (); int main () { return inet_ntop (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntop in -lsocket" >&5 $as_echo_n "checking for inet_ntop in -lsocket... " >&6; } if ${ac_cv_lib_socket_inet_ntop+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $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 inet_ntop (); int main () { return inet_ntop (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_inet_ntop=yes else ac_cv_lib_socket_inet_ntop=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_socket_inet_ntop" >&5 $as_echo "$ac_cv_lib_socket_inet_ntop" >&6; } if test "x$ac_cv_lib_socket_inet_ntop" = xyes; then : $as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntop in -lnsl" >&5 $as_echo_n "checking for inet_ntop in -lnsl... " >&6; } if ${ac_cv_lib_nsl_inet_ntop+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $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 inet_ntop (); int main () { return inet_ntop (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_inet_ntop=yes else ac_cv_lib_nsl_inet_ntop=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_nsl_inet_ntop" >&5 $as_echo "$ac_cv_lib_nsl_inet_ntop" >&6; } if test "x$ac_cv_lib_nsl_inet_ntop" = xyes; then : $as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h socket_lib="$socket_lib -lnsl" fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } if ${ac_cv_lib_socket_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $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 if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socket=yes else ac_cv_lib_socket_socket=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_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } if test "x$ac_cv_lib_socket_socket" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socketpair in -lsocket" >&5 $as_echo_n "checking for socketpair in -lsocket... " >&6; } if ${ac_cv_lib_socket_socketpair+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $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 socketpair (); int main () { return socketpair (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socketpair=yes else ac_cv_lib_socket_socketpair=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_socket_socketpair" >&5 $as_echo "$ac_cv_lib_socket_socketpair" >&6; } if test "x$ac_cv_lib_socket_socketpair" = xyes; then : $as_echo "#define HAVE_SOCKETPAIR 1" >>confdefs.h fi socket_lib="-lsocket" fi fi # Check whether --enable-socks was given. if test "${enable_socks+set}" = set; then : enableval=$enable_socks; fi if test "x$enable_socks" = "xyes" ; then enable_socks="no" for ac_header in socks.h do : ac_fn_c_check_header_mongrel "$LINENO" "socks.h" "ac_cv_header_socks_h" "$ac_includes_default" if test "x$ac_cv_header_socks_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SOCKS_H 1 _ACEOF enable_socks="yes" fi done else enable_socks="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socks proxy support" >&5 $as_echo_n "checking for socks proxy support... " >&6; } if test "x$enable_socks" = "xyes" ; then socket_lib="-lsocksd $socket_lib" $as_echo "#define HAVE_SOCKS 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_ac_Lib=`$as_echo "ac_cv_lib_$clib''_lstat" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lstat in -l$clib" >&5 $as_echo_n "checking for lstat in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 lstat (); int main () { return lstat (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_LSTAT 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_strcoll" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strcoll in -l$clib" >&5 $as_echo_n "checking for strcoll in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 strcoll (); int main () { return strcoll (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_STRCOLL 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_stricmp" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stricmp in -l$clib" >&5 $as_echo_n "checking for stricmp in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 stricmp (); int main () { return stricmp (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_STRICMP 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_stristr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stristr in -l$clib" >&5 $as_echo_n "checking for stristr in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 stristr (); int main () { return stristr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_STRISTR 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_sysconf" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysconf in -l$clib" >&5 $as_echo_n "checking for sysconf in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 sysconf (); int main () { return sysconf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_SYSCONF 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_posix_memalign" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for posix_memalign in -l$clib" >&5 $as_echo_n "checking for posix_memalign in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 posix_memalign (); int main () { return posix_memalign (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_POSIX_MEMALIGN 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_dlopen" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -l$clib" >&5 $as_echo_n "checking for dlopen in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_LIB$clib" | $as_tr_cpp` 1 _ACEOF LIBS="-l$clib $LIBS" 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 : UCOMMON_LIBS="$UCOMMON_LIBS -ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lcompat" >&5 $as_echo_n "checking for dlopen in -lcompat... " >&6; } if ${ac_cv_lib_compat_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcompat $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_compat_dlopen=yes else ac_cv_lib_compat_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_compat_dlopen" >&5 $as_echo "$ac_cv_lib_compat_dlopen" >&6; } if test "x$ac_cv_lib_compat_dlopen" = xyes; then : UCOMMON_LIBS="$UCOMMON_LIBS -lcompat" fi { $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 : $as_echo "#define HAVE_SHL_LOAD 1" >>confdefs.h UCOMMON_LIBS="$UCOMMON_LIBS -ldld" fi fi fi PTHREAD_FLAGS="" if test "$enable_shared" = "no" ; then UCOMMON_FLAGS="$UCOMMON_FLAGS -DUCOMMON_STATIC" ; fi # Check whether --enable-atomics was given. if test "${enable_atomics+set}" = set; then : enableval=$enable_atomics; $as_echo "#define HAVE_GCC_ATOMICS 1" >>confdefs.h fi # Check whether --enable-pth was given. if test "${enable_pth+set}" = set; then : enableval=$enable_pth; fi if test "$threading" = "none" ; then if test "$enable_pth" != "yes" ; then 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 : PTHREAD_FLAGS="-mt -pthread -pthreads" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $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 pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=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_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : tlib="pthread" UCOMMON_LIBS="$UCOMMON_LIBS -lpthread" fi if test -z "$tlib" ; then as_ac_Lib=`$as_echo "ac_cv_lib_$clib''_pthread_create" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -l$clib" >&5 $as_echo_n "checking for pthread_create in -l$clib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$clib $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 pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : tlib="$clib" fi fi if test -z "$tlib" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lc_r" >&5 $as_echo_n "checking for pthread_create in -lc_r... " >&6; } if ${ac_cv_lib_c_r_pthread_create+:} 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 pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_r_pthread_create=yes else ac_cv_lib_c_r_pthread_create=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_pthread_create" >&5 $as_echo "$ac_cv_lib_c_r_pthread_create" >&6; } if test "x$ac_cv_lib_c_r_pthread_create" = xyes; then : tlib="c_r" if test "$clib" = "c" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -lc_r" >&5 $as_echo_n "checking for malloc in -lc_r... " >&6; } if ${ac_cv_lib_c_r_malloc+:} 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 malloc (); int main () { return malloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_r_malloc=yes else ac_cv_lib_c_r_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_c_r_malloc" >&5 $as_echo "$ac_cv_lib_c_r_malloc" >&6; } if test "x$ac_cv_lib_c_r_malloc" = xyes; then : clib="c_r" fi fi fi fi if test ! -z "$tlib" ; then as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_pthread_condattr_setclock" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_condattr_setclock in -l$tlib" >&5 $as_echo_n "checking for pthread_condattr_setclock in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 pthread_condattr_setclock (); int main () { return pthread_condattr_setclock (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_pthread_setconcurrency" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setconcurrency in -l$tlib" >&5 $as_echo_n "checking for pthread_setconcurrency in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 pthread_setconcurrency (); int main () { return pthread_setconcurrency (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_PTHREAD_SETCONCURRENCY 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_pthread_yield" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_yield in -l$tlib" >&5 $as_echo_n "checking for pthread_yield in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 pthread_yield (); int main () { return pthread_yield (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_PTHREAD_YIELD 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_pthread_delay" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_delay in -l$tlib" >&5 $as_echo_n "checking for pthread_delay in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 pthread_delay (); int main () { return pthread_delay (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_PTHREAD_DELAY 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_pthread_delay_np" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_delay_np in -l$tlib" >&5 $as_echo_n "checking for pthread_delay_np in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 pthread_delay_np (); int main () { return pthread_delay_np (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_PTHREAD_DELAY_NP 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_pthread_setschedprio" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setschedprio in -l$tlib" >&5 $as_echo_n "checking for pthread_setschedprio in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 pthread_setschedprio (); int main () { return pthread_setschedprio (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_PTHREAD_SETSCHEDPRIO 1" >>confdefs.h fi fi else ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" if test "x$ac_cv_header_windows_h" = xyes; then : else ac_fn_c_check_header_mongrel "$LINENO" "pth.h" "ac_cv_header_pth_h" "$ac_includes_default" if test "x$ac_cv_header_pth_h" = xyes; then : UCOMMON_LIBS="$UCOMMON_LIBS -lpth" UCOMMON_FLAGS="$UCOMMON_FLAGS -D__PTH__" else as_fn_error $? "\"pthread or GNU pth support required\"" "$LINENO" 5 fi fi fi else ac_fn_c_check_header_mongrel "$LINENO" "pth.h" "ac_cv_header_pth_h" "$ac_includes_default" if test "x$ac_cv_header_pth_h" = xyes; then : UCOMMON_LIBS="$UCOMMON_LIBS -lpth" UCOMMON_FLAGS="$UCOMMON_FLAGS -D__PTH__" else as_fn_error $? "\"GNU pth required\"" "$LINENO" 5 fi fi fi for func in ftok shm_open nanosleep clock_nanosleep clock_gettime strerror_r localtime_r gmtime_r posix_fadvise ftruncate pwrite setpgrp setlocale gettext execvp atexit realpath symlink readlink waitpid wait4 ; do found="no" as_ac_var=`$as_echo "ac_cv_func_$func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : found=$func else as_ac_Lib=`$as_echo "ac_cv_lib_posix4_$func" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $func in -lposix4" >&5 $as_echo_n "checking for $func in -lposix4... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix4 $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 $func (); int main () { return $func (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : found=$func posix4_lib="-lposix4" else as_ac_Lib=`$as_echo "ac_cv_lib_rt_$func" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $func in -lrt" >&5 $as_echo_n "checking for $func in -lrt... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $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 $func (); int main () { return $func (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : found=$func rt_lib="-lrt" else if test ! -z "$tlib" ; then as_ac_Lib=`$as_echo "ac_cv_lib_$tlib''_$func" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $func in -l$tlib" >&5 $as_echo_n "checking for $func in -l$tlib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$tlib $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 $func (); int main () { return $func (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : found=$func fi fi fi fi fi case $found in shm_open) $as_echo "#define HAVE_SHM_OPEN 1" >>confdefs.h ;; setpgrp) $as_echo "#define HAVE_SETPGRP 1" >>confdefs.h ;; realpath) $as_echo "#define HAVE_REALPATH 1" >>confdefs.h ;; ftok) $as_echo "#define HAVE_FTOK 1" >>confdefs.h ;; gmtime_r) $as_echo "#define HAVE_GMTIME_R 1" >>confdefs.h ;; localtime_r) $as_echo "#define HAVE_LOCALTIME_R 1" >>confdefs.h ;; strerror_r) $as_echo "#define HAVE_STRERROR_R 1" >>confdefs.h ;; nanosleep) $as_echo "#define HAVE_NANOSLEEP 1" >>confdefs.h ;; clock_nanosleep) $as_echo "#define HAVE_CLOCK_NANOSLEEP 1" >>confdefs.h ;; clock_gettime) $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h ;; posix_fadvise) $as_echo "#define HAVE_POSIX_FADVISE 1" >>confdefs.h ;; ftruncate) $as_echo "#define HAVE_FTRUNCATE 1" >>confdefs.h ;; pwrite) $as_echo "#define HAVE_PWRITE 1" >>confdefs.h ;; setlocale) $as_echo "#define HAVE_SETLOCALE 1" >>confdefs.h ;; gettext) $as_echo "#define HAVE_GETTEXT 1" >>confdefs.h have_gettext="yes" ;; execvp) $as_echo "#define HAVE_EXECVP 1" >>confdefs.h ;; symlink) $as_echo "#define HAVE_SYMLINK 1" >>confdefs.h ;; readlink) $as_echo "#define HAVE_READLINK 1" >>confdefs.h ;; waitpid) $as_echo "#define HAVE_WAITPID 1" >>confdefs.h ;; wait4) $as_echo "#define HAVE_WAIT4 1" >>confdefs.h ;; esac done UCOMMON_LINKED="$socket_lib $posix4_lib $rt_lib $UCOMMON_LIBS" UCOMMON_LIBS="$socket_lib $posix4_lib $rt_lib $UCOMMON_LIBS $UCOMMON_LIBC" if test "$UCOMMON_MODEL" = "CC" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lSystemstubs" >&5 $as_echo_n "checking for printf in -lSystemstubs... " >&6; } if ${ac_cv_lib_Systemstubs_printf+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lSystemstubs $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 printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Systemstubs_printf=yes else ac_cv_lib_Systemstubs_printf=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_Systemstubs_printf" >&5 $as_echo "$ac_cv_lib_Systemstubs_printf" >&6; } if test "x$ac_cv_lib_Systemstubs_printf" = xyes; then : UCOMMON_CLINK="$UCOMMON_CLINK -lSystemstubs" UCOMMON_LIBC="$UCOMMON_LIBC -lgcc" fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu COMPILER_FLAGS="" if test "x$GCC" = "xyes" ; then UCOMMON_FLAGS="$UCOMMON_FLAGS -Wno-long-long" ; fi for flag in $CXXFLAGS ; do case "$flag" in -f*exceptions|-f*rtti|-f*check-new|-f*enforce-eh-specs|-finline|-f*except) if test "$UCOMMON_MODEL" = "CXX" ; then UCOMMON_FLAGS="$UCOMMON_FLAGS $flag" ; fi ;; -fvisibility=*) VISIBLE_FLAGS="" COMPILER_FLAGS="$COMPILER_FLAGS $flag" ;; *) COMPILER_FLAGS="$COMPILER_FLAGS $flag" ;; esac done export CXXFLAGS="$COMPILER_FLAGS" if test "$UCOMMON_MODEL" = "CC" ; then UCOMMON_FLAGS="$UCOMMON_FLAGS" if test x"$GCC" = "xyes" ; then ucflags="-fno-exceptions -fno-rtti -fno-enforce-eh-specs" lcflags="-nodefaultlibs -nostdinc++" else ucflags="-library=no%Cstd -features=no%except -features=namespace -features=no%rtti" lcflags="" fi for flag in $ucflags ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports $flag" >&5 $as_echo_n "checking whether ${CXX} supports $flag... " >&6; } echo 'void f(){}' >conftest.cpp if test -z "`${CXX} $flag -c conftest.cpp 2>&1`"; then UCOMMON_FLAGS="$UCOMMON_FLAGS $flag" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "$flag" = "-library=no%Cstd" ; then UCOMMON_MODEL="CXX" ; fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* done for flag in $lcflags ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports $flag" >&5 $as_echo_n "checking whether ${CXX} supports $flag... " >&6; } echo 'void f(){}' >conftest.cpp if test -z "`${CXX} $flag -c conftest.cpp 2>&1`"; then UCOMMON_CLINK="$UCOMMON_CLINK $flag" { $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 rm -f conftest* done else ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu for ac_header in stdexcept do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdexcept" "ac_cv_header_stdexcept" "$ac_includes_default" if test "x$ac_cv_header_stdexcept" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDEXCEPT 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for old style iostream" >&5 $as_echo_n "checking for old style iostream... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include using namespace std; class mystr : public streambuf, public iostream { mystr(); }; mystr::mystr() : streambuf(), iostream((streambuf *)this) { } int main () { return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } UCOMMON_FLAGS="$UCOMMON_FLAGS -DNEW_STDCPP" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } UCOMMON_FLAGS="$UCOMMON_FLAGS -DOLD_STDCPP" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXXFLAGS="$ac_save_CXXFLAGS" fi if test ! -z "$PTHREAD_FLAGS" ; then for flag in $PTHREAD_FLAGS ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports $flag" >&5 $as_echo_n "checking whether ${CXX} supports $flag... " >&6; } echo 'void f(){}' >conftest.cpp if test -z "`${CXX} $flag -c conftest.cpp 2>&1`"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } UCOMMON_FLAGS="$UCOMMON_FLAGS $flag" break else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi done fi export CXXFLAGS # libstdc++ on some targets broken badly if inlines hidden. Might be # deeper issue with ansi c++ library model... flags="-fno-check-new -finline" if test "$UCOMMON_MODEL" = "CC" ; then if test "$enable_shared" != "no" ; then flags="$flags -fvisibility-inlines-hidden" fi fi for flag in $flags ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports $flag" >&5 $as_echo_n "checking whether ${CXX} supports $flag... " >&6; } echo 'void f(){}' >conftest.cpp if test -z "`${CXX} $flag -c conftest.cpp 2>&1`"; then UCOMMON_FLAGS="$UCOMMON_FLAGS $flag" { $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 rm -f conftest* done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports visibility" >&5 $as_echo_n "checking whether ${CXX} supports visibility... " >&6; } echo 'void f(){}' >conftest.cpp if test -z "`${CXX} -fvisibility=hidden -c conftest.cpp 2>&1`"; then UCOMMON_FLAGS="$UCOMMON_FLAGS -fvisibility=hidden -DUCOMMON_VISIBILITY=1" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } UCOMMON_VISIBILITY="1" else UCOMMON_FLAGS="$UCOMMON_FLAGS -DUCOMMON_VISIBILITY=0" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* 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 includes="$includedir" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$includes")` includes=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$includes"\" )` result=`(echo "$includes")` done libs="$libdir" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$libs")` libs=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$libs"\" )` result=`(echo "$libs")` done case "$libs" in /usr/*) ;; *) UCOMMON_LINKED="-L$libs $UCOMMON_LINKED" ;; esac case "$includes" in /usr/*) ;; *) UCOMMON_FLAGS="$UCOMMON_FLAGS -I$includes" ;; esac case "$target_os" in *bsd*) if test "$UCOMMON_MODEL" = "CC" ; then if test "$GCC" = "yes" -a "$UCOMMON_LIBC" = "-lc" ; then UCOMMON_LIBC="-Wl,-lc" elif test "$GCC" = "yes" -a "$UCOMMON_LIBC" = "-lc_r" ; then UCOMMON_LIBC="-Wl,-lc_r" fi fi ;; osf*) UCOMMON_FLAGS="$UCOMMON_FLAGS -D_POSIX_C_SOURCE=1 -D_OSF_SOURCE=1 -D__USE_STD_IOSTREAM" ;; cygwin*|mingw*) UCOMMON_LINKED="$UCOMMON_LINKED -no-undefined" UCOMMON_LIBS="$UCOMMON_LIBS -no-undefined" ;; esac UCOMMON_CLINK="$UCOMMON_CLINK $UCOMMON_LIBC" if test -z "$UCOMMON_SSLSTACK" ; then UCOMMON_SSLSTACK="$sslstack" ; fi OPENSSL_LIBS="" GNUTLS_LIBS="" if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}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 ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) 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_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 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. 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 ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) 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_path_ac_pt_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 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" 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 PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; 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" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi # Check whether --with-pkg-config was given. if test "${with_pkg_config+set}" = set; then : withval=$with_pkg_config; pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5 $as_echo_n "checking for OPENSSL... " >&6; } if test -n "$OPENSSL_CFLAGS"; then pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl >= \$OPENSSL_REQUIRES\""; } >&5 ($PKG_CONFIG --exists --print-errors "openssl >= $OPENSSL_REQUIRES") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl >= $OPENSSL_REQUIRES" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$OPENSSL_LIBS"; then pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl >= \$OPENSSL_REQUIRES\""; } >&5 ($PKG_CONFIG --exists --print-errors "openssl >= $OPENSSL_REQUIRES") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl >= $OPENSSL_REQUIRES" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl >= $OPENSSL_REQUIRES" 2>&1` else OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl >= $OPENSSL_REQUIRES" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$OPENSSL_PKG_ERRORS" >&5 OPENSSL_LIBS="" for ac_header in openssl/ssl.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_SSL_H 1 _ACEOF OPENSSL_LIBS="-lssl -lcrypto -lz $OPENSSL_LINK" fi done for ac_header in openssl/fips.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/fips.h" "ac_cv_header_openssl_fips_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_fips_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_FIPS_H 1 _ACEOF fi done elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } OPENSSL_LIBS="" for ac_header in openssl/ssl.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_SSL_H 1 _ACEOF OPENSSL_LIBS="-lssl -lcrypto -lz $OPENSSL_LINK" fi done for ac_header in openssl/fips.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/fips.h" "ac_cv_header_openssl_fips_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_fips_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_FIPS_H 1 _ACEOF fi done else OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNUTLS" >&5 $as_echo_n "checking for GNUTLS... " >&6; } if test -n "$GNUTLS_CFLAGS"; then pkg_cv_GNUTLS_CFLAGS="$GNUTLS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls >= 2.8.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls >= 2.8.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GNUTLS_CFLAGS=`$PKG_CONFIG --cflags "gnutls >= 2.8.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GNUTLS_LIBS"; then pkg_cv_GNUTLS_LIBS="$GNUTLS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls >= 2.8.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls >= 2.8.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GNUTLS_LIBS=`$PKG_CONFIG --libs "gnutls >= 2.8.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GNUTLS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnutls >= 2.8.0" 2>&1` else GNUTLS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnutls >= 2.8.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GNUTLS_PKG_ERRORS" >&5 GNUTLS_LIBS="" elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } GNUTLS_LIBS="" else GNUTLS_CFLAGS=$pkg_cv_GNUTLS_CFLAGS GNUTLS_LIBS=$pkg_cv_GNUTLS_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi else for ac_header in openssl/ssl.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_SSL_H 1 _ACEOF OPENSSL_LIBS="-lssl -lcrypto -lz $OPENSSL_LINK" fi done for ac_header in openssl/fips.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/fips.h" "ac_cv_header_openssl_fips_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_fips_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_FIPS_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gnutls_init in -lgnutls" >&5 $as_echo_n "checking for gnutls_init in -lgnutls... " >&6; } if ${ac_cv_lib_gnutls_gnutls_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgnutls $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 gnutls_init (); int main () { return gnutls_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_gnutls_gnutls_init=yes else ac_cv_lib_gnutls_gnutls_init=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_gnutls_gnutls_init" >&5 $as_echo "$ac_cv_lib_gnutls_gnutls_init" >&6; } if test "x$ac_cv_lib_gnutls_gnutls_init" = xyes; then : GNUTLS_LIBS="-lgnutls" fi fi SECURE="" case "$ssl" in secure|any|detect) if test ! -z "$GNUTLS_LIBS" ; then SECURE_LIBS="$GNUTLS_LIBS" SECURE="gnutls" fi if test -z "$SECURE" ; then if test ! -z "$OPENSSL_LIBS" ; then SECURE_LIBS="$OPENSSL_LIBS" SECURE="openssl" fi fi ;; gnutls|gnu) if test ! -z "$GNUTLS_LIBS" ; then SECURE_LIBS="$GNUTLS_LIBS" SECURE="gnutls" fi ;; openssl|ssl) if test ! -z "$OPENSSL_LIBS" ; then SECURE_LIBS="$OPENSSL_LIBS" SECURE="openssl" fi ;; esac if test -z "$SECURE" ; then SECURE_LIBS="" SECURE="nossl" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking secure library mode" >&5 $as_echo_n "checking secure library mode... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SECURE" >&5 $as_echo "$SECURE" >&6; } SECURE_LOCAL="../$SECURE/libusecure.la $SECURE_LIBS" LT_GENERIC="${LIBTOOL}" if test "$UCOMMON_MODEL" = "CC" ; then LIBTOOL='$(SHELL) $(top_srcdir)/cmodel.sh'" ${LIBTOOL}" ; fi includes='${includedir}/ucommon' if test "$sysconfdir" = '${prefix}/etc' ; then sysconfdir="/etc" ; fi if test "$localstatedir" = '${prefix}/var' ; then localstatedir="/var" ; fi ac_fn_c_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default" if test "x$ac_cv_header_libintl_h" = xyes; then : $as_echo "#define HAVE_LIBINTL_H 1" >>confdefs.h if test "$have_gettext" = "no" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettext in -lintl" >&5 $as_echo_n "checking for gettext in -lintl... " >&6; } if ${ac_cv_lib_intl_gettext+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $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 gettext (); int main () { return gettext (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_gettext=yes else ac_cv_lib_intl_gettext=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_intl_gettext" >&5 $as_echo "$ac_cv_lib_intl_gettext" >&6; } if test "x$ac_cv_lib_intl_gettext" = xyes; then : $as_echo "#define HAVE_GETTEXT 1" >>confdefs.h UCOMMON_LIBS="$UCOMMON_LIBS -lintl" fi fi fi if test "$prefix" = "NONE" ; then prefixdir="$ac_default_prefix" else prefixdir="$prefix" ; fi UCOMMON_INCLUDES="$includes" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$UCOMMON_INCLUDES")` UCOMMON_INCLUDES=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$UCOMMON_INCLUDES"\" )` result=`(echo "$UCOMMON_INCLUDES")` done UCOMMON_LOCALE="$localedir" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$UCOMMON_LOCALE")` UCOMMON_LOCALE=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$UCOMMON_LOCALE"\" )` result=`(echo "$UCOMMON_LOCALE")` done UCOMMON_CFGPATH="$sysconfdir" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$UCOMMON_CFGPATH")` UCOMMON_CFGPATH=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$UCOMMON_CFGPATH"\" )` result=`(echo "$UCOMMON_CFGPATH")` done UCOMMON_VARPATH="$localstatedir" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$UCOMMON_VARPATH")` UCOMMON_VARPATH=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$UCOMMON_VARPATH"\" )` result=`(echo "$UCOMMON_VARPATH")` done UCOMMON_PREFIX="$prefixdir" result="***" prior="A" while test "$prior" != "$result" ; do prior=`(echo "$UCOMMON_PREFIX")` UCOMMON_PREFIX=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""$UCOMMON_PREFIX"\" )` result=`(echo "$UCOMMON_PREFIX")` done cat >>confdefs.h <<_ACEOF #define UCOMMON_PREFIX "$UCOMMON_PREFIX" _ACEOF cat >>confdefs.h <<_ACEOF #define UCOMMON_CFGPATH "$UCOMMON_CFGPATH" _ACEOF cat >>confdefs.h <<_ACEOF #define UCOMMON_VARPATH "$UCOMMON_VARPATH" _ACEOF cat >>confdefs.h <<_ACEOF #define UCOMMON_LOCALE "$UCOMMON_LOCALE" _ACEOF # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; 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_path_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else case $DOXYGEN in [\\/]* | ?:[\\/]*) ac_cv_path_DOXYGEN="$DOXYGEN" # Let the user override the test with a path. ;; *) 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_path_DOXYGEN="$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 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_DOXYGEN" && ac_cv_path_DOXYGEN="doxygen" ;; esac fi DOXYGEN=$ac_cv_path_DOXYGEN if test -n "$DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOXYGEN" >&5 $as_echo "$DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ac_config_files="$ac_config_files Makefile corelib/Makefile commoncpp/Makefile openssl/Makefile gnutls/Makefile nossl/Makefile utils/Makefile inc/Makefile inc/ucommon/Makefile inc/commoncpp/Makefile test/Makefile directive commoncpp.pc ucommon.pc ucommon.spec ucommon-config commoncpp-config" 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= 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi : "${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 -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' 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 # 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'" # 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 ucommon $as_me 6.0.7, which was generated by GNU Autoconf 2.69. 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="\\ ucommon config.status 6.0.7 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" 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." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' 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"`' compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $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 \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ reload_flag_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_separator_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; 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 \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX \ postlink_cmds_CXX; 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' AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _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 "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "ucommon-config.h") CONFIG_HEADERS="$CONFIG_HEADERS ucommon-config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "corelib/Makefile") CONFIG_FILES="$CONFIG_FILES corelib/Makefile" ;; "commoncpp/Makefile") CONFIG_FILES="$CONFIG_FILES commoncpp/Makefile" ;; "openssl/Makefile") CONFIG_FILES="$CONFIG_FILES openssl/Makefile" ;; "gnutls/Makefile") CONFIG_FILES="$CONFIG_FILES gnutls/Makefile" ;; "nossl/Makefile") CONFIG_FILES="$CONFIG_FILES nossl/Makefile" ;; "utils/Makefile") CONFIG_FILES="$CONFIG_FILES utils/Makefile" ;; "inc/Makefile") CONFIG_FILES="$CONFIG_FILES inc/Makefile" ;; "inc/ucommon/Makefile") CONFIG_FILES="$CONFIG_FILES inc/ucommon/Makefile" ;; "inc/commoncpp/Makefile") CONFIG_FILES="$CONFIG_FILES inc/commoncpp/Makefile" ;; "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; "directive") CONFIG_FILES="$CONFIG_FILES directive" ;; "commoncpp.pc") CONFIG_FILES="$CONFIG_FILES commoncpp.pc" ;; "ucommon.pc") CONFIG_FILES="$CONFIG_FILES ucommon.pc" ;; "ucommon.spec") CONFIG_FILES="$CONFIG_FILES ucommon.spec" ;; "ucommon-config") CONFIG_FILES="$CONFIG_FILES ucommon-config" ;; "commoncpp-config") CONFIG_FILES="$CONFIG_FILES commoncpp-config" ;; *) 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 ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; 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 s&@MKDIR_P@&$ac_MKDIR_P&;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 # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :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="CXX " # ### 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 # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### 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" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # How to create reloadable object files. reload_flag=$lt_reload_flag_CXX reload_cmds=$lt_reload_cmds_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # 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_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # 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_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # 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_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; 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 ucommon-6.0.7/ucommon.spec.cmake0000644000175000017500000001100412163025062013523 00000000000000# Copyright (c) 2008, 2009 David Sugar, Tycho Softworks. # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. Name: ucommon Summary: Portable C++ runtime for threads and sockets Version: @VERSION@ Release: 0%{?dist} License: LGPLv3+ URL: http://www.gnu.org/software/commoncpp Source0: http://www.gnutelephony.org/dist/tarballs/ucommon-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: doxygen graphviz-gd openssl-devel Group: System Environment/Libraries Summary: Runtime library for portable C++ threading and sockets %description GNU uCommon C++ is a lightweight library to facilitate using C++ design patterns even for very deeply embedded applications, such as for systems using uClibc along with POSIX threading support. For this reason, uCommon disables language features that consume memory or introduce runtime overhead. uCommon introduces some design patterns from Objective-C, such as reference counted objects, memory pools, and smart pointers. uCommon introduces some new concepts for handling of thread locking and synchronization. %package bin Requires: %{name} = %{version}-%{release} Group: Applications/System Summary: ucommon system and support applications. %package devel Requires: %{name} = %{version}-%{release} Requires: %{name}-bin = %{version}-%{release} Requires: openssl-devel Requires: pkgconfig Group: Development/Libraries Summary: Headers for building ucommon applications %package doc Group: Documentation Summary: Generated class documentation for ucommon %description bin This is a collection of command line tools that use various aspects of the ucommon library. Some may be needed to prepare files or for development of applications. %description devel This package provides header and support files needed for building applications that use the uCommon library and frameworks. %description doc Generated class documentation for GNU uCommon library from header files, html browsable. %prep %setup -q %build %{__rm} -rf build %{__mkdir} build cd build cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DSYSCONFDIR=%{_sysconfdir} \ -DMANDIR=%{_mandir} \ -DCMAKE_VERBOSE_MAKEFILE=TRUE \ -DCMAKE_C_FLAGS_RELEASE:STRING="$RPM_OPT_FLAGS" \ -DCMAKE_CXX_FLAGS_RELEASE:STRING="$RPM_OPT_FLAGS" \ .. %{__make} %{?_smp_mflags} %install cd build %{__rm} -rf %{buildroot} make install DESTDIR=%{buildroot} %{__chmod} 0755 %{buildroot}%{_bindir}/ucommon-config %{__chmod} 0755 %{buildroot}%{_bindir}/commoncpp-config %{__rm} -rf %{buildroot}%{_libdir}/*.la %clean %{__rm} -rf %{buildroot} %files %defattr(-,root,root,-) %doc AUTHORS README COPYING COPYING.LESSER COPYRIGHT NEWS SUPPORT ChangeLog %{_libdir}/libucommon.so.* %{_libdir}/libusecure.so.* %{_libdir}/libcommoncpp.so.* %files bin %defattr(-,root,root,-) %{_bindir}/args %{_bindir}/car %{_bindir}/scrub-files %{_bindir}/mdsum %{_bindir}/sockaddr %{_bindir}/zerofill %{_mandir}/man1/args.* %{_mandir}/man1/car.* %{_mandir}/man1/scrub-files.* %{_mandir}/man1/mdsum.* %{_mandir}/man1/sockaddr.* %{_mandir}/man1/zerofill.* %files devel %defattr(-,root,root,-) %{_libdir}/*.so %{_includedir}/ucommon/ %{_includedir}/commoncpp/ %{_libdir}/pkgconfig/*.pc %{_bindir}/ucommon-config %{_bindir}/commoncpp-config # %{_mandir}/man1/ucommon-config.* %files doc %defattr(-,root,root,-) # %doc doc/html/* %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %changelog * Sat Sep 18 2010 - David Sugar - 3.4.0-0 - simplified packaging and better runtime focus. - ccscript moved to bayonne, ccaudio detached. * Sun Aug 01 2010 - David Sugar - 3.3.0-0 - internationalization bindings with gnu gettext support. - reorganized utils into ucommon-bin subpackage. * Fri Jun 04 2010 - David Sugar - 3.0.0-0 - merged ccscript and ccaudio with ucommon to create single framework. * Sun Jul 19 2009 - David Sugar - 2.0.6-1 - fixed ucommon-config upstream. * Tue May 05 2009 - David Sugar - 2.0.5-4 - removed static libraries, fixed other build issues (#498736) * Sun May 03 2009 - David Sugar - 2.0.5-3 - spec file prepared for redhat/fedora (#498736) ucommon-6.0.7/inc/0000755000175000017500000000000012175176705010766 500000000000000ucommon-6.0.7/inc/commoncpp/0000755000175000017500000000000012175176706012762 500000000000000ucommon-6.0.7/inc/commoncpp/numbers.h0000644000175000017500000000731312163025062014513 00000000000000#ifndef COMMONCPP_NUMBERS_H_ #define COMMONCPP_NUMBERS_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif typedef ucommon::DateTimeString DateTimeString; typedef ucommon::DateNumber DateNumber; class __EXPORT Date : public ucommon::Date { protected: inline void toJulian(long year, long month, long day) {ucommon::Date::set(year, month, day);} inline void fromJulian(char *buf) const {put(buf);} public: inline Date(time_t value) : ucommon::Date(value) {}; inline Date(struct tm *object) : ucommon::Date(object) {}; inline Date(const char *ptr, size_t size = 0) : ucommon::Date(ptr, size) {}; inline Date(int y, unsigned m, unsigned d) : ucommon::Date(y, m, d) {}; inline Date(const Date& object) : ucommon::Date(object) {}; inline Date() : ucommon::Date() {}; inline int getYear(void) const {return year();} inline unsigned getMonth(void) const {return month();} inline unsigned getDay(void) const {return day();} inline unsigned getDayOfWeek(void) const {return dow();} inline long getJulian(void) const {return julian;} inline const char *get(char *buffer) const {return put(buffer);} inline time_t getTime(void) const {return timeref();} inline bool isValid(void) const {return is_valid();} }; class __EXPORT Time : public ucommon::Time { protected: inline void toSeconds(int h, int m = 0, int s = 0) {set(h, m, s);} inline void fromSeconds(char *buf) const {put(buf);} public: inline Time(time_t value) : ucommon::Time(value) {}; inline Time(tm_t *object) : ucommon::Time(object) {}; inline Time(const char *ptr, size_t size) : ucommon::Time(ptr, size) {}; inline Time(int h, int m, int s) : ucommon::Time(h, m, s) {}; inline Time() : ucommon::Time() {}; inline int getHour(void) const {return hour();} inline int getMinute(void) const {return minute();} inline int getSecond(void) const {return second();} inline const char *get(char *buffer) const {return put(buffer);} inline bool isValid(void) const {return is_valid();} }; class __EXPORT DateTime : public ucommon::DateTime { public: inline DateTime(time_t time) : ucommon::DateTime(time) {}; inline DateTime(struct tm *dt) : ucommon::DateTime(dt) {}; inline DateTime(int year, unsigned month, unsigned day, int hour = 0, int minute = 0, int second = 0) : ucommon::DateTime(year, month, day, hour, minute, second) {}; inline DateTime(const char *ptr, size_t size) : ucommon::DateTime(ptr, size) {}; inline DateTime(const DateTime& obj) : ucommon::DateTime(obj) {}; inline DateTime() : ucommon::DateTime() {}; inline int getYear(void) const {return year();} inline unsigned getMonth(void) const {return month();} inline unsigned getDay(void) const {return day();} inline unsigned getDayOfWeek(void) const {return dow();} inline long getJulian(void) const {return julian;} inline const char *get(char *buffer) const {return ucommon::DateTime::put(buffer);} inline time_t getTime(void) const {return ucommon::DateTime::timeref();} inline bool isValid(void) const {return ucommon::DateTime::is_valid();} inline int getHour(void) const {return hour();} inline int getMinute(void) const {return minute();} inline int getSecond(void) const {return second();} inline static tm_t *glt(time_t *time = NULL) {return ucommon::DateTime::local(time);} }; #endif ucommon-6.0.7/inc/commoncpp/tokenizer.h0000644000175000017500000002635112163025062015055 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file tokenizer.h * @short string tokenizer. **/ #ifndef COMMONCPP_TOKENIZER_H_ #define COMMONCPP_TOKENIZER_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_THREAD_H_ #include #endif #ifndef COMMMONCPP_EXCEPTION_H_ #include #endif NAMESPACE_COMMONCPP /** * Splits delimited string into tokens. * * The StringTokenizer takes a pointer to a string and a pointer * to a string containing a number of possible delimiters. * The StringTokenizer provides an input forward iterator which allows * to iterate through all tokens. An iterator behaves like a logical * pointer to the tokens, i.e. to shift to the next token, you've * to increment the iterator, you get the token by dereferencing the * iterator. * * Memory consumption: * This class operates on the original string and only allocates memory * for the individual tokens actually requested, so this class * allocates at maximum the space required for the longest token in the * given string. * Since for each iteration, memory is reclaimed for the last token, * you MAY NOT store pointers to them; if you need them afterwards, * copy them. You may not modify the original string while you operate * on it with the StringTokenizer; the behaviour is undefined in that * case. * * The iterator has one special method 'nextDelimiter()' which returns * a character containing the next delimiter following this * tokenization process or '\\0', if there are no following delimiters. In * case of skipAllDelim, it returns the FIRST delimiter. * * With the method 'setDelimiters(const char*)' you may change the * set of delimiters. It affects all running iterators. * * Example: *
 *  StringTokenizer st("mary had a little lamb;its fleece was..", " ;");
 *  StringTokenizer::iterator i;
 *  for (i = st.begin() ; i != st.end() ; ++i) {
 *        cout << "Token: '" << *i << "'\t";
 *        cout << " next Delim: '" << i.nextDelimiter() << "'" << endl;
 *  }
 *  
* * @author Henner Zeller * @license LGPL */ class __EXPORT StringTokenizer { public: /** * a delimiter string containing all usual whitespace delimiters. * These are space, tab, newline, carriage return, * formfeed and vertical tab. (see isspace() manpage). */ static const char * const SPACE; /** * Exception thrown, if someone tried to read beyond the * end of the tokens. * Will not happen if you use it the 'clean' way with comparison * against end(), but if you skip some tokens, because you 'know' * they are there. Simplifies error handling a lot, since you can * just read your tokens the way you expect it, and if there is some * error in the input this Exception will be thrown. */ // maybe move more global ? class NoSuchElementException { }; /** * The input forward iterator for tokens. * @author Henner Zeller */ class __EXPORT iterator { friend class StringTokenizer; // access our private constructors private: const StringTokenizer *myTok; // my StringTokenizer const char *start; // start of current token const char *tokEnd; // end of current token (->nxDelimiter) const char *endp; // one before next token char *token; // allocated token, if requested // for initialization of the itEnd iterator iterator(const StringTokenizer &tok, const char *end) : myTok(&tok),tokEnd(0),endp(end),token(0) {} iterator(const StringTokenizer &tok) : myTok(&tok),tokEnd(0),endp(myTok->str-1),token(0) { ++(*this); // init first token. } public: iterator() : myTok(0),start(0),tokEnd(0),endp(0),token(0) {} // see also: comment in implementation of operator++ virtual ~iterator() { if (token) *token='\0'; delete [] token; } /** * copy constructor. */ // everything, but not responsible for the allocated token. iterator(const iterator& i) : myTok(i.myTok),start(i.start),tokEnd(i.tokEnd), endp(i.endp),token(0) {} /** * assignment operator. */ // everything, but not responsible for the allocated token. iterator &operator = (const iterator &i) { myTok = i.myTok; start = i.start; endp = i.endp; tokEnd = i.tokEnd; if ( token ) delete [] token; token = 0; return *this; } /** * shifts this iterator to the next token in the string. */ iterator &operator ++ () THROWS (NoSuchElementException); /** * returns the immutable string this iterator * points to or '0' if no token is available (i.e. * i == end()). * Do not store pointers to this token, since it is * invalidated for each iteration. If you need the token, * copy it (e.g. with strdup()); */ const char* operator * () THROWS (NoSuchElementException); /** * returns the next delimiter after the current token or * '\\0', if there are no following delimiters. * It returns the very next delimiter (even if * skipAllDelim=true). */ inline char nextDelimiter() const {return (tokEnd) ? *tokEnd : '\0';} /** * compares to other iterator. Usually used to * compare against the end() iterator. */ // only compare the end-position. speed. inline bool operator == (const iterator &other) const {return (endp == other.endp);} /** * compares to other iterator. Usually used to * compare against the end() iterator. */ // only compare the end position. speed. inline bool operator != (const iterator &other) const {return (endp != other.endp);} }; private: friend class StringTokenizer::iterator; const char *str; const char *delim; bool skipAll, trim; iterator itEnd; public: /** * creates a new StringTokenizer for a string * and a given set of delimiters. * * @param str String to be split up. This string will * not be modified by this StringTokenizer, * but you may as well not modfiy this string * while tokenizing is in process, which may * lead to undefined behaviour. * * @param delim String containing the characters * which should be regarded as delimiters. * * @param skipAllDelim OPTIONAL. * true, if subsequent * delimiters should be skipped at once * or false, if empty tokens should * be returned for two delimiters with * no other text inbetween. The first * behaviour may be desirable for whitespace * skipping, the second for input with * delimited entry e.g. /etc/passwd like files * or CSV input. * NOTE, that 'true' here resembles the * ANSI-C strtok(char *s,char *d) behaviour. * DEFAULT = false * * @param trim OPTIONAL. * true, if the tokens returned * should be trimmed, so that they don't have * any whitespaces at the beginning or end. * Whitespaces are any of the characters * defined in StringTokenizer::SPACE. * If delim itself is StringTokenizer::SPACE, * this will result in a behaviour with * skipAllDelim = true. * DEFAULT = false */ StringTokenizer (const char *str, const char *delim, bool skipAllDelim = false, bool trim = false); /** * create a new StringTokenizer which splits the input * string at whitespaces. The tokens are stripped from * whitespaces. This means, if you change the set of * delimiters in either the 'begin(const char *delim)' method * or in 'setDelimiters()', you then get whitespace * trimmed tokens, delimited by the new set. * Behaves like StringTokenizer(s, StringTokenizer::SPACE,false,true); */ StringTokenizer (const char *s); /** * returns the begin iterator */ iterator begin() const {return iterator(*this);} /** * changes the set of delimiters used in subsequent * iterations. */ void setDelimiters (const char *d) {delim = d;} /** * returns a begin iterator with an alternate set of * delimiters. */ iterator begin(const char *d) { delim = d; return iterator(*this); } /** * the iterator marking the end. */ const iterator& end() const {return itEnd;} }; END_NAMESPACE #endif /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 4 * End: */ ucommon-6.0.7/inc/commoncpp/dccp.h0000644000175000017500000001664112163025062013755 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/udp.h * @short udp derived socket classes. **/ #ifndef COMMONCPP_DCCP_H_ #define COMMONCPP_DCCP_H_ #include #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif #ifndef COMMONCPP_ADDRESS_H_ #include #endif #ifndef COMMONCPP_SOCKET_H_ #include #endif NAMESPACE_COMMONCPP /** * DCCP sockets are used for stream based connected sessions between two * sockets. Both error recovery and flow control operate transparently * for a DCCP socket connection. The DCCP socket base class is used both * for client connections and to bind a DCCP "server" for accepting DCCP * streams. * * An implicit and unique DCCPSocket object exists in Common C++ to represent * a bound DCCP socket acting as a "server" for receiving connection requests. * This class is not part of DCCPStream because such objects normally perform * no physical I/O (read or write operations) other than to specify a listen * backlog queue and perform "accept" operations for pending connections. * The Common C++ DCCPSocket offers a Peek method to examine where the next * pending connection is coming from, and a Reject method to flush the next * request from the queue without having to create a session. * * The DCCPSocket also supports a "OnAccept" method which can be called when a * DCCPStream related object is created from a DCCPSocket. By creating a * DCCPStream from a DCCPSocket, an accept operation automatically occurs, and * the DCCPSocket can then still reject the client connection through the * return status of it's OnAccept method. * * @author Leandro Sales * @author Heverton Stuart * @short bound server for DCCP streams and sessions. */ class __EXPORT DCCPSocket : public Socket { union { struct sockaddr_in ipv4; #ifdef CCXX_IPV6 struct sockaddr_in6 ipv6; #endif } peer; Family family; public: /** * A method to call in a derived DCCPSocket class that is acting * as a server when a connection request is being accepted. The * server can implement protocol specific rules to exclude the * remote socket from being accepted by returning false. The * Peek method can also be used for this purpose. * * @return true if client should be accepted. * @param ia internet host address of the client. * @param port number of the client. */ virtual bool onAccept(const IPV4Host &ia, tpport_t port); #ifdef CCXX_IPV6 virtual bool onAccept(const IPV6Host &ia, tpport_t port); #endif virtual IPV4Host getIPV4Sender(tpport_t *port = NULL) const; #ifdef CCXX_IPV6 virtual IPV6Host getIPV6Sender(tpport_t *port = NULL) const; #endif /** * A DCCP "server" is created as a DCCP socket that is bound * to a hardware address and port number on the local machine * and that has a backlog queue to listen for remote connection * requests. If the server cannot be created, an exception is * thrown. * * @param bind local ip address or interface to use. * @param port number to bind socket under. * @param backlog size of connection request queue. */ DCCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog = 5); #ifdef CCXX_IPV6 DCCPSocket(const IPV6Address &bind, tpport_t port, unsigned backlog = 5); #endif /** * Create a named dccp socket by service and/or interface id. * For IPV4 we use [host:]svc or [host/]svc for the string. * If we have getaddrinfo, we use that to obtain the addr to * bind for. * * @param name of host interface and service port to bind. * @param backlog size of connection request queue. */ DCCPSocket(const char *name, Family family = IPV4, unsigned backlog = 5); /** * Create an unconnected ephemeral DCCP client socket. */ DCCPSocket(Family family = IPV4); /** * Create a server session by accepting a DCCP Socket. */ DCCPSocket(DCCPSocket& server, timeout_t timeout = 0); /** * Used to reject the next incoming connection request. */ void reject(void); /** * Disconnect active dccp connection (client use). */ void disconnect(void); /** * Set CCID DCCP. */ bool setCCID(uint8_t ccid); /** * Get TX CCID DCCP. */ int getTxCCID(); /** * Get RX CCID DCCP. */ int getRxCCID(); /** * Return number of bytes to be read */ size_t available(); /** * Create a DCCP client connection to a DCCP socket (on * a remote machine). * * @param host address of remote DCCP server. * @param port number to connect. */ void connect(const IPV4Host &host, tpport_t port, timeout_t timeout = 0); #ifdef CCXX_IPV6 void connect(const IPV6Host &host, tpport_t port, timeout_t timeout = 0); #endif /** * Connect to a named client. */ void connect(const char *name); /** * Used to wait for pending connection requests. * @return true if data packets available. * @param timeout in milliseconds. TIMEOUT_INF if not specified. */ inline bool isPendingConnection(timeout_t timeout = TIMEOUT_INF) /* not const -- jfc */ {return Socket::isPending(Socket::pendingInput, timeout);} /** * Use base socket handler for ending this socket. */ virtual ~DCCPSocket(); }; END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/socket.h0000644000175000017500000004406612163025062014336 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/socket.h * @short socket operations. **/ #ifndef COMMONCPP_SOCKET_H_ #define COMMONCPP_SOCKET_H_ #include #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif #ifndef COMMONCPP_ADDRESS_H_ #include #endif #ifndef COMMONCPP_EXCEPTION_H_ #include #endif #ifndef MSG_DONTWAIT #define MSG_DONTWAIT 0 #endif #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif #ifndef SOCK_DCCP #define SOCK_DCCP 6 #endif #ifndef IPPROTO_DCCP #define IPPROTO_DCCP 33 #endif #ifndef SOL_DCCP #define SOL_DCCP 269 #endif #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12 #define DCCP_SOCKOPT_CCID 13 #define DCCP_SOCKOPT_TX_CCID 14 #define DCCP_SOCKOPT_RX_CCID 15 NAMESPACE_COMMONCPP typedef socket_t SOCKET; class __EXPORT Socket : protected ucommon::Socket { public: enum State { INITIAL, AVAILABLE, BOUND, CONNECTED, CONNECTING, STREAM }; typedef enum State State; enum Family { #ifdef CCXX_IPV6 IPV6 = AF_INET6, #endif IPV4 = AF_INET }; typedef enum Family Family; enum Error { errSuccess = 0, errCreateFailed, errCopyFailed, errInput, errInputInterrupt, errResourceFailure, errOutput, errOutputInterrupt, errNotConnected, errConnectRefused, errConnectRejected, errConnectTimeout, errConnectFailed, errConnectInvalid, errConnectBusy, errConnectNoRoute, errBindingFailed, errBroadcastDenied, errRoutingDenied, errKeepaliveDenied, errServiceDenied, errServiceUnavailable, errMulticastDisabled, errTimeout, errNoDelay, errExtended, errLookupFail, errSearchErr, errInvalidValue }; typedef enum Error Error; enum Tos { tosLowDelay = 0, tosThroughput, tosReliability, tosMinCost, tosInvalid }; typedef enum Tos Tos; enum Pending { pendingInput, pendingOutput, pendingError }; typedef enum Pending Pending; private: // used by exception handlers.... mutable Error errid; mutable const char *errstr; mutable long syserr; void setSocket(void); protected: static socket_t dupSocket(socket_t s,Socket::State state); static Mutex mutex; mutable struct { bool thrown: 1; bool broadcast: 1; bool route: 1; bool keepalive: 1; bool loopback: 1; bool multicast: 1; bool completion: 1; bool linger: 1; unsigned ttl: 8; } flags; State volatile state; /** * This service is used to throw all socket errors which usually * occur during the socket constructor. * * @param error defined socket error id. * @param err string or message to pass. * @param systemError the system error# that caused the error */ Error error(Error error, const char *err = NULL, long systemError = 0) const; /** * This service is used to throw application defined socket errors * where the application specific error code is a string. * * @param err string or message to pass. */ inline void error(const char *err) const {error(errExtended, err);}; /** * This service is used to turn the error handler on or off for * "throwing" exceptions by manipulating the thrown flag. * * @param enable true to enable handler. */ inline void setError(bool enable) {flags.thrown = !enable;}; /** * Used as the default destructor for ending a socket. This * will cleanly terminate the socket connection. It is provided * for use in derived virtual destructors. */ void endSocket(void); /** * Used as a common handler for connection failure processing. * * @return correct failure code to apply. */ Error connectError(void); /** * Set the send limit. */ Error sendLimit(int limit = 2048); /** * Set thr receive limit. */ Error receiveLimit(int limit = 1); /** * Set the send timeout for sending raw network data. * * @return errSuccess if set. * @param timer value in millisec. */ Error sendTimeout(timeout_t timer); /** * Receive timeout for receiving raw network data. * * @return errSuccess if set. * @param timer value in milliseconds. */ Error receiveTimeout(timeout_t timer); /** * Set the protocol stack network kernel send buffer size * associated with the socket. * * @return errSuccess on success, or error. * @param size of buffer in bytes. */ Error sendBuffer(unsigned size); /** * Set the protocol stack network kernel receive buffer size * associated with the socket. * * @return errSuccess on success, or error. * @param size of buffer in bytes. */ Error receiveBuffer(unsigned size); /** * Set the total protocol stack network kernel buffer size * for both send and receive together. * * @return errSuccess on success * @param size of buffer. */ Error bufferSize(unsigned size); /** * Set the subnet broadcast flag for the socket. This enables * sending to a subnet and may require special image privileges * depending on the operating system. * * @return 0 (errSuccess) on success, else error code. * @param enable when set to true. */ Error setBroadcast(bool enable); /** * Setting multicast binds the multicast interface used for * the socket to the interface the socket itself has been * implicitly bound to. It is also used as a check flag * to make sure multicast is enabled before multicast * operations are used. * * @return 0 (errSuccess) on success, else error code. * @param enable when set to true. * @param family of protocol. */ Error setMulticastByFamily(bool enable, Family family = IPV4); /** * Set the multicast loopback flag for the socket. Loopback * enables a socket to hear what it is sending. * * @return 0 (errSuccess) on success, else error code. * @param enable when set to true. * @param family of protocol. */ Error setLoopbackByFamily(bool enable, Family family = IPV4); /** * Set the multicast time to live for a multicast socket. * * @return 0 (errSuccess) on success, else error code. * @param ttl time to live. * @param fam family of protocol. */ Error setTimeToLiveByFamily(unsigned char ttl, Family fam = IPV4); /** * Join a multicast group. * * @return 0 (errSuccess) on success, else error code. * @param ia address of multicast group to join. */ Error join(const IPV4Multicast &ia); #ifdef CCXX_IPV6 Error join(const IPV6Multicast &ia); #endif /** * Drop membership from a multicast group. * * @return 0 (errSuccess) on success, else error code. * @param ia address of multicast group to drop. */ Error drop(const IPV4Multicast &ia); #ifdef CCXX_IPV6 Error drop(const IPV6Multicast &ia); #endif /** * Set the socket routing to indicate if outgoing messages * should bypass normal routing (set false). * * @return 0 on success. * @param enable normal routing when set to true. */ Error setRouting(bool enable); /** * Enable/disable delaying packets (Nagle algorithm) * * @return 0 on success. * @param enable disable Nagle algorithm when set to true. */ Error setNoDelay(bool enable); /** * An unconnected socket may be created directly on the local * machine. Sockets can occupy both the internet domain (AF_INET) * and UNIX socket domain (AF_UNIX) under unix. The socket type * (SOCK_STREAM, SOCK_DGRAM) and protocol may also be specified. * If the socket cannot be created, an exception is thrown. * * @param domain socket domain to use. * @param type base type and protocol family of the socket. * @param protocol specific protocol to apply. */ Socket(int domain, int type, int protocol = 0); /** * A socket object may be created from a file descriptor when that * descriptor was created either through a socket() or accept() * call. This constructor is mostly for internal use. * * @param fd file descriptor of an already existing socket. */ Socket(socket_t fd); /** * Create an inactive socket object for base constructors. */ Socket(); /** * A socket can also be constructed from an already existing * Socket object. On POSIX systems, the socket file descriptor * is dup()'d. On Win32, DuplicateHandle() is used. * * @param source of existing socket to clone. */ Socket(const Socket &source); /** * Process a logical input line from a socket descriptor * directly. * * @param buf pointer to string. * @param len maximum length to read. * @param timeout for pending data in milliseconds. * @return number of bytes actually read. */ ssize_t readLine(char *buf, size_t len, timeout_t timeout = 0); /** * Read in a block of len bytes with specific separator. Can * be zero, or any other char. If \\n or \\r, it's treated just * like a readLine(). Otherwise it looks for the separator. * * @param buf pointer to byte allocation. * @param len maximum length to read. * @param separator separator for a particular ASCII character * @param t timeout for pending data in milliseconds. * @return number of bytes actually read. */ virtual ssize_t readData(void * buf,size_t len,char separator=0,timeout_t t=0); /** * Write a block of len bytes to socket. * * @param buf pointer to byte allocation. * @param len maximum length to write. * @param t timeout for pending data in milliseconds. * @return number of bytes actually written. */ virtual ssize_t writeData(const void* buf,size_t len,timeout_t t=0); public: ~Socket(); /** * Often used by a "catch" to fetch the last error of a thrown * socket. * * @return error number of Error error. */ inline Error getErrorNumber(void) const {return errid;} /** * Often used by a "catch" to fetch the user set error string * of a thrown socket, but only if EXTENDED error codes are used. * * @return string for error message. */ inline const char *getErrorString(void) const {return errstr;} inline long getSystemError(void) const {return syserr;} const char *getSystemErrorString(void) const; /** * Get the status of pending operations. This can be used to * examine if input or output is waiting, or if an error has * occured on the descriptor. * * @return true if ready, false on timeout. * @param pend ready check to perform. * @param timeout in milliseconds, inf. if not specified. */ virtual bool isPending(Pending pend, timeout_t timeout = TIMEOUT_INF); /** * See if a specific protocol family is available in the * current runtime environment. * * @return true if family available. */ static bool check(Family fam); /** * Operator based testing to see if a socket is currently * active. */ bool operator!() const; operator bool() const; /** * Sockets may also be duplicated by the assignment operator. */ Socket &operator=(const Socket &from); /** * May be used to examine the origin of data waiting in the * socket receive queue. This can tell a TCP server where pending * "connect" requests are coming from, or a UDP socket where it's * next packet arrived from. * * @param port ptr to port number of sender. * @return host address, test with "isInetAddress()". */ virtual IPV4Host getIPV4Sender(tpport_t *port = NULL) const; inline IPV4Host getSender(tpport_t *port = NULL) const {return getIPV4Sender(port);} #ifdef CCXX_IPV6 virtual IPV6Host getIPV6Sender(tpport_t *port = NULL) const; #endif /** * Get the host address and port of the socket this socket * is connected to. If the socket is currently not in a * connected state, then a host address of 0.0.0.0 is * returned. * * @param port ptr to port number of remote socket. * @return host address of remote socket. */ IPV4Host getIPV4Peer(tpport_t *port = NULL) const; inline IPV4Host getPeer(tpport_t *port = NULL) const {return getIPV4Peer(port);} #ifdef CCXX_IPV6 IPV6Host getIPV6Peer(tpport_t *port = NULL) const; #endif /** * Get the local address and port number this socket is * currently bound to. * * @param port ptr to port number on local host. * @return host address of interface this socket is bound to. */ IPV4Host getIPV4Local(tpport_t *port = NULL) const; inline IPV4Host getLocal(tpport_t *port = NULL) const {return getIPV4Local(port);} #ifdef CCXX_IPV6 IPV6Host getIPV6Local(tpport_t *port = NULL) const; #endif /** * Used to specify blocking mode for the socket. A socket * can be made non-blocking by setting setCompletion(false) * or set to block on all access with setCompletion(true). * I do not believe this form of non-blocking socket I/O is supported * in winsock, though it provides an alternate asynchronous set of * socket services. * * @param immediate mode specify socket I/O call blocking mode. */ void setCompletion(bool immediate); /** * Enable lingering sockets on close. * * @param linger specify linger enable. */ Error setLinger(bool linger); /** * Set the keep-alive status of this socket and if keep-alive * messages will be sent. * * @return 0 on success. * @param enable keep alive messages. */ Error setKeepAlive(bool enable); /** * Set packet scheduling on platforms which support ip quality * of service conventions. This effects how packets in the * queue are scheduled through the interface. * * @return 0 on success, error code on failure. * @param service type of service enumerated type. */ Error setTypeOfService(Tos service); /** * Can test to see if this socket is "connected", and hence * whether a "catch" can safely call getPeer(). Of course, * an unconnected socket will return a 0.0.0.0 address from * getPeer() as well. * * @return true when socket is connected to a peer. */ bool isConnected(void) const; /** * Test to see if the socket is at least operating or if it * is mearly initialized. "initialized" sockets may be the * result of failed constructors. * * @return true if not in initial state. */ bool isActive(void) const; /** * Return if broadcast has been enabled for the specified * socket. * * @return true if broadcast socket. */ inline bool isBroadcast(void) const {return flags.broadcast;}; /** * Return if socket routing is enabled. * * @return true if routing enabled. */ inline bool isRouted(void) const {return flags.route;}; inline struct in_addr getaddress(const IPV4Address &ia) {return ia.getAddress();} #ifdef CCXX_IPV6 inline struct in6_addr getaddress(const IPV6Address &ia) {return ia.getAddress();} #endif }; #if defined(CCXX_EXCEPTIONS) class __EXPORT SockException : public IOException { private: Socket::Error _socketError; public: inline SockException(const String &str, Socket::Error socketError, long systemError = 0) : IOException(str, systemError), _socketError(socketError) {}; inline Socket::Error getSocketError() const { return _socketError; } }; #endif END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/applog.h0000644000175000017500000003574212163025062014331 00000000000000// Copyright (C) 2005-2010 Angelo Naselli, Penta Engineering s.r.l. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/applog.h * @short Application logging facilities abstraction. **/ #ifndef COMMONCPP_APPLOG_H_ #define COMMONCPP_APPLOG_H_ #ifndef COMMONCPP_SLOG_H_ #include #endif #ifndef COMMONCPP_EXCEPTION_H_ #include #endif #include #include #include #include NAMESPACE_COMMONCPP using namespace std; /** * Produces a dump of a buffer in a hexdump way with its * code Ascii translation and relative buffer address. * * For instance: * 0000000 - 77 98 21 49 0e 00 05 00 40 1c 01 1c 2f 00 00 00 w.!I....@.../... * */ class __EXPORT HEXdump { protected: /** * output string */ std::string _str; public: // max_len: max number of bytes to be printed. 0 prints all. /** * HEXdump constructor. * * @param buffer buffer to be "hexdumped" * @param buff_len buffer length * @param max_len max number of bytes to be "hexdumped". Usefull to * truncate output. mas_len=0 does prints all. */ HEXdump(const unsigned char *buffer, int buff_len, int max_len = 200); /** * HEXdump destructor. */ virtual ~HEXdump() { _str = string();} /** * const char* cast provided for conveneince. */ const char * c_str() const { return _str.c_str(); } /** * string cast provided for conveneince. */ std::string str() { return _str; } /** * operator << * @param hd hexdump. * @return application logger stream */ friend std::ostream& operator<< (std::ostream& out, const HEXdump &hd) { out << hd.c_str(); return out; } }; #ifdef CCXX_EXCEPTIONS /** * Applog exception, used for memory problems at the moment * */ class __EXPORT AppLogException : public ost::Exception { public: /** * Constructor. * @param what_arg exception string */ AppLogException(String &what_arg) : ost::Exception(what_arg) {}; }; #endif class AppLogPrivate; /** * Application logger is a class that implements a logger that can be used * by applications to save log file somewhere on the system. * * It uses ost::slog to write to syslog and std::clog to write to standard * output. * * It provides either a stream oriented logger or a old printf style one. * * It can be used to log directly on a file or in a spooler like way. Latter * uses a ost::ThreadQueue to implement a thread safe access to logger. * * It provides a global stream variable called ost::alog. * * It provides an AppLog::Ident class that represents a module name for * instance that can be used to tag logs. Logging levels are the same * defined into ost::Slog: * Slog::levelEmergency * Slog::levelAlert * Slog::levelCritical * Slog::levelError * Slog::levelWarning * Slog::levelNotice * Slog::levelInfo * Slog::levelDebugfrom. * * Example of usage: alog << mod_name << debug << "Hello world!" << std::endl; */ class __EXPORT AppLog : protected streambuf, public ostream { protected: // d pointer AppLogPrivate *d; void writeLog(bool endOfLine = true); static std::map *assoc; public: /** * Ident class that represents module name. */ class __EXPORT Ident { private: std::string _ident; public: /** * Constructor. */ Ident() {}; /** * Desctructor. */ ~Ident() {}; /** * Copy constructor. */ Ident(Ident& id) {_ident = id._ident;} /** * const char* constructor, provided for convenience. */ Ident(const char *str) : _ident(str) {}; /** * std::string cast. */ std::string& str() {return _ident;} /** * Assignment operator (string). */ Ident& operator= (std::string &st) {_ident = st; return *this;} /** * Assignment operator (const char[]), provided for convenience. */ Ident& operator= (const char str[]) {_ident = str; return *this;} /** * const char* cast provided for conveneince. */ const char* c_str() {return _ident.c_str();} }; #ifndef _MSWINDOWS_ /** * Constructor for a customized logger. * @param logFileName log file name. * @param logDirectly true to write directly to file, false to use * a spooler like logger. * @param usePipe true to use pipe instead of file, false otherwise */ AppLog(const char* logFileName = NULL, bool logDirectly = false , bool usePipe = false); #else /** * Constructor for a customized logger. * @param logFileName log file name. * @param logDirectly true to write directly to file, false to use * a spooler like logger. */ AppLog(const char* logFileName = NULL, bool logDirectly = false); #endif /** * Destructor */ virtual ~AppLog(); /** * Subscribes the current thread to logger, it reserves thread safe * buffer for it. */ void subscribe(); /** * Unsubscribes the current thread from logger. */ void unsubscribe(); #ifndef _MSWINDOWS_ /** * Allows to set up ost::alog parameters. * @param FileName log file name. * @param logDirectly true to write directly to file, false to use * a spooler like logger. * @param usePipe true to use pipe instead of file, false otherwise */ void logFileName(const char* FileName, bool logDirectly = false, bool usePipe = false); #else /** * Allows to set up ost::alog parameters. * @param FileName log file name. * @param logDirectly true to write directly to file, false to use * a spooler like logger. */ void logFileName(const char* FileName, bool logDirectly = false); #endif /** * if logDirectly is set it closes the file. */ void close(void); /** * Sets the log level. * @param enable log level. */ void level(Slog::Level enable); /** * Enables clog output. * @param en true to enable clog output. */ void clogEnable(bool en = true); /** * Enables slog output for error level messages. * @param en true to enable slog output. */ void slogEnable(bool en = true); /** * Sets the level for that ident. * @param ident ident (module name for instance). * @param level level */ void identLevel(const char *ident, Slog::Level level); /** * Opens the file if not already and sets ident * @param ident module name for instance. */ void open(const char *ident); /** * stream overflow() overload. * @param c character to be managed * @return c */ virtual int overflow(int c); /** * stream sync() overload */ virtual int sync(); /** * emerg level printf style method, provided for convenience. * @param format printf format */ void emerg(const char *format, ...); /** * alert level printf style method, provided for convenience. * @param format printf format */ void alert(const char *format, ...); /** * critical level printf style method, provided for convenience. * @param format printf format */ void critical(const char *format, ...); /** * error level printf style method, provided for convenience. * @param format printf format */ void error(const char *format, ...); /** * warn level printf style method, provided for convenience. * @param format printf format */ void warn(const char *format, ...); /** * notice level printf style method, provided for convenience. * @param format printf format */ void notice(const char *format, ...); /** * info level printf style method, provided for convenience. * @param format printf format */ void info(const char *format, ...); /** * debug level printf style method, provided for convenience. * @param format printf format */ void debug(const char *format, ...); /** * operator to change ident and log level * @param ident ident (module name for instance) * @param level new log level * @return application logger stream */ AppLog &operator()(const char *ident, Slog::Level level = Slog::levelError); /** * operator to change ident * @param ident ident (module name for instance) * @return application logger stream */ inline AppLog& operator()(Ident &ident) { open(ident.c_str()); return *this; } /** * operator to change logging level * @param level new log level * @return application logger stream */ AppLog &operator()(Slog::Level level); /** * manipulator operator, to change print levels. * @param (* pfManipulator)(AppLog &) * @return application logger stream */ AppLog& operator<< (AppLog& (*pfManipulator)(AppLog&)); /** * manipulator operator, to use ostream manipulators (i.e. std::endl,...) * @param (* pfManipulator)(AppLog &) * @return application logger stream */ AppLog& operator<< (ostream& (*pfManipulator)(ostream&)); friend ostream& operator << (ostream &os, AppLog & al) { return al; } /** * operator << * @param ident module name for instance. * @return application logger stream */ inline AppLog& operator<< (Ident &ident) { open(ident.c_str()); return *this; } /** * warn level * @return application logger stream */ inline AppLog &warn(void) {return operator()(Slog::levelWarning);} /** * error level * @return application logger stream */ AppLog &error(void) { return operator()(Slog::levelError);} /** * debug level * @return application logger stream */ inline AppLog &debug(void) {return operator()(Slog::levelDebug);} /** * emerg level * @return application logger stream */ inline AppLog &emerg(void) {return operator()(Slog::levelEmergency);} /** * alert level * @return application logger stream */ inline AppLog &alert(void) {return operator()(Slog::levelAlert);} /** * critical level * @return application logger stream */ inline AppLog &critical(void) {return operator()(Slog::levelCritical);} /** * notice level * @return application logger stream */ inline AppLog ¬ice(void) {return operator()(Slog::levelNotice);} /** * info level * @return application logger stream */ inline AppLog &info(void) {return operator()(Slog::levelInfo);} /** * Translates level from string to Slog::Level, useful for * configuration files for instance. * Valid level names are: * "emerg" for Slog::levelEmergency * "alert" for Slog::levelAlert * "critical" for Slog::levelCritical * "error" for Slog::levelError * "warn" for Slog::levelWarning * "notice" for Slog::levelNotice * "info" for Slog::levelInfo * "debug" for Slog::levelDebug * @param name Slog Level name * @return Slog level value */ static Slog::Level levelTranslate(string name) { std::map::iterator it = assoc->find(name); return (it != assoc->end()) ? it->second : Slog::levelEmergency; } }; /** * Manipulator for debug level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &debug(AppLog& sl) {return sl.operator()(Slog::levelDebug);} /** * Manipulator for warn level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &warn(AppLog& sl) {return sl.operator()(Slog::levelWarning);} /** * Manipulator for error level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &error(AppLog& sl) { return sl.operator()(Slog::levelError);} /** * Manipulator for emerg level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &emerg(AppLog& sl) {return sl.operator()(Slog::levelEmergency);} /** * Manipulator for alert level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &alert(AppLog& sl) {return sl.operator()(Slog::levelAlert);} /** * Manipulator for critical level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &critical(AppLog& sl) {return sl.operator()(Slog::levelCritical);} /** * Manipulator for notice level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog ¬ice(AppLog& sl) {return sl.operator()(Slog::levelNotice);} /** * Manipulator for info level * @param sl application logger stream * @return application logger stream */ __EXPORT inline AppLog &info(AppLog& sl) {return sl.operator()(Slog::levelInfo);} /** * alog global log stream definition */ __EXPORT extern AppLog alog; END_NAMESPACE #endif //___APPLOG_H___ ucommon-6.0.7/inc/commoncpp/pointer.h0000644000175000017500000000742012163025062014517 00000000000000// Copyright (C) 2001-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception to the GNU General Public License, permission is // granted for additional uses of the text contained in its release // of Common C++. // // The exception is that, if you link the Common C++ library with other // files to produce an executable, this does not by itself cause the // resulting executable to be covered by the GNU General Public License. // Your use of that executable is in no way restricted on account of // linking the Common C++ library code into it. // // This exception does not however invalidate any other reasons why // the executable file might be covered by the GNU General Public License. // // This exception applies only to the code released under the // name Common C++. If you copy code from other releases into a copy of // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. /** * @file commoncpp/pointer.h * @short Template for creating reference count managed smart pointers. **/ #ifndef COMMONCPP_POINTER_H_ #define COMMONCPP_POINTER_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif NAMESPACE_COMMONCPP /** * Used to create and manage referece counted pointers. * * @author David Sugar * @short reference counted pointer template. */ template class Pointer { protected: unsigned *ptrCount; T *ptrObject; void ptrDetach(void) { if(ptrCount && --(*ptrCount)==0) { delete ptrObject; delete ptrCount; } ptrObject = NULL; ptrCount = NULL; } public: explicit Pointer(T* ptr = NULL) : ptrObject(ptr) { ptrCount = new unsigned; *ptrCount = 1; } Pointer(const Pointer &ref) { ptrObject = ref.ptrObject; ptrCount = ref.ptrCount; ++(*ptrCount); } inline virtual ~Pointer() {ptrDetach();} Pointer& operator=(const Pointer &ref) { if(this != &ref) { ptrDetach(); ptrObject = ref.ptrObject; ptrCount = ref.ptrCount; ++(*ptrCount); } return *this; } inline T& operator*() const {return *ptrObject;}; inline T* getObject() const {return ptrObject;}; inline T* operator->() const {return ptrObject;}; inline bool operator!() const {return (*ptrCount == 1);}; inline int operator++() const {return ++(*ptrCount);}; int operator--() const { if(*ptrCount == 1) { delete this; return 0; } return --(*ptrCount); } }; END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/process.h0000644000175000017500000002045612163025062014521 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/process.h * @short Process services. **/ #ifndef COMMONCPP_PROCESS_H_ #define COMMONCPP_PROCESS_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_THREAD_H_ #include #endif NAMESPACE_COMMONCPP /** * A class for containing portable process related functions * that help create portable code. These are typically * referenced thru Process::xxx static member functions. * Many of these members are used both for win32 and posix * systems although some may be platform specific. * * @short Peocess wrapper class. * @author David Sugar */ class __EXPORT Process { private: static bool rtflag; public: #ifndef _MSWINDOWS_ typedef void (*Trap)(int); /** * Detach current process into a daemon, posix * only. Perhaps a similar method can be used * for creating win32 "services"? */ static void detach(void); /** * Attach the current process to another device * or i/o session. It is deamonified and dissasociated * with the prior parent process and controlling terminal. * * @param devname path to attach to. */ static void attach(const char *devname); /** * Set a posix compliant signal handler. * * @return previous handler. * @param signo signal no. * @param handler trap handler. */ static Trap setPosixSignal(int signo, Trap handler); /** * Set system call interuptable signal handler. * * #return previous handler. * @param signo signal no. * @param handler trap handler. */ static Trap setInterruptSignal(int signo, Trap handler); #endif /** * Lock a process in memory. Ideally you should be deep enough * where additional memallocs for functions will not kill you, * or use false for future. * * @return true if successful. * @param future pages as well... */ bool lock(bool future = true); /** * Unlock process pages. */ void unlock(void); /** * Spawn a process and wait for it's exit code. In win32 * this is done with the spawn system call. In posix, * this is done with a fork, an execvp, and a waitpid. * * @warning The implementation differences between posix and * win32 systems may cause side effects. For instance, if you * use atexit() and this spawn method, on posix systems the * function set up with atexit() will be called when the * parent process of the fork exits, which will not happen on * Win32 systems. * * @return error code from process. * @param exec name of executable. * @param argv list of command arguments. * @param wait for process to exit before return. */ static int spawn(const char *exec, const char **argv, bool wait = true); /** * Get the exit status of another process, waiting for it * to exit. * * @return exit code from process. * @param pid process id. */ static int join(int pid); /** * Cancel a running child process. * * @return 0 on success. * @param pid process id. * @param sig cancel signal to apply. */ static bool cancel(int pid, int sig = 0); /** * Get system environment. * * @return system environ symbol. * @param name of symbol. */ static const char *getEnv(const char *name); /** * Set system environment in a standard manner. * * @param name of environment symbol to set. * @param value of environment symbol. * @param overwrite true if replace existing symbol. */ static void setEnv(const char *name, const char *value, bool overwrite); /** * Get etc prefix path. * * @return etc prefix. */ static const char *getConfigDir(void); /** * Get home directory. * * @return user home directory. */ static const char *getHomeDir(void); /** * Get user name. * * @return user login id. */ static const char *getUser(void); /** * Set user id by name. * * @return true if successful. */ static bool setUser(const char *id, bool grp = true); /** * Set the effective group id by name. * * @return true if successful. */ static bool setGroup(const char *id); /** * Return the effective operating system page size. * * @return system page size. */ static size_t getPageSize(void); /** * Used to set process priority and optionally enable realtime. */ static void setPriority(int pri); /** * Used to set process scheduling policy. */ static void setScheduler(const char *policy); /** * Portable shortcut for setting realtime... */ static void setRealtime(int pri = 0); /** * Return true if scheduler settable. */ static bool isScheduler(void); /** * Return true if realtime scheduling. */ static inline bool isRealtime(void) {return rtflag;}; }; /** * This class is used to create a "named" lock entity that can be used * to control access to a resource between multiple processes. The * posix implimentation uses a pidfile and the win32 version uses a * globally visible mutex. * * @author David Sugar * @short System-wide named lock */ class __EXPORT Lockfile { private: #ifdef _MSWINDOWS_ HANDLE _mutex; bool _flagged; #else char *_path; #endif public: /** * Create a lock under a known name. * * @param name of system-wide lock to create. */ Lockfile(const char *name); /** * Create a new lock object that can be used to make locks. */ Lockfile(); /** * Destroy the current lock and release it. */ ~Lockfile() {unlock();}; /** * Lock a system-wide name for this process. If the lock * is successful, return true. If an existing lock was * already acquired, release it first. * * @return true if lock successful. * @param name system-wide lock to use. */ bool lock(const char *name); /** * Release an acquired lock. */ void unlock(void); /** * Flag if the current process has aqcuired a lock. * * @return true if we have the lock. */ bool isLocked(void); }; END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/udp.h0000644000175000017500000004422112163025062013627 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/udp.h * @short udp derived socket classes. **/ #ifndef COMMONCPP_UDP_H_ #define COMMONCPP_UDP_H_ #include #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif #ifndef COMMONCPP_ADDRESS_H_ #include #endif #ifndef COMMONCPP_SOCKET_H_ #include #endif NAMESPACE_COMMONCPP /** * UDP sockets implement the TCP SOCK_DGRAM UDP protocol. They can be * used to pass unverified messages between hosts, or to broadcast a * specific message to an entire subnet. Please note that Streaming of * realtime data commonly use UDPDuplex related classes rather than * UDPSocket. * * In addition to connected TCP sessions, Common C++ supports UDP sockets and * these also cover a range of functionality. Like a TCPSocket, A UDPSocket * can be created bound to a specific network interface and/or port address, * though this is not required. UDP sockets also are usually either * connected or otherwise "associated" with a specific "peer" UDP socket. * Since UDP sockets operate through discreet packets, there are no streaming * operators used with UDP sockets. * * In addition to the UDP "socket" class, there is a "UDPBroadcast" class. * The UDPBroadcast is a socket that is set to send messages to a subnet as a * whole rather than to an individual peer socket that it may be associated * with. * * UDP sockets are often used for building "realtime" media streaming * protocols and full duplex messaging services. When used in this manner, * typically a pair of UDP sockets are used together; one socket is used to * send and the other to receive data with an associated pair of UDP sockets * on a "peer" host. This concept is represented through the Common C++ * UDPDuplex object, which is a pair of sockets that communicate with another * UDPDuplex pair. * * * @author David Sugar * @short Unreliable Datagram Protocol sockets. */ class __EXPORT UDPSocket : public Socket { private: inline Error setKeepAlive(bool enable) {return Socket::setKeepAlive(enable);}; protected: #ifdef CCXX_IPV6 union { struct sockaddr_in6 ipv6; struct sockaddr_in ipv4; } peer; #else union { struct sockaddr_in ipv4; } peer; #endif Family family; public: /** * Create an unbound UDP socket, mostly for internal use. */ UDPSocket(Family family = IPV4); /** * Create a UDP socket bound by a service name. */ UDPSocket(const char *name, Family family = IPV4); /** * Create a UDP socket and bind it to a specific interface * and port address so that other UDP sockets on remote * machines (or the same host) may find and send UDP messages * to it. On failure to bind, an exception is thrown. * * @param bind address to bind this socket to. * @param port number to bind this socket to. */ UDPSocket(const IPV4Address &bind, tpport_t port); #ifdef CCXX_IPV6 UDPSocket(const IPV6Address &bind, tpport_t port); #endif /** * Destroy a UDP socket as a socket. */ virtual ~UDPSocket(); /** * Set the loopback. */ inline Error setLoopback(bool enable) {return Socket::setLoopbackByFamily(enable, family);} /** * Set the multicast. */ inline Error setMulticast(bool enable) {return Socket::setMulticastByFamily(enable, family);} /** * Set time to live. */ inline Error setTimeToLive(char ttl) {return Socket::setTimeToLiveByFamily(ttl, family);} /** * set the peer address to send message packets to. This can be * set before every send() call if nessisary. * * @param host address to send packets to. * @param port number to deliver packets to. */ void setPeer(const IPV4Host &host, tpport_t port); void connect(const IPV4Host &host, tpport_t port); #ifdef CCXX_IPV6 void setPeer(const IPV6Host &host, tpport_t port); void connect(const IPV6Host &host, tpport_t port); #endif /** * get the interface index for a named network device * * @param ethX is device name, like "eth0" or "eth1" * @param InterfaceIndex is the index value returned by os * @todo Win32 and ipv6 specific implementation. */ Socket::Error getInterfaceIndex(const char *ethX,int& InterfaceIndex); /** * join a multicast group on a particular interface * * @param ia is the multicast address to use * @param InterfaceIndex is the index value returned by * getInterfaceIndex * @todo Win32 and ipv6 specific implementation. */ Socket::Error join(const IPV4Multicast &ia,int InterfaceIndex); /** * Send a message packet to a peer host. * * @param buf pointer to packet buffer to send. * @param len of packet buffer to send. * @return number of bytes sent. */ ssize_t send(const void *buf, size_t len); /** * Receive a message from any host. * * @param buf pointer to packet buffer to receive. * @param len of packet buffer to receive. * @param reply save sender address for reply if true. * @return number of bytes received. */ ssize_t receive(void *buf, size_t len, bool reply = false); /** * Examine address of sender of next waiting packet. This also * sets "peer" address to the sender so that the next "send" * message acts as a "reply". This additional behavior overides * the standard socket getSender behavior. * * @param port pointer to hold port number. */ IPV4Host getIPV4Peer(tpport_t *port = NULL) const; inline IPV4Host getPeer(tpport_t *port = NULL) const {return getIPV4Peer(port);} #ifdef CCXX_IPV6 IPV6Host getIPV6Peer(tpport_t *port = NULL) const; #endif /** * Examine contents of next waiting packet. * * @param buf pointer to packet buffer for contents. * @param len of packet buffer. * @return number of bytes examined. */ inline ssize_t peek(void *buf, size_t len) {return ::recv(so, (char *)buf, len, MSG_PEEK);}; /** * Associate socket with a named connection */ void setPeer(const char *service); void connect(const char *service); /** * Disassociate this socket from any host connection. No data * should be read or written until a connection is established. */ Error disconnect(void); }; /** * Representing a UDP socket used for subnet broadcasts, this class * provides an alternate binding and setPeer() capability for UDP * sockets. * * @author David Sugar * @short Unreliable Datagram for subnet broadcasts. */ class __EXPORT UDPBroadcast : public UDPSocket { private: void setPeer(const IPV4Host &ia, tpport_t port); Error setBroadcast(bool enable) {return Socket::setBroadcast(enable);}; public: /** * Create and bind a subnet broadcast socket. * * @param ia address to bind socket under locally. * @param port to bind socket under locally. */ UDPBroadcast(const IPV4Address &ia, tpport_t port); /** * Set peer by subnet rather than specific host. * * @param subnet of peer hosts to send to. * @param port number to use. */ void setPeer(const IPV4Broadcast &subnet, tpport_t port); }; /** * Representing half of a two-way UDP connection, the UDP transmitter * can broadcast data to another selected peer host or to an entire * subnet. * * @author David Sugar * @short Unreliable Datagram Peer Associations. */ class __EXPORT UDPTransmit : protected UDPSocket { private: /** * Common code for diferent flavours of Connect (host, broadcast, * multicast). * * @param ia network address to associate with * @param port port number to associate with */ Error cConnect(const IPV4Address &ia, tpport_t port); protected: /** * Create a UDP transmitter. */ UDPTransmit(Family family = IPV4); /** * Create a UDP transmitter, bind it to a specific interface * and port address so that other UDP sockets on remote * machines (or the same host) may find and send UDP messages * to it, and associate it with a given port on a peer host. * On failure to bind, an exception is thrown. This class is * only used to build the UDP Duplex. * * @param bind address to bind this socket to. * @param port number to bind this socket to. */ UDPTransmit(const IPV4Address &bind, tpport_t port = 5005); #ifdef CCXX_IPV6 UDPTransmit(const IPV6Address &bind, tpport_t port = 5005); #endif /** * Associate this socket with a specified peer host. The port * number from the constructor will be used. All UDP packets * will be sent to and received from the specified host. * * @return 0 on success, -1 on error. * @param host address to connect socket to. * @param port to connect socket to. */ Error connect(const IPV4Host &host, tpport_t port); #ifdef CCXX_IPV6 Error connect(const IPV6Address &host, tpport_t port); #endif /** * Associate this socket with a subnet of peer hosts for * subnet broadcasting. The server must be able to assert * broadcast permission for the socket. * * @return 0 on success, -1 on error. * @param subnet subnet address to broadcast into. * @param port transport port to broadcast into. */ Error connect(const IPV4Broadcast &subnet, tpport_t port); /** * Associate this socket with a multicast group. * * @return 0 on success, -1 on error. * @param mgroup address of the multicast group to send to. * @param port port number */ Error connect(const IPV4Multicast &mgroup, tpport_t port); #ifdef CCXX_IPV6 Error connect(const IPV6Multicast &mgroup, tpport_t port); #endif /** * Transmit "send" to use "connected" send rather than sendto. * * @return number of bytes sent. * @param buf address of buffer to send. * @param len of bytes to send. */ inline ssize_t send(const void *buf, size_t len) {return ::send(so, (const char *)buf, len, MSG_NOSIGNAL);} /** * Stop transmitter. */ inline void endTransmitter(void) {Socket::endSocket();} /* * Get transmitter socket. * * @return transmitter. */ inline SOCKET getTransmitter(void) {return so;}; inline Error setMulticast(bool enable) {return Socket::setMulticastByFamily(enable, family);} inline Error setTimeToLive(unsigned char ttl) {return Socket::setTimeToLiveByFamily(ttl, family);}; public: /** * Transmit "send" to use "connected" send rather than sendto. * * @note Windows does not support MSG_DONTWAIT, so it is defined * as 0 on that platform. * @return number of bytes sent. * @param buffer address of buffer to send. * @param len of bytes to send. */ inline ssize_t transmit(const char *buffer, size_t len) {return ::send(so, buffer, len, MSG_DONTWAIT|MSG_NOSIGNAL);} /** * See if output queue is empty for sending more packets. * * @return true if output available. * @param timeout in milliseconds to wait. */ inline bool isOutputReady(unsigned long timeout = 0l) {return Socket::isPending(Socket::pendingOutput, timeout);}; inline Error setRouting(bool enable) {return Socket::setRouting(enable);}; inline Error setTypeOfService(Tos tos) {return Socket::setTypeOfService(tos);}; inline Error setBroadcast(bool enable) {return Socket::setBroadcast(enable);}; }; /** * Representing half of a two-way UDP connection, the UDP receiver * can receive data from another peer host or subnet. This class is * used exclusivily to derive the UDPDuplex. * * @author David Sugar * @short Unreliable Datagram Peer Associations. */ class __EXPORT UDPReceive : protected UDPSocket { protected: /** * Create a UDP receiver, bind it to a specific interface * and port address so that other UDP sockets on remote * machines (or the same host) may find and send UDP messages * to it, and associate it with a given port on a peer host. * On failure to bind, an exception is thrown. * * @param bind address to bind this socket to. * @param port number to bind this socket to. */ UDPReceive(const IPV4Address &bind, tpport_t port); #ifdef CCXX_IPV6 UDPReceive(const IPV6Address &bind, tpport_t port); #endif /** * Associate this socket with a specified peer host. The port * number from the constructor will be used. All UDP packets * will be sent received from the specified host. * * @return 0 on success, -1 on error. * @param host host network address to connect socket to. * @param port host transport port to connect socket to. */ Error connect(const IPV4Host &host, tpport_t port); #ifdef CCXX_IPV6 Error connect(const IPV6Host &host, tpport_t port); #endif /** * Check for pending data. * * @return true if data is waiting. * @param timeout in milliseconds. */ bool isPendingReceive(timeout_t timeout) {return Socket::isPending(Socket::pendingInput, timeout);}; /** * End receiver. */ inline void endReceiver(void) {Socket::endSocket();} inline SOCKET getReceiver(void) const {return so;}; inline Error setRouting(bool enable) {return Socket::setRouting(enable);} inline Error setMulticast(bool enable) {return Socket::setMulticastByFamily(enable, family);} inline Error join(const IPV4Multicast &ia) {return Socket::join(ia);} #ifdef CCXX_IPV6 inline Error join(const IPV6Multicast &ia) {return Socket::join(ia);} #endif inline Error drop(const IPV4Multicast &ia) {return Socket::drop(ia);} #ifdef CCXX_IPV6 inline Error drop(const IPV6Multicast &ia) {return Socket::drop(ia);} #endif public: /** * Receive a data packet from the connected peer host. * * @return num of bytes actually received. * @param buf address of data receive buffer. * @param len size of data receive buffer. */ inline ssize_t receive(void *buf, size_t len) {return ::recv(so, (char *)buf, len, 0);}; /** * See if input queue has data packets available. * * @return true if data packets available. * @param timeout in milliseconds. */ inline bool isInputReady(timeout_t timeout = TIMEOUT_INF) {return Socket::isPending(Socket::pendingInput, timeout);}; }; /** * UDP duplex connections impliment a bi-directional point-to-point UDP * session between two peer hosts. Two UDP sockets are typically used * on alternating port addresses to assure that sender and receiver * data does not collide or echo back. A UDP Duplex is commonly used * for full duplex real-time streaming of UDP data between hosts. * * @author David Sugar * @short Unreliable Datagram Peer Associations. */ class __EXPORT UDPDuplex : public UDPTransmit, public UDPReceive { public: /** * Create a UDP duplex as a pair of UDP simplex objects * bound to alternating and interconnected port addresses. * * @param bind address to bind this socket to. * @param port number to bind sender. */ UDPDuplex(const IPV4Address &bind, tpport_t port); #ifdef CCXX_IPV6 UDPDuplex(const IPV6Address &bind, tpport_t port); #endif /** * Associate the duplex with a specified peer host. Both * the sender and receiver will be interconnected with * the remote host. * * @return 0 on success, error code on error. * @param host address to connect socket to. * @param port number to connect socket to. */ Error connect(const IPV4Host &host, tpport_t port); #ifdef CCXX_IPV6 Error connect(const IPV6Host &host, tpport_t port); #endif /** * Disassociate this duplex from any host connection. No data * should be read or written until a connection is established. * * @return 0 on success, error code on error. */ Error disconnect(void); }; END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/commoncpp.h0000644000175000017500000000123112163025062015024 00000000000000#ifndef COMMONCPP_COMMONCPP_H_ #define COMMONCPP_COMMONCPP_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef NEW_STDCPP #include #endif #endif ucommon-6.0.7/inc/commoncpp/object.h0000644000175000017500000003704112163025062014307 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file object.h * @short Some object manipulation classes for smart pointers, linked lists, * etc. **/ #ifndef COMMONCPP_OBJECT_H_ #define COMMONCPP_OBJECT_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif NAMESPACE_COMMONCPP class MapObject; class MapIndex; /** * A reference countable object. This is used in association with smart * pointers (RefPointer). * * @author David Sugar * @short Object managed by smart pointer reference count. */ class __EXPORT RefObject { protected: friend class RefPointer; unsigned refCount; /** * The constructor simply initializes the count. */ inline RefObject() {refCount = 0;}; /** * The destructor is called when the reference count returns * to zero. This is done through a virtual destructor. */ virtual ~RefObject(); public: /** * The actual object being managed can be returned by this * method as a void and then recast to the actual type. This * removes the need to dynamic cast from RefObject and the * dependence on rtti this implies. * * @return underlying object being referenced. */ virtual void *getObject(void) = 0; }; /** * Pointer to reference counted objects. This is a non-template form * of a reference count smart pointer, and so uses common code. This * can be subclassed to return explicit object types. * * @author David Sugar * @short Pointer to reference count managed objects. */ class __EXPORT RefPointer { protected: RefObject *ref; /** * Detach current object, for example, when changing pointer. */ void detach(void); /** * Patch point for mutex in derived class. This may often * be a single static mutex shared by a managed type. */ virtual void enterLock(void); /** * Patch point for a mutex in derived class. This may often * be a single static mutex shared by a managed type. */ virtual void leaveLock(void); public: /** * Create an unattached pointer. */ inline RefPointer() {ref = NULL;}; /** * Create a pointer attached to a reference counted object. * * Object being referenced. */ RefPointer(RefObject *obj); /** * A copy constructor. * * Pointer being copied. */ RefPointer(const RefPointer &ptr); virtual ~RefPointer(); RefPointer& operator=(const RefObject &ref); inline void *operator*() const {return getObject();}; inline void *operator->() const {return getObject();}; void *getObject(void) const; bool operator!() const; }; /** * Self managed single linked list object chain. This is used for * accumulating lists by using as a base class for a derived subclass. * * @author David Sugar * @short Accumulating single linked list. */ class __EXPORT LinkedSingle { protected: LinkedSingle *nextObject; inline LinkedSingle() {nextObject = NULL;}; virtual ~LinkedSingle(); public: /** * Get first linked object in list. This may be dynamically * recast, and may refer to a master static bookmark pointer * in a derived class. Otherwise it simply returns the current * object. In a "free" list, this may not only return the first * object, but also set the first to next. * * @return pointer to first object in list. */ virtual LinkedSingle *getFirst(void); /** * Gets the last object in the list. This normally follows the * links to the end. This is a virtual because derived class * may include a static member bookmark for the current end. * * @return pointer to last object in list. */ virtual LinkedSingle *getLast(void); /** * Get next object, for convenience. Derived class may use * this with a dynamic cast. * * @return next object in list. */ inline LinkedSingle *getNext(void) {return nextObject;}; /** * Insert object into chain. This is a virtual because * derived class may choose instead to perform an insert * at head or tail, may manage bookmarks, and may add mutex lock. * * @param object being inserted. */ virtual void insert(LinkedSingle& obj); LinkedSingle &operator+=(LinkedSingle &obj); }; /** * Self managed double linked list object chain. This is used for * accumulating lists by using as a base class for a derived subclass. * * @author David Sugar * @short Accumulating double linked list. */ class __EXPORT LinkedDouble { protected: LinkedDouble *nextObject, *prevObject; inline LinkedDouble() {nextObject = prevObject = NULL;}; virtual ~LinkedDouble(); virtual void enterLock(void); virtual void leaveLock(void); virtual LinkedDouble *firstObject(); virtual LinkedDouble *lastObject(); public: /** * Requested in overloaded insert() method to indicate how to insert * data into list */ enum InsertMode { modeAtFirst, /**< insert at first position in list pointed by current object */ modeAtLast, /**< insert at last position in list pointed by current object */ modeBefore, /**< insert in list before current object */ modeAfter /**< insert in list after current object */ }; /** * Get first linked object in list. This may be dynamically * recast, and may refer to a master static bookmark pointer * in a derived class. Otherwise it follows list to front. * * @return pointer to first object in list. */ virtual LinkedDouble *getFirst(void); /** * Gets the last object in the list. This normally follows the * links to the end. This is a virtual because derived class * may include a static member bookmark for the current end. * * @return pointer to last object in list. */ virtual LinkedDouble *getLast(void); /** * Virtual to get the insert point to use when adding new members. This * may be current, or always head or always tail. As a virtual, this allows * derived class to establish "policy". * * @return pointer to insertion point in list. */ virtual LinkedDouble *getInsert(void); /** * Get next object, for convenience. Derived class may use * this with a dynamic cast. * * @return next object in list. */ inline LinkedDouble *getNext(void) {return nextObject;}; /** * Get prev object in the list. * * @return pointer to previous object. */ inline LinkedDouble *getPrev(void) {return prevObject;}; /** * Insert object into chain at given position, as indicated by \ref InsertMode; * If no position is given, it defaults to \ref modeAtLast, inserting element * at list's end. * * @param object being inserted. * @param position where object is inserted. */ virtual void insert(LinkedDouble& obj, InsertMode position = modeAtLast); /** * Remove object from chain. */ virtual void detach(void); LinkedDouble &operator+=(LinkedDouble &obj); LinkedDouble &operator--(); }; /** * A map table allows for entities to be mapped (hash index) onto it. * Unlike with Assoc, This form of map table also allows objects to be * removed from the table. This table also includes a mutex lock for * thread safety. A free list is also optionally maintained for reusable * maps. * * @author David Sugar * @short Table to hold hash indexed objects. */ class __EXPORT MapTable : public Mutex { protected: friend class MapObject; friend class MapIndex; unsigned range; unsigned count; MapObject **map; void cleanup(void); public: /** * Create a map table with a specified number of slots. * * @param number of slots. */ MapTable(unsigned size); /** * Destroy the table, calls cleanup. */ virtual ~MapTable(); /** * Get index value from id string. This function can be changed * as needed to provide better collision avoidence for specific * tables. * * @param id string * @return index slot in table. */ virtual unsigned getIndex(const char *id); /** * Return range of this table. * * @return table range. */ inline unsigned getRange(void) {return range;}; /** * Return the number of object stored in this table. * * @return table size. */ inline unsigned getSize(void) {return count;}; /** * Lookup an object by id key. It is returned as void * for * easy re-cast. * * @param key to find. * @return pointer to found object or NULL. */ void *getObject(const char *id); /** * Map an object to our table. If it is in another table * already, it is removed there first. * * @param object to map. */ void addObject(MapObject &obj); /** * Get the first element into table, it is returned as void * for * easy re-cast. * * @return pointer to found object or NULL. */ void *getFirst(); /** * Get the last element into table, it is returned as void * for * easy re-cast. * * @return pointer to found object or NULL. */ void *getLast(); /** * Get table's end, useful for cycle control; it is returned as void * for * easy re-cast. * * @return pointer to found object or NULL. */ void *getEnd() { return NULL; }; /** * Get next object from managed free list. This returns as a * void so it can be recast into the actual type being used in * derived MapObject's. A derived version of MapTable may well * offer an explicit type version of this. Some derived * MapObject's may override new to use managed list. * * @return next object on free list. */ void *getFree(void); /** * Add an object to the managed free list. Some MapObject's * may override delete operator to detach and do this. * * @param object to add. */ void addFree(MapObject *obj); /** * An operator to map an object to the table. * * @return table being used. * @param object being mapped. */ MapTable &operator+=(MapObject &obj); /** * This operator is virtual in case it must also add the object to a * managed free list. * * @return current table. * @param object entity to remove. */ virtual MapTable &operator-=(MapObject &obj); }; /** * The MapIndex allows linear access into a MapTable, that otherwise could have * its elements being retrieved only by key. * It can be increased, checked and dereferenced like a pointer, by means of * suitable operators. * * @author Sergio Repetto * @short Index object to access MapTable elements */ class __EXPORT MapIndex { MapObject* thisObject; public : /** * Creates an empty map index (pointing to nothing). */ MapIndex() : thisObject(NULL) {}; /** * Creates a map index pointing to a specific map object * * @param the indexed object */ MapIndex(MapObject* theObject) : thisObject(theObject) {}; /** * Creates a copy of a given map index * * @param the source index object */ MapIndex(const MapIndex& theIndex) : thisObject(theIndex.thisObject) {}; /** * Dereference operator: the pointed object it is returned as void * for * easy re-cast. * * @return pointer to indexed object. */ void* operator*() const { return (void*)thisObject; } /** * Assignment operator to avoid implicit cast. * * @return the object itself, as changed. */ MapIndex& operator=(MapObject *theObject); /** * Prefix increment operator, to be used in loops and such. * * @return the object itself, as changed. */ MapIndex& operator++(); // prefix /** * Postfix increment operator, to be used in loops and such. * * @return the object itself, as changed. */ MapIndex operator++(int) // postfix { return this->operator++(); } /** * Comparison operator, between two MapIndex's. * * @return the object itself, as changed. */ bool operator==(const MapIndex& theIndex) const { return thisObject == theIndex.thisObject; }; bool operator!=(const MapIndex& theIndex) const { return !(*this == theIndex); }; /** * Comparison operator, between the MapIndex and a MapObject, useful to avoid * casts for sake of clearness. * * @return the object itself, as changed. */ bool operator==(const MapObject* theObject) const { return thisObject == theObject; }; bool operator!=(const MapObject* theObject) const { return !(*this == theObject); }; }; /** * The MapObject is a base class which can be used to make a derived * class operate on a MapTable. Derived classes may override new and * delete operators to use managed free list from a MapTable. * * @author David Sugar * @short Mappable object. */ class __EXPORT MapObject { protected: friend class MapTable; friend class MapIndex; MapObject *nextObject; const char *idObject; MapTable *table; public: /** * Remove the object from it's current table. */ void detach(void); /** * Save id, mark as not using any table. * * @param id string for this object. */ MapObject(const char *id); }; END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/Makefile.am0000644000175000017500000000152712163025062014724 00000000000000# Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = $(LT_VERSION) -release $(LT_RELEASE) AM_CXXFLAGS = $(UCOMMON_FLAGS) pkgincludedir = $(includedir)/commoncpp pkginclude_HEADERS = config.h export.h string.h exception.h thread.h \ slog.h applog.h address.h socket.h tcp.h udp.h dccp.h mime.h file.h \ process.h pointer.h serial.h tokenizer.h numbers.h object.h \ commoncpp.h ucommon-6.0.7/inc/commoncpp/Makefile.in0000644000175000017500000004277412175171470014756 00000000000000# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = inc/commoncpp DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(pkginclude_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ucommon-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgincludedir)" HEADERS = $(pkginclude_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/commoncpp ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKFLAGS = @CHECKFLAGS@ COMPAT = @COMPAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_GENERIC = @LT_GENERIC@ LT_VERSION = @LT_VERSION@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SECURE = @SECURE@ SECURE_LIBS = @SECURE_LIBS@ SECURE_LOCAL = @SECURE_LOCAL@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UCOMMON_CFGPATH = @UCOMMON_CFGPATH@ UCOMMON_CLINK = @UCOMMON_CLINK@ UCOMMON_FLAGS = @UCOMMON_FLAGS@ UCOMMON_INCLUDES = @UCOMMON_INCLUDES@ UCOMMON_LIBC = @UCOMMON_LIBC@ UCOMMON_LIBS = @UCOMMON_LIBS@ UCOMMON_LINKED = @UCOMMON_LINKED@ UCOMMON_LOCALE = @UCOMMON_LOCALE@ UCOMMON_MODEL = @UCOMMON_MODEL@ UCOMMON_PREFIX = @UCOMMON_PREFIX@ UCOMMON_VARPATH = @UCOMMON_VARPATH@ UCOMMON_VISIBILITY = @UCOMMON_VISIBILITY@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ includes = @includes@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libs = @libs@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = $(LT_VERSION) -release $(LT_RELEASE) AM_CXXFLAGS = $(UCOMMON_FLAGS) pkginclude_HEADERS = config.h export.h string.h exception.h thread.h \ slog.h applog.h address.h socket.h tcp.h udp.h dccp.h mime.h file.h \ process.h pointer.h serial.h tokenizer.h numbers.h object.h \ commoncpp.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu inc/commoncpp/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu inc/commoncpp/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-pkgincludeHEADERS install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ucommon-6.0.7/inc/commoncpp/serial.h0000644000175000017500000006036712163025062014327 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file serial.h * @short Serial I/O services. **/ #ifndef COMMONCPP_SERIAL_H_ #define COMMONCPP_SERIAL_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_THREAD_H_ #include #endif #ifndef COMMMONCPP_EXCEPTION_H_ #include #endif NAMESPACE_COMMONCPP /** * The Serial class is used as the base for all serial I/O services * under APE. A serial is a system serial port that is used either * for line or packet based data input. Serial ports may also be * "streamable" in a derived form. * * Common C++ serial I/O classes are used to manage serial devices and * implement serial device protocols. From the point of view of Common C++, * serial devices are supported by the underlying Posix specified "termios" * call interface. * * The serial I/O base class is used to hold a descriptor to a serial device * and to provide an exception handling interface for all serial I/O classes. * The base class is also used to specify serial I/O properties such as * communication speed, flow control, data size, and parity. The "Serial" * base class is not itself directly used in application development, * however. * * Common C++ Serial I/O is itself divided into two conceptual modes; frame * oriented and line oriented I/O. Both frame and line oriented I/O makes * use of the ability of the underlying tty driver to buffer data and return * "ready" status from when select either a specified number of bytes or * newline record has been reached by manipulating termios c_cc fields * appropriately. This provides some advantage in that a given thread * servicing a serial port can block and wait rather than have to continually * poll or read each and every byte as soon as it appears at the serial port. * * @author David Sugar * @short base class for all serial I/O services. */ class __EXPORT Serial { public: enum Error { errSuccess = 0, errOpenNoTty, errOpenFailed, errSpeedInvalid, errFlowInvalid, errParityInvalid, errCharsizeInvalid, errStopbitsInvalid, errOptionInvalid, errResourceFailure, errOutput, errInput, errTimeout, errExtended }; typedef enum Error Error; enum Flow { flowNone, flowSoft, flowHard, flowBoth }; typedef enum Flow Flow; enum Parity { parityNone, parityOdd, parityEven }; typedef enum Parity Parity; enum Pending { pendingInput, pendingOutput, pendingError }; typedef enum Pending Pending; private: Error errid; char *errstr; struct { bool thrown: 1; bool linebuf: 1; } flags; void * original; void * current; /** * Used to properly initialize serial object. */ void initSerial(void); protected: fd_t dev; int bufsize; /** * Opens the serial device. * * @param fname Pathname of device to open */ void open(const char *fname); /** * Closes the serial device. * */ void close(void); /** * Reads from serial device. * * @param Data Point to character buffer to receive data. Buffers MUST * be at least Length + 1 bytes in size. * @param Length Number of bytes to read. */ virtual int aRead(char * Data, const int Length); /** * Writes to serial device. * * @param Data Point to character buffer containing data to write. Buffers MUST * @param Length Number of bytes to write. */ virtual int aWrite(const char * Data, const int Length); /** * This service is used to throw all serial errors which usually * occur during the serial constructor. * * @param error defined serial error id. * @param errstr string or message to optionally pass. */ Error error(Error error, char *errstr = NULL); /** * This service is used to thow application defined serial * errors where the application specific error code is a string. * * @param err string or message to pass. */ inline void error(char *err) {error(errExtended, err);}; /** * This method is used to turn the error handler on or off for * "throwing" execptions by manipulating the thrown flag. * * @param enable true to enable handler. */ inline void setError(bool enable) {flags.thrown = !enable;}; /** * Set packet read mode and "size" of packet read buffer. * This sets VMIN to x. VTIM is normally set to "0" so that * "isPending()" can wait for an entire packet rather than just * the first byte. * * @return actual buffer size set. * @param size of packet read request. * @param btimer optional inter-byte data packet timeout. */ int setPacketInput(int size, unsigned char btimer = 0); /** * Set "line buffering" read mode and specifies the newline * character to be used in seperating line records. isPending * can then be used to wait for an entire line of input. * * @param newline newline character. * @param nl1 EOL2 control character. * @return size of conical input buffer. */ int setLineInput(char newline = 13, char nl1 = 0); /** * Restore serial device to the original settings at time of open. */ void restore(void); /** * Used to flush the input waiting queue. */ void flushInput(void); /** * Used to flush any pending output data. */ void flushOutput(void); /** * Used to wait until all output has been sent. */ void waitOutput(void); /** * Used as the default destructor for ending serial I/O * services. It will restore the port to it's original state. */ void endSerial(void); /** * Used to initialize a newly opened serial file handle. You * should set serial properties and DTR manually before first * use. */ void initConfig(void); /** * This allows later ttystream class to open and close a serial * device. */ Serial() {initSerial();}; /** * A serial object may be constructed from a named file on the * file system. This named device must be "isatty()". * * @param name of file. */ Serial(const char *name); public: /** * The serial base class may be "thrown" as a result on an error, * and the "catcher" may then choose to destory the object. By * assuring the socket base class is a virtual destructor, we * can assure the full object is properly terminated. */ virtual ~Serial(); /** * Serial ports may also be duplecated by the assignment * operator. */ Serial &operator=(const Serial &from); /** * Set serial port speed for both input and output. * * @return 0 on success. * @param speed to select. 0 signifies modem "hang up". */ Error setSpeed(unsigned long speed); /** * Set character size. * * @return 0 on success. * @param bits character size to use (usually 7 or 8). */ Error setCharBits(int bits); /** * Set parity mode. * * @return 0 on success. * @param parity mode. */ Error setParity(Parity parity); /** * Set number of stop bits. * * @return 0 on success. * @param bits stop bits. */ Error setStopBits(int bits); /** * Set flow control. * * @return 0 on success. * @param flow control mode. */ Error setFlowControl(Flow flow); /** * Set the DTR mode off momentarily. * * @param millisec number of milliseconds. */ void toggleDTR(timeout_t millisec); /** * Send the "break" signal. */ void sendBreak(void); /** * Often used by a "catch" to fetch the last error of a thrown * serial. * * @return error numbr of last Error. */ inline Error getErrorNumber(void) {return errid;}; /** * Often used by a "catch" to fetch the user set error string * of a thrown serial. * * @return string for error message. */ inline char *getErrorString(void) {return errstr;}; /** * Get the "buffer" size for buffered operations. This can * be used when setting packet or line read modes to determine * how many bytes to wait for in a given read call. * * @return number of bytes used for buffering. */ inline int getBufferSize(void) {return bufsize;}; /** * Get the status of pending operations. This can be used to * examine if input or output is waiting, or if an error has * occured on the serial device. * * @return true if ready, false if timeout. * @param pend ready check to perform. * @param timeout in milliseconds. */ virtual bool isPending(Pending pend, timeout_t timeout = TIMEOUT_INF); }; /** * TTY streams are used to represent serial connections that are fully * "streamable" objects using C++ stream classes and friends. * * The first application relevant serial I/O class is the TTYStream class. * TTYStream offers a linearly buffered "streaming" I/O session with the * serial device. Furthermore, traditional C++ "stream" operators (<< and * >>) may be used with the serial device. A more "true" to ANSI C++ library * format "ttystream" is also available, and this supports an "open" method * in which one can pass initial serial device parameters immediately * following the device name in a single string, as in * "/dev/tty3a:9600,7,e,1", as an example. * * The TTYSession aggragates a TTYStream and a Common C++ Thread which is * assumed to be the execution context that will be used to perform actual * I/O operations. This class is very anagolous to TCPSession. * * * @author David Sugar * @short streamable tty serial I/O class. */ class __EXPORT TTYStream : protected std::streambuf, public Serial, public std::iostream { private: int doallocate(); friend TTYStream& crlf(TTYStream&); friend TTYStream& lfcr(TTYStream&); protected: char *gbuf, *pbuf; timeout_t timeout; /** * This constructor is used to derive "ttystream", a more * C++ style version of the TTYStream class. */ TTYStream(); /** * Used to allocate the buffer space needed for iostream * operations. This is based on MAX_INPUT. */ void allocate(void); /** * Used to terminate the buffer space and clean up the tty * connection. This function is called by the destructor. */ void endStream(void); /** * This streambuf method is used to load the input buffer * through the established tty serial port. * * @return char from get buffer, EOF also possible. */ int underflow(void); /** * This streambuf method is used for doing unbuffered reads * through the establish tty serial port when in interactive mode. * Also this method will handle proper use of buffers if not in * interative mode. * * @return char from tty serial port, EOF also possible. */ int uflow(void); /** * This streambuf method is used to write the output * buffer through the established tty port. * * @param ch char to push through. * @return char pushed through. */ int overflow(int ch); public: /** * Create and open a tty serial port. * * @param filename char name of device to open. * @param to default timeout. */ TTYStream(const char *filename, timeout_t to = 0); /** * End the tty stream and cleanup. */ virtual ~TTYStream(); /** * Set the timeout control. * * @param to timeout to use. */ inline void setTimeout(timeout_t to) {timeout = to;}; /** * Set tty mode to buffered or "interactive". When interactive, * all streamed I/O is directly sent to the serial port * immediately. * * @param flag bool set to true to make interactive. */ void interactive(bool flag); /** * Flushes the stream input and out buffers, writes * pending output. * * @return 0 on success. */ int sync(void); /** * Get the status of pending operations. This can be used to * examine if input or output is waiting, or if an error has * occured on the serial device. If read buffer contains data * then input is ready and if write buffer contains data it is * first flushed then checked. * * @return true if ready, false if timeout. * @param pend ready check to perform. * @param timeout in milliseconds. */ bool isPending(Pending pend, timeout_t timeout = TIMEOUT_INF); }; /** * A more natural C++ "ttystream" class for use by non-threaded * applications. This class behaves a lot more like fstream and * similar classes. * * @author David Sugar * @short C++ "fstream" style ttystream class. */ class __EXPORT ttystream : public TTYStream { public: /** * Construct an unopened "ttystream" object. */ ttystream(); /** * Construct and "open" a tty stream object. A filename in * the form "device:options[,options]" may be used to pass * device options as part of the open. * * @param name of file and serial options. */ ttystream(const char *name); /** * Open method for a tty stream. * * @param name filename to open. */ void open(const char *name); /** * Close method for a tty stream. */ void close(void); /** * Test to see if stream is opened. */ inline bool operator!() {return (dev < 0);}; }; /** * * The TTYSession aggragates a TTYStream and a Common C++ Thread which is * assumed to be the execution context that will be used to perform actual * I/O operations. This class is very anagolous to TCPSession. * * @author David Sugar * @short This class is very anagolous to TCPSession. */ class __EXPORT TTYSession : public Thread, public TTYStream { public: /** * Create TTY stream that will be managed by it's own thread. * * @param name of tty device to open. * @param pri execution priority. * @param stack allocation needed on some platforms. */ TTYSession(const char *name, int pri = 0, int stack = 0); virtual ~TTYSession(); }; #ifndef _MSWINDOWS_ // Not support this right now....... // class SerialPort; class SerialService; /** * The serial port is an internal class which is attached to and then * serviced by a specified SerialService thread. Derived versions of * this class offer specific functionality such as serial integration * protocols. * * The TTYPort and TTYService classes are used to form thread-pool serviced * serial I/O protocol sets. These can be used when one has a large number * of serial devices to manage, and a single (or limited number of) thread(s) * can then be used to service the tty port objects present. Each tty port * supports a timer control and several virtual methods that the service * thread can call when events occur. This model provides for "callback" * event management, whereby the service thread performs a "callback" into * the port object when events occur. Specific events supported include the * expiration of a TTYPort timer, pending input data waiting to be read, and * "sighup" connection breaks. * * * @author David Sugar * @short base class for thread pool serviced serial I/O. */ class __EXPORT SerialPort: public Serial, public TimerPort { private: SerialPort *next, *prev; SerialService *service; #ifdef USE_POLL struct pollfd *ufd; #endif bool detect_pending; bool detect_output; bool detect_disconnect; friend class SerialService; protected: /** * Construct a tty serial port for a named serial device. * * @param svc pool thread object. * @param name of tty port. */ SerialPort(SerialService *svc, const char *name); /** * Disconnect the Serial Port from the service pool thread * and shutdown the port. */ virtual ~SerialPort(); /** * Used to indicate if the service thread should monitor pending * data for us. */ void setDetectPending( bool ); /** * Get the current state of the DetectPending flag. */ inline bool getDetectPending( void ) const { return detect_pending; } /** * Used to indicate if output ready monitoring should be performed * by the service thread. */ void setDetectOutput( bool ); /** * Get the current state of the DetectOutput flag. */ inline bool getDetectOutput( void ) const { return detect_output; } /** * Called by the service thread when the objects timer * has expired. */ virtual void expired(void); /** * Called by the service thread when input data is pending * for this tty port. Effected by setPacketInput and by * setLineInput. */ virtual void pending(void); /** * Called by the service thread when an exception has occured * such as a hangup. */ virtual void disconnect(void); /** * Transmit "send" data to the serial port. This is not public * since it's meant to support internal protocols rather than * direct public access to the device. * * @return number of bytes send. * @param buf address of buffer to send. * @param len of bytes to send. */ inline int output(void *buf, int len) {return aWrite((char *)buf, len);}; /** * Perform when output is available for sending data. */ virtual void output(void); /** * Receive "input" for pending data from the serial port. This * is not a public member since it's meant to support internal * protocols rather than direct external access to the device. * * @return number of bytes received. * @param buf address of buffer to input. * @param len of input buffer used. */ inline int input(void *buf, int len) {return aRead((char *)buf, len);}; public: /** * Derived setTimer to notify the service thread pool of changes * in expected timeout. This allows SerialService to * reschedule all timers. * * @param timeout in milliseconds. */ void setTimer(timeout_t timeout = 0); /** * Derived incTimer to notify the service thread pool of a * change in expected timeout. This allows SerialService to * reschedule all timers. */ void incTimer(timeout_t timeout); }; /** * The SerialService is a thead service object that is meant to service * attached serial ports. Multiple pool objects may be created and * multiple serial ports may be attached to the same thread of * of execution. This allows one to balance threads and the serial ports * they service. * * The TTYPort and TTYService classes are used to form thread-pool serviced * serial I/O protocol sets. These can be used when one has a large number * of serial devices to manage, and a single (or limited number of) thread(s) * can then be used to service the tty port objects present. Each tty port * supports a timer control and several virtual methods that the service * thread can call when events occur. This model provides for "callback" * event management, whereby the service thread performs a "callback" into * the port object when events occur. Specific events supported include the * expiration of a TTYPort timer, pending input data waiting to be read, and * "sighup" connection breaks. * * * @author David Sugar * @short Thread pool service for serial ports. */ class __EXPORT SerialService : public Thread, private Mutex { private: fd_set connect; int iosync[2]; int hiwater; int count; SerialPort *first, *last; /** * Attach a new serial port to this service thread. * * @param port of SerialPort derived object to attach. */ void attach(SerialPort *port); /** * Detach a serial port from this service thread. * * @param port of SerialPort derived object to remove. */ void detach(SerialPort *port); /** * The service thread itself. */ void run(void); friend class SerialPort; protected: /** * A virtual handler for processing user defined update * requests (1-254) which have been posted through Update. * * @param flag of update request. */ virtual void onUpdate(unsigned char flag); /** * A virtual handler for event loop calls. This can be * used to extend event loop processing. */ virtual void onEvent(void); /** * A virtual handler for adding support for additional * callback events into SerialPort. * * @param port serial port currently being evaluated. */ virtual void onCallback(SerialPort *port); public: /** * Notify service thread that a port has been added or * removed, or a timer changed, so that a new schedule * can be computed for expiring attached ports. This * can also be used to pass requests to the OnUpdate() * event handler. * * @param flag event for OnUpdate, termination, or reschedule. */ void update(unsigned char flag = 0xff); /** * Create a service thread for attaching serial ports. The * thread begins execution with the first attached port. * * @param pri of this thread to run under. * @param stack stack size. * @param id stack ID. */ SerialService(int pri = 0, size_t stack = 0, const char *id = NULL); /** * Terminate the service thread and update attached objects. */ virtual ~SerialService(); /** * Get current reference count. This can be used when selecting * the lead used service handler from a pool. * * @return count of active ports. */ inline int getCount(void) {return count;}; }; #endif #ifdef CCXX_EXCEPTIONS class __EXPORT SerException : public IOException { public: SerException(const String &str) : IOException(str) {}; }; #endif END_NAMESPACE #endif /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 4 * End: */ ucommon-6.0.7/inc/commoncpp/mime.h0000644000175000017500000001411312163025062013763 00000000000000// Copyright (C) 2001-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file mime.h * @short MIME document abstractions. **/ #ifndef COMMONCPP_MIME_H_ #define COMMONCPP_MIME_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_SOCKET_H_ #include #endif NAMESPACE_COMMONCPP class MIMEMultipart; class MIMEItemPart; /** * A container class for multi-part MIME document objects which can * be streamed to a std::ostream destination. * * @author David Sugar * @short container for streamable multi-part MIME documents. */ class __EXPORT MIMEMultipart { protected: friend class MIMEItemPart; char boundry[8]; char mtype[80]; char *header[16]; MIMEItemPart *first, *last; virtual ~MIMEMultipart(); public: /** * Contruct a multi-part document, and describe it's type. * * @param document (content) type. */ MIMEMultipart(const char *document); /** * Stream the headers of the multi-part document. The headers * of individual entities are streamed as part of the body. * * @param output to stream document header into. */ virtual void head(std::ostream *output); /** * Stream the "body" of the multi-part document. This involves * streaming the headers and body of each document part. * * @param output to stream document body into. */ virtual void body(std::ostream *output); /** * Get a string array of the headers to use. This is used to * assist URLStream::post. * * @return array of headers. */ char **getHeaders(void) {return header;}; }; /** * The Multipart form is a MIME multipart document specific for the * construction and delivery of form data to a web server through a * post method. * * @author David Sugar * @short deliver form results as multipart document. */ class __EXPORT MIMEMultipartForm : public MIMEMultipart { protected: virtual ~MIMEMultipartForm(); public: /** * Construct a form result. This is a MIMEMultipart of type * multipart/form-data. */ MIMEMultipartForm(); }; /** * This is used to attach an item part to a MIME multipart document * that is being streamed. The base item part class is used by all * derived items. * * @author David Sugar * @short item or part of a multi-part object. */ class __EXPORT MIMEItemPart { protected: friend class MIMEMultipart; MIMEMultipart *base; MIMEItemPart *next; const char *ctype; /** * Stream the header(s) for the current document part. * * @param output to stream header into. */ virtual void head(std::ostream *output); /** * Stream the content of this document part. * * @param output to stream document body into. */ virtual void body(std::ostream *output) = 0; /** * Construct and attach a document part to a multipart document. * * @param top multipart document to attach to. * @param ct Content-Type to use. */ MIMEItemPart(MIMEMultipart *top, const char *ct); virtual ~MIMEItemPart(); }; /** * This is a document part type for use in submitting multipart form * data to a web server. * * @author David Sugar * @short multipart document part for web form data field. */ class __EXPORT MIMEFormData : public MIMEItemPart { protected: const char *content; const char *name; virtual ~MIMEFormData(); public: /** * Stream header, Content-Disposition form-data. * * @param output stream to send header to. */ void head(std::ostream *output); /** * Stream content (value) of this form data field. * * @param output stream to send body to. */ void body(std::ostream *output); /** * Construct form data field part of multipart form. * * @param top multipart form this is part of * @param name of form data field * @param content of form data field */ MIMEFormData(MIMEMultipartForm *top, const char *name, const char *content); }; END_NAMESPACE #endif /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 4 * End: */ ucommon-6.0.7/inc/commoncpp/thread.h0000644000175000017500000006012512163025062014307 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file commoncpp/thread.h * @short Common C++ thread class and sychronization objects **/ #ifndef COMMONCPP_THREAD_H_ #define COMMONCPP_THREAD_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif #define ENTER_CRITICAL enterMutex(); #define LEAVE_CRITICAL leaveMutex(); NAMESPACE_COMMONCPP class __EXPORT Mutex : protected ucommon::RecursiveMutex { public: inline Mutex() : RecursiveMutex() {}; inline void enterMutex(void) {RecursiveMutex::lock();}; inline void leaveMutex(void) {RecursiveMutex::release();}; inline bool tryEnterMutex(void) {return RecursiveMutex::lock(0l);}; inline void enter(void) {RecursiveMutex::lock();}; inline void leave(void) {RecursiveMutex::release();}; inline bool test(void) {return RecursiveMutex::lock(0l);}; }; /** * The Mutex Counter is a counter variable which can safely be incremented * or decremented by multiple threads. A Mutex is used to protect access * to the counter variable (an integer). An initial value can be specified * for the counter, and it can be manipulated with the ++ and -- operators. * * @author David Sugar * @short Thread protected integer counter. */ class __EXPORT MutexCounter : public Mutex { protected: volatile int counter; public: /** * Create and optionally name a mutex protected counter. */ MutexCounter(); /** * Create and optionally name a mutex protected counter with * an initial value. * * @param initial value of counter. */ MutexCounter(int initial); int operator++(); int operator--(); }; /** * The MutexLock class is used to protect a section of code so that at any * given time only a single thread can perform the protected operation. * * It use Mutex to protect operation. Using this class is usefull and * exception safe. The mutex that has been locked is automatically * released when the function call stack falls out of scope, so one doesnt * have to remember to unlock the mutex at each function return. * * A common use is * * void func_to_protect() * { * MutexLock lock(mutex); * ... operation ... * } * * NOTE: do not declare variable as "MutexLock (mutex)", the mutex will be * released at statement end. * * @author Frediano Ziglio * @short Mutex automatic locker for protected access. */ class __EXPORT MutexLock { private: Mutex& mutex; public: /** * Acquire the mutex * * @param _mutex reference to mutex to aquire. */ inline MutexLock( Mutex& _mutex ) : mutex( _mutex ) { mutex.enterMutex(); } /** * Release the mutex automatically */ // this should be not-virtual inline ~MutexLock() { mutex.leaveMutex(); } }; class __EXPORT ThreadLock : protected ucommon::ThreadLock { public: inline ThreadLock() : ucommon::ThreadLock() {}; inline void readLock(void) {ucommon::ThreadLock::access();}; inline void writeLock(void) {ucommon::ThreadLock::modify();}; inline void tryReadLock(void) {ucommon::ThreadLock::access(0);}; inline void tryWriteLock(void) {ucommon::ThreadLock::modify(0);}; inline void unlock(void) {ucommon::ThreadLock::release();}; }; /** * The ReadLock class is used to protect a section of code through * a ThreadLock for "read" access to the member function. The * ThreadLock is automatically released when the object falls out of * scope. * * A common use is * * void func_to_protect() * { * ReadLock lock(threadlock); * ... operation ... * } * * NOTE: do not declare variable as "ReadLock (threadlock)", the * mutex will be released at statement end. * * @author David Sugar * @short Read mode automatic locker for protected access. */ class __EXPORT ReadLock { private: ThreadLock& tl; public: /** * Wait for read access * * @param _tl reference to lock to aquire. */ inline ReadLock( ThreadLock& _tl ) : tl( _tl ) { tl.readLock(); } /** * Post the semaphore automatically */ // this should be not-virtual inline ~ReadLock() { tl.unlock(); } }; /** * The WriteLock class is used to protect a section of code through * a ThreadLock for "write" access to the member function. The * ThreadLock is automatically released when the object falls out of * scope. * * A common use is * * void func_to_protect() * { * WriteLock lock(threadlock); * ... operation ... * } * * NOTE: do not declare variable as "WriteLock (threadlock)", the * mutex will be released at statement end. * * @author David Sugar * @short Read mode automatic locker for protected access. */ class __EXPORT WriteLock { private: ThreadLock& tl; public: /** * Wait for write access * * @param _tl reference to threadlock to aquire. */ inline WriteLock( ThreadLock& _tl ) : tl( _tl ) { tl.writeLock(); } /** * Post the semaphore automatically */ // this should be not-virtual inline ~WriteLock() { tl.unlock(); } }; class __EXPORT Conditional : private ucommon::Conditional { public: inline Conditional() : ucommon::Conditional() {}; bool wait(timeout_t timeout, bool locked = false); void signal(bool broadcast); inline void enterMutex(void) {ucommon::Conditional::lock();}; inline void leaveMutex(void) {ucommon::Conditional::unlock();}; }; class __EXPORT Semaphore : private ucommon::Semaphore { public: inline Semaphore(unsigned size=0) : ucommon::Semaphore(size) {}; inline bool wait(timeout_t timeout = 0) {return ucommon::Semaphore::wait(timeout);}; inline void post(void) {ucommon::Semaphore::release();}; }; /** * The SemaphoreLock class is used to protect a section of code through * a semaphore so that only x instances of the member function may * execute concurrently. * * A common use is * * void func_to_protect() * { * SemaphoreLock lock(semaphore); * ... operation ... * } * * NOTE: do not declare variable as "SemaohoreLock (semaphore)", the * mutex will be released at statement end. * * @author David Sugar * @short Semaphore automatic locker for protected access. */ class __EXPORT SemaphoreLock { private: Semaphore& sem; public: /** * Wait for the semaphore */ inline SemaphoreLock( Semaphore& _sem ) : sem( _sem ) { sem.wait(); } /** * Post the semaphore automatically */ // this should be not-virtual inline ~SemaphoreLock() { sem.post(); } }; class __EXPORT Event : private ucommon::TimedEvent { public: inline Event() : TimedEvent() {}; inline void wait(void) {ucommon::TimedEvent::wait(Timer::inf);}; inline bool wait(timeout_t timeout) {return ucommon::TimedEvent::wait(timeout);}; inline void signal(void) {ucommon::TimedEvent::signal();}; inline void reset(void) {ucommon::TimedEvent::reset();}; }; class __EXPORT Thread : protected ucommon::JoinableThread { public: /** * How to raise error */ typedef enum Throw { throwNothing, /**< continue without throwing error */ throwObject, /**< throw object that cause error (throw this) */ throwException /**< throw an object relative to error */ } Throw; private: friend class Slog; Throw exceptions; bool detached, terminated; Thread *parent; size_t msgpos; char msgbuf[128]; public: Thread(int pri = 0, size_t stack = 0); virtual ~Thread(); inline void map(void) {JoinableThread::map();}; virtual void initial(void); virtual void notify(Thread *thread); virtual void final(void); virtual void run(void) = 0; void terminate(void); void finalize(void); void detach(void); void start(void); void exit(void); inline void join(void) {JoinableThread::join();}; inline void sync(void) {Thread::exit();}; static inline Thread *get(void) {return (Thread *)JoinableThread::get();}; inline static void yield(void) {ucommon::Thread::yield();}; inline static void sleep(timeout_t msec = TIMEOUT_INF) {ucommon::Thread::sleep(msec);}; bool isRunning(void); bool isThread(void); /** * Get exception mode of the current thread. * * @return exception mode. */ static Throw getException(void); /** * Set exception mode of the current thread. * * @return exception mode. */ static void setException(Throw mode); /** * Get the thread id. */ inline pthread_t getId(void) {return tid;}; }; /** * This class is used to access non-reentrant date and time functions in the * standard C library. * * The class has two purposes: * - 1 To be used internaly in CommonCpp's date and time classes to make them * thread safe. * - 2 To be used by clients as thread safe replacements to the standard C * functions, much like Thread::sleep() represents a thread safe version * of the standard sleep() function. * * @note The class provides one function with the same name as its equivalent * standard function and one with another, unique name. For new clients, * the version with the unique name is recommended to make it easy to * grep for accidental usage of the standard functions. The version with * the standard name is provided for existing clients to sed replace their * original version. * * @note Also note that some functions that returned pointers have been redone * to take that pointer as an argument instead, making the caller * responsible for memory allocation/deallocation. This is almost * how POSIX specifies *_r functions (reentrant versions of the * standard time functions), except the POSIX functions also return the * given pointer while we do not. We don't use the *_r functions as they * aren't all generally available on all platforms yet. * * @author Idar Tollefsen * @short Thread safe date and time functions. */ class __EXPORT SysTime { public: static time_t getTime(time_t *tloc = NULL); static time_t time(time_t *tloc) { return getTime(tloc); }; static int getTimeOfDay(struct timeval *tp); static int gettimeofday(struct timeval *tp, struct timezone *) { return getTimeOfDay(tp); }; static struct tm *getLocalTime(const time_t *clock, struct tm *result); static struct tm *locatime(const time_t *clock, struct tm *result) { return getLocalTime(clock, result); }; static struct tm *getGMTTime(const time_t *clock, struct tm *result); static struct tm *gmtime(const time_t *clock, struct tm *result) { return getGMTTime(clock, result);}; }; /** * Timer ports are used to provide synchronized timing events when managed * under a "service thread" such as SocketService. This is made into a * stand-alone base class since other derived libraries (such as the * serial handlers) may also use the pooled "service thread" model * and hence also require this code for managing timing. * * @author David Sugar * @short synchronized millisecond timing for service threads. */ class __EXPORT TimerPort { #ifndef _MSWINDOWS_ struct timeval timer; #else DWORD timer; #endif bool active; public: /** * Create a timer, mark it as inactive, and set the initial * "start" time to the creation time of the timer object. This * allows "incTimer" to initially refer to time delays relative * to the original start time of the object. */ TimerPort(); /** * Set a new start time for the object based on when this call is * made and optionally activate the timer for a specified number * of milliseconds. This can be used to set the starting time * of a realtime session. * * @param timeout delay in milliseconds from "now" */ void setTimer(timeout_t timeout = 0); /** * Set a timeout based on the current time reference value either * from object creation or the last setTimer(). This reference * can be used to time synchronize realtime data over specified * intervals and force expiration when a new frame should be * released in a synchronized manner. * * @param timeout delay in milliseconds from reference. */ void incTimer(timeout_t timeout); /** * Adjust a timeout based on the current time reference value either * from object creation or the last setTimer(). This reference * can be used to time synchronize realtime data over specified * intervals and force expiration when a new frame should be * released in a synchronized manner. * * @param timeout delay in milliseconds from reference. */ void decTimer(timeout_t timeout); /** * Sleep until the current timer expires. This is useful in time * syncing realtime periodic tasks. */ void sleepTimer(void); /** * This is used to "disable" the service thread from expiring * the timer object. It does not effect the reference time from * either creation or a setTimer(). */ void endTimer(void); /** * This is used by service threads to determine how much time * remains before the timer expires based on a timeout specified * in setTimer() or incTimer(). It can also be called after * setting a timeout with incTimer() to see if the current timeout * has already expired and hence that the application is already * delayed and should skip frame(s). * * return time remaining in milliseconds, or TIMEOUT_INF if * inactive. */ timeout_t getTimer(void) const; /** * This is used to determine how much time has elapsed since a * timer port setTimer benchmark time was initially set. This * allows one to use setTimer() to set the timer to the current * time and then measure elapsed time from that point forward. * * return time elapsed in milliseconds, or TIMEOUT_INF if * inactive. */ timeout_t getElapsed(void) const; }; #ifndef _MSWINDOWS_ struct timespec *getTimeout(struct timespec *spec, timeout_t timeout); #endif inline struct tm *localtime_r(const time_t *t, struct tm *b) {return SysTime::getLocalTime(t, b);} inline char *ctime_r(const time_t *t, char *buf) {return ctime(t);} inline struct tm *gmtime_r(const time_t *t, struct tm *b) {return SysTime::getGMTTime(t, b);} inline char *asctime_r(const struct tm *tm, char *b) {return asctime(tm);} inline Thread *getThread(void) {return Thread::get();} /** * The buffer class represents an IPC service that is built upon a buffer * of fixed capacity that can be used to transfer objects between one or * more producer and consumer threads. Producer threads post objects * into the buffer, and consumer threads wait for and receive objects from * the buffer. Semaphores are used to to block the buffer from overflowing * and indicate when there is data available, and mutexes are used to protect * multiple consumers and producer threads from stepping over each other. * * The buffer class is an abstract class in that the actual data being * buffered is not directly specified within the buffer class itself. The * buffer class should be used as a base class for a class that actually * impliments buffering and which may be aware of the data types actually * are being buffered. A template class could be created based on buffer * for this purpose. Another possibility is to create a class derived * from both Thread and Buffer which can be used to implement message passing * threads. * * @author David Sugar * @short Producer/Consumer buffer for use between threads. */ #ifdef _MSWINDOWS_ class __EXPORT Buffer : public Mutex #else class __EXPORT Buffer : public Conditional #endif { private: #ifdef _MSWINDOWS_ HANDLE sem_head, sem_tail; #endif size_t _size; size_t _used; protected: /** * Invoke derived class buffer peeking method. * @return size of object found. * @param buf pointer to copy contents of head of buffer to. */ virtual size_t onPeek(void *buf) = 0; /** * Invoke derived class object request from buffer. * @return size of object returned. * @param buf pointer to hold object returned from the buffer. */ virtual size_t onWait(void *buf) = 0; /** * Invoke derived class posting of object to buffer. * @return size of object posted. * @param buf pointer to object being posted to the buffer. */ virtual size_t onPost(void *buf) = 0; public: /** * value to return when a timed operation returned with a * timeout. */ static const size_t timeout; /** * Create a buffer object of known capacity. * @param capacity is the integer capacity of the buffer. */ Buffer(size_t capacity); /** * In derived functions, may be used to free the actual memory * used to hold buffered data. */ virtual ~Buffer(); /** * Return the capacity of the buffer as specified at creation. * @return size of buffer. */ inline size_t getSize(void) {return _size;}; /** * Return the current capacity in use for the buffer. Free space * is technically getSize() - getUsed(). * @return integer used capacity of the buffer. * @see #getSize */ inline size_t getUsed(void) {return _used;}; /** * Let one or more threads wait for an object to become available * in the buffer. The waiting thread(s) will wait forever if no * object is ever placed into the buffer. * * @return size of object passed by buffer in bytes. * @param buf pointer to store object retrieved from the buffer. * @param timeout time to wait. */ size_t wait(void *buf, timeout_t timeout = 0); /** * Post an object into the buffer and enable a waiting thread to * receive it. * * @return size of object posted in bytes. * @param buf pointer to object to store in the buffer. * @param timeout time to wait. */ size_t post(void *buf, timeout_t timeout = 0); /** * Peek at the current content (first object) in the buffer. * * @return size of object in the buffer. * @param buf pointer to store object found in the buffer. */ size_t peek(void *buf); /** * New virtual to test if buffer is a valid object. * @return true if object is valid. */ virtual bool isValid(void); }; /** * A buffer class that holds a known capacity of fixed sized objects defined * during creation. * * @author David Sugar * @short producer/consumer buffer for fixed size objects. */ class __EXPORT FixedBuffer : public Buffer { private: char *buf, *head, *tail; size_t objsize; protected: /** * Return the first object in the buffer. * @return predefined size of this buffers objects. * @param buf pointer to copy contents of head of buffer to. */ size_t onPeek(void *buf); /** * Wait for and return a fixed object in the buffer. * @return predefined size of this buffers objects. * @param buf pointer to hold object returned from the buffer. */ size_t onWait(void *buf); /** * Post an object of the appropriate size into the buffer. * @return predefined size of this buffers objects. * @param buf pointer to data to copy into the buffer. */ size_t onPost(void *buf); public: /** * Create a buffer of known capacity for objects of a specified * size. * * @param capacity of the buffer. * @param objsize for each object held in the buffer. */ FixedBuffer(size_t capacity, size_t objsize); /** * Create a copy of an existing fixed size buffer and duplicate * it's contents. * * @param fb existing FixedBuffer object. */ FixedBuffer(const FixedBuffer &fb); /** * Destroy the fixed buffer and free the memory used to store objects. */ virtual ~FixedBuffer(); FixedBuffer &operator=(const FixedBuffer &fb); bool isValid(void); }; /** * Somewhat generic queue processing class to establish a producer * consumer queue. This may be used to buffer cdr records, or for * other purposes where an in-memory queue is needed for rapid * posting. This class is derived from Mutex and maintains a linked * list. A thread is used to dequeue data and pass it to a callback * method that is used in place of "run" for each item present on the * queue. The conditional is used to signal the run thread when new * data is posted. * * This class was changed by Angelo Naselli to have a timeout on the queue * * @short in memory data queue interface. * @author David Sugar */ class __EXPORT ThreadQueue : public Mutex, public Thread, public Semaphore { private: void run(void); // private run method protected: typedef struct _data { struct _data *next; unsigned len; char data[1]; } data_t; timeout_t timeout; bool started; data_t *first, *last; // head/tail of list String name; /* * Overloading of final(). It demarks Semaphore to avoid deadlock. */ virtual void final(); /** * Start of dequeing. Maybe we need to connect a database * or something, so we have a virtual... */ virtual void startQueue(void); /** * End of dequeing, we expect the queue is empty for now. Maybe * we need to disconnect a database or something, so we have * another virtual. */ virtual void stopQueue(void); /** * A derivable method to call when the timout is expired. */ virtual void onTimer(void); /** * Virtual callback method to handle processing of a queued * data items. After the item is processed, it is deleted from * memory. We can call multiple instances of runQueue in order * if multiple items are waiting. * * @param data item being dequed. */ virtual void runQueue(void *data) = 0; public: /** * Create instance of our queue and give it a process priority. * * @param id queue ID. * @param pri process priority. * @param stack stack size. */ ThreadQueue(const char *id, int pri, size_t stack = 0); /** * Destroy the queue. */ virtual ~ThreadQueue(); /** * Set the queue timeout. * When the timer expires, the onTimer() method is called * for the thread * * @param timeout timeout in milliseconds. */ void setTimer(timeout_t timeout); /** * Put some unspecified data into this queue. A new qd * structure is created and sized to contain a copy of * the actual content. * * @param data pointer to data. * @param len size of data. */ void post(const void *data, unsigned len); }; /** @relates Buffer */ inline size_t get(Buffer &b, void *o, timeout_t t = 0) {return b.wait(o, t);} /** @relates Buffer */ inline size_t put(Buffer &b, void *o, timeout_t t = 0) {return b.post(o, t);} /** @relates Buffer */ inline size_t peek(Buffer &b, void *o) {return b.peek(o);} END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/slog.h0000644000175000017500000002127312163025062014005 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/slog.h * @short System logging facilities abstraction. **/ #ifndef COMMONCPP_SLOG_H_ #define COMMONCPP_SLOG_H_ #include #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif #ifndef COMMONCPP_THREAD_H_ #include #endif NAMESPACE_COMMONCPP /** * The slog class is used to stream messages to the system's logging facility (syslogd). * A default slog object is used to avoid confusion with the native syslog * facility and to imply a logical relationship to the C++ clog(). * * The key difference is that the slog object sends it's output to the * system logging daemon (typically syslogd) rather than through stderr. * slog can be streamed with the << operator just * like clog; a default slog object is pre-initialized, and you stream * character data to it. * * The slog allows one to specify logging levels and other properties through the () operators. * Hence, once can do: * *
 * slog("mydaemon", SLOG_DAEMON, SLOG_EMERGENCY) << I just died << endl; 
* * or things like: * *
 * slog("mydaemon", SLOG_DAEMON);
 * slog(SLOG_INFO) << "daemon initalized" << endl; 
* * The intent is to be as common-place and as convenient to use as the stderr based clog facility * found in C++, and this is especially useful for C++ daemons. * * The std::flush manipulator doesn't work. Either the * std::endl or std::ends manipulators * must be used to cause the output to be sent to the daemon. * * When this class is used on a system that doesn't have the syslog headers * (i.e. a non-posix win32 box), the output goes to the a file with the same name * as the syslog identifier string with '.log' appended to it. If the identifier string ends in * '.exe', the '.exe' is removed before the '.log' is appened. (e.g. the identifier foo.exe will * generate a log file named foo.log) * * @author David Sugar *
Minor docs & hacks by Jon Little * * @short system logging facility class. */ class __EXPORT Slog : protected std::streambuf, public std::ostream { public: typedef enum Class { classSecurity, classAudit, classDaemon, classUser, classDefault, classLocal0, classLocal1, classLocal2, classLocal3, classLocal4, classLocal5, classLocal6, classLocal7 } Class; typedef enum Level { levelEmergency = 1, levelAlert, levelCritical, levelError, levelWarning, levelNotice, levelInfo, levelDebug } Level; private: pthread_mutex_t lock; FILE *syslog; int priority; Level _level; bool _enable; bool _clogEnable; protected: /** * This is the streambuf function that actually outputs the data * to the device. Since all output should be done with the standard * ostream operators, this function should never be called directly. */ int overflow(int c); public: /** * Default (and only) constructor. The default log level is set to * SLOG_DEBUG. There is no default log facility set. One should be * set before attempting any output. This is done by the open() or the * operator()(const char*, Class, Level) * functions. */ Slog(void); virtual ~Slog(void); void close(void); /** * (re)opens the output stream. * @param ident The identifier portion of the message sent to the syslog daemon. * @param grp The log facility the message is sent to */ void open(const char *ident, Class grp = classUser); /** * Sets the log identifier, level, and class to use for subsequent output * @param ident The identifier portion of the message * @param grp The log facility the message is sent to * @param level The log level of the message */ Slog &operator()(const char *ident, Class grp = classUser, Level level = levelError); /** * Changes the log level and class to use for subsequent output * @param level The log level of the message * @param grp The log facility the message is sent to */ Slog &operator()(Level level, Class grp = classDefault); /** * Does nothing except return *this. */ Slog &operator()(void); /** * Print a formatted syslog string. * * @param format string. */ void error(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void warn(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void debug(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void emerg(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void alert(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void critical(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void notice(const char *format, ...); /** * Print a formatted syslog string. * * @param format string. */ void info(const char *format, ...); /** * Sets the logging level. * @param enable is the logging level to use for further output */ inline void level(Level enable) {_level = enable;}; /** * Enables or disables the echoing of the messages to clog in addition * to the syslog daemon. This is enabled by the default class constructor. * @param f true to enable, false to disable clog output */ inline void clogEnable(bool f=true) {_clogEnable = f;}; inline Slog &warn(void) {return operator()(Slog::levelWarning);}; inline Slog &error(void) {return operator()(Slog::levelError);}; inline Slog &debug(void) {return operator()(Slog::levelDebug);}; inline Slog &emerg(void) {return operator()(Slog::levelEmergency);}; inline Slog &alert(void) {return operator()(Slog::levelAlert);}; inline Slog &critical(void) {return operator()(Slog::levelCritical);}; inline Slog ¬ice(void) {return operator()(Slog::levelNotice);}; inline Slog &info(void) {return operator()(Slog::levelInfo);}; }; extern __EXPORT Slog slog; END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/address.h0000644000175000017500000007651512163025062014477 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/address.h * @short Network addresses and sockets related classes. **/ #ifndef COMMONCPP_ADDRESS_H_ #define COMMONCPP_ADDRESS_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_THREAD_H_ #include #endif #ifndef COMMMONCPP_EXCEPTION_H_ #include #endif NAMESPACE_COMMONCPP // future definition of ipv4 specific classes, now defines #define INET_IPV4_ADDRESS_SIZE 16 #define CIDR_IPV4_ADDRESS_SIZE 32 #define INET_IPV6_ADDRESS_SIZE 40 #define CIDR_IPV6_ADDRESS_SIZE 45 #define CIDR IPV4Cidr #define InetAddress IPV4Address #define InetHostAddress IPV4Host #define InetMaskAddress IPV4Mask #define InetMcastAddress IPV4Multicast #define InetMcastAddressValidator IPV4MulticastValidator #define InetAddrValidator IPV4Validator #define BroadcastAddress IPV4Broadcast /** * Transport Protocol Ports. */ typedef unsigned short tpport_t; class IPV4Host; /** * Classes derived from IPV4Address would require an specific * validator to pass to the IPV4Address constructor. This is a base * class for classes of function objects used by such derived classes. * * @author Federico Montesino * @short Abstract base class for derived inet addresses validators. */ class __EXPORT IPV4Validator { public: /** * Constructor. Does not deal with any state. */ IPV4Validator() { }; /** * keeps compilers happy. */ virtual ~IPV4Validator() {}; /** * Pure virtual application operator. Apply the validation * algorithm specific to derived classes. */ virtual void operator()(const in_addr address) const = 0; }; /** * Class for the function object that validates multicast addresses. * Implements a specific application operator to validate multicast * addresses. * * @author Federico Montesino * @short Validating class specialized for multicast addresses. */ class __EXPORT IPV4MulticastValidator: public IPV4Validator { public: /** * Constructor. Does not deal with any state. */ IPV4MulticastValidator(){}; /** * Keeps compilers happy. */ virtual ~IPV4MulticastValidator(){}; /** * Application operator. Apply the validation algorithm * specific to multicast addresses */ void operator()(const in_addr address) const; }; /** * The CIDR class is used to support routing tables and validate address * policies. * * @author David Sugar * @short Classless Internet Domain Routing */ class __EXPORT IPV4Cidr { protected: struct in_addr netmask, network; unsigned getMask(const char *cp) const; public: /** * Get network address associated with this cidr. * * @return system binary coded address. */ inline struct in_addr getNetwork(void) const {return network;}; /** * Get network mask associated with this cidr. * * @return system binary coded network mask. */ inline struct in_addr getNetmask(void) const {return netmask;}; /** * Compute the broadcast address associated with this cidr. * * @return system binary coded network address. */ struct in_addr getBroadcast(void) const; /** * Set the cidr from a full or partial hostname, or from an * address/mask, or a host/bits specification. * * @param cidr string to use. */ void set(const char *cidr); /** * Construct a new cidr from a string. * * @param cidr string to use. */ IPV4Cidr(const char *cidr); /** * Construct an empty cidr. */ IPV4Cidr(); /** * Construct a copy of a cidr. * * @param cidr to copy from. */ IPV4Cidr(IPV4Cidr &); /** * See if a socket address is a member of this cidr's network. * * @param saddr pointer to test. * @return true if member of cidr. */ bool isMember(const struct sockaddr *saddr) const; /** * See if a low level address object is a member of this cidr's net. * * @param inaddr object to test. * @return true if member of cidr. */ bool isMember(const struct in_addr &inaddr) const; inline bool operator==(const struct sockaddr *a) const {return isMember(a);}; inline bool operator==(const struct in_addr &a) const {return isMember(a);}; }; #ifdef CCXX_IPV6 /** * The CIDR class is used to support routing tables and validate address * policies. * * @author David Sugar * @short Classless Internet Domain Routing */ class __EXPORT IPV6Cidr { protected: struct in6_addr netmask, network; unsigned getMask(const char *cp) const; public: /** * Get network address associated with this cidr. * * @return system binary coded address. */ inline struct in6_addr getNetwork(void) const {return network;}; /** * Get network mask associated with this cidr. * * @return system binary coded network mask. */ inline struct in6_addr getNetmask(void) const {return netmask;}; /** * Compute the broadcast address associated with this cidr. * * @return system binary coded network address. */ struct in6_addr getBroadcast(void) const; /** * Set the cidr from a full or partial hostname, or from a * host/bits specification. * * @param cidr string to use. */ void set(const char *cidr); /** * Construct a new cidr from a string. * * @param cidr string to use. */ IPV6Cidr(const char *cidr); /** * Construct an empty cidr. */ IPV6Cidr(); /** * Construct a copy of a cidr. * * @param cidr to copy from. */ IPV6Cidr(IPV6Cidr &); /** * See if a socket address is a member of this cidr's network. * * @param saddr pointer to test. * @return true if member of cidr. */ bool isMember(const struct sockaddr *saddr) const; /** * See if a low level address object is a member of this cidr's net. * * @param inaddr object to test. * @return true if member of cidr. */ bool isMember(const struct in6_addr &inaddr) const; inline bool operator==(const struct sockaddr *sa) const {return isMember(sa);}; inline bool operator==(const struct in6_addr &a) const {return isMember(a);}; }; #endif /** * The network name and address objects are all derived from a common * IPV4Address base class. Specific classes, such as IPV4Host, * IPV4Mask, etc, are defined from IPV4Address entirely so that the * manner a network address is being used can easily be documented and * understood from the code and to avoid common errors and accidental misuse * of the wrong address object. For example, a "connection" to something * that is declared as a "IPV4Host" can be kept type-safe from a * "connection" accidently being made to something that was declared a * "IPV4Broadcast". * * @author David Sugar * @short Internet Address binary data type. */ class __EXPORT IPV4Address { private: // The validator given to an IPV4Address object must not be a // transient object, but that must exist at least until the // last address object of its kind is deleted. This is an // artifact to be able to do specific checks for derived // classes inside constructors. const InetAddrValidator *validator; protected: struct in_addr * ipaddr; size_t addr_count; mutable char* hostname; // hostname for ipaddr[0]. Used by getHostname #if defined(_MSWINDOWS_) static MutexCounter counter; #else static Mutex mutex; #endif /** * Sets the IP address from a string representation of the * numeric address, ie "127.0.0.1" * * @param host The string representation of the IP address * @return true if successful */ bool setIPAddress(const char *host); /** * Used to specify a host name or numeric internet address. * * @param host The string representation of the IP address or * a hostname, , if NULL, it will default to INADDR_ANY */ void setAddress(const char *host); public: /** * Create an Internet Address object with an empty (0.0.0.0) * address. * * @param validator optional validator function object, intended for * derived classes. */ IPV4Address(const InetAddrValidator *validator = NULL); /** * Convert the system internet address data type (struct in_addr) * into a Common C++ IPV4Address object. * * @param addr struct of system used binary internet address. * @param validator optional validator function object, intended for * derived classes. */ IPV4Address(struct in_addr addr, const InetAddrValidator *validator = NULL); /** * Convert a null terminated ASCII host address string * (example: "127.0.0.1") or host address name (example: * "www.voxilla.org") directly into a Common C++ IPV4Address * object. * * @param address null terminated C string. * @param validator optional validator function object, intended for * derived classes. */ IPV4Address(const char *address, const InetAddrValidator *validator = NULL); /** * Copy constructor */ IPV4Address(const IPV4Address &rhs); /** * Destructor */ virtual ~IPV4Address(); /** * Provide a string representation of the value (Internet Address) * held in the IPV4Address object. * * @return string representation of IPV4Address. */ const char *getHostname(void) const; /** * May be used to verify if a given IPV4Address returned * by another function contains a "valid" address, or "0.0.0.0" * which is often used to mark "invalid" IPV4Address values. * * @return true if address != 0.0.0.0. */ bool isInetAddress(void) const; /** * Provide a low level system usable struct in_addr object from * the contents of IPV4Address. This is needed for services such * as bind() and connect(). * * @return system binary coded internet address. */ struct in_addr getAddress(void) const; /** * Provide a low level system usable struct in_addr object from * the contents of IPV4Address. This is needed for services such * as bind() and connect(). * * @param i for IPV4Addresses with multiple addresses, returns the * address at this index. User should call getAddressCount() * to determine the number of address the object contains. * @return system binary coded internet address. If parameter i is * out of range, the first address is returned. */ struct in_addr getAddress(size_t i) const; /** * Returns the number of internet addresses that an IPV4Address object * contains. This usually only happens with IPV4Host objects * where multiple IP addresses are returned for a DNS lookup */ size_t getAddressCount() const { return addr_count; } IPV4Address &operator=(const char *str); IPV4Address &operator=(struct in_addr addr); IPV4Address &operator=(const IPV4Address &rhs); /** * Allows assignment from the return of functions like * inet_addr() or htonl() */ IPV4Address &operator=(unsigned long addr); inline IPV4Address &operator=(unsigned int addr) {return *this = (unsigned long) addr; } inline bool operator!() const {return !isInetAddress();}; /** * Compare two internet addresses to see if they are equal * (if they specify the physical address of the same internet host). * * If there is more than one IP address in either IPV4Address object, * this will return true if all of the IP addresses in the smaller * are in the larger in any order. */ bool operator==(const IPV4Address &a) const; /** * Compare two internet addresses to see if they are not * equal (if they each refer to unique and different physical * ip addresses). * * This is implimented in terms of operator== */ bool operator!=(const IPV4Address &a) const; }; /** * Internet addresses used specifically as masking addresses (such as " * 255.255.255.0") are held in the IPV4Mask derived object. The * seperate class is used so that C++ type casting can automatically * determine when an IPV4Address object is really a mask address object * rather than simply using the base class. This also allows manipulative * operators for address masking to operate only when presented with a * Masked address as well as providing cleaner and safer source. * * @author David Sugar * @short Internet Address Mask such as subnet masks. */ class __EXPORT IPV4Mask : public IPV4Address { public: /** * Create the mask from a null terminated ASCII string such as * "255.255.255.128". * * @param mask null terminated ASCII mask string. */ IPV4Mask(const char *mask); /** * Masks are usually used to coerce host addresses into a specific * router or class domain. This can be done by taking the Inet * Host Address object and "and"ing it with an address mask. This * operation can be directly expressed in C++ through the & operator. * * @return a internet host address that has been masked. * @param addr host address to be masked by subnet. * @param mask inetnet mask address object to mask by. */ friend __EXPORT IPV4Host operator&(const IPV4Host &addr, const IPV4Mask &mask); /** * Allows assignment from the return of functions like * inet_addr() or htonl() */ IPV4Address &operator=(unsigned long addr) { return IPV4Address::operator =(addr); } }; /** * This object is used to hold the actual and valid internet address of a * specific host machine that will be accessed through a socket. * * @author David Sugar * @short Address of a specific Internet host machine. */ class __EXPORT IPV4Host : public IPV4Address { private: static IPV4Host _host_; public: /** * Create a new host address for a specific internet host. The * internet host can be specified in a null terminated ASCII * string and include either the physical host address or the * DNS name of a host machine. Hence, an IPV4Host * ("www.voxilla.org") can be directly declaired in this manner. * * Defaults to the IP address that represents the interface matching * "gethostname()". * * @param host dns or physical address of an Internet host. */ IPV4Host(const char *host = NULL); /** * Convert a system socket binary address such as may be * returned through the accept() call or getsockpeer() into * an internet host address object. * * @param addr binary address of internet host. */ IPV4Host(struct in_addr addr); /** * Allows assignment from the return of functions like * inet_addr() or htonl() */ IPV4Address &operator=(unsigned long addr) { return IPV4Address::operator =(addr); } /** * Mask the internet host address object with a network mask address. * This is commonly used to coerce an address by subnet. */ IPV4Host &operator&=(const IPV4Mask &mask); friend class IPV4Mask; friend __EXPORT IPV4Host operator&(const IPV4Host &addr, const IPV4Mask &mask); }; /** * The broadcast address object is used to store the broadcast address for * a specific subnet. This is commonly used for UDP broadcast operations. */ class __EXPORT IPV4Broadcast : public IPV4Address { public: /** * Specify the physical broadcast address to use and create a new * broadcast address object based on a null terminated ASCII * string. * * @param net null terminated ASCII network address. */ IPV4Broadcast(const char *net = "255.255.255.255"); }; /** * A specialization of IPV4Address that provides address validation * for multicast addresses. Whenever its value changes the new value * is checked to be in the range from 224.0.0.1 through * 239.255.255.255. If it is not, an exception is thrown. * * @short A multicast network address. * @author Federico Montesino */ class __EXPORT IPV4Multicast: public IPV4Address { public: /** * Create an Internet Multicast Address object with an empty * (0.0.0.0) address. */ IPV4Multicast(); /** * Convert the system internet address data type (struct in_addr) * into a Common C++ IPV4Multicast object. * * @param address struct of system used binary internet address. */ IPV4Multicast(const struct in_addr address); /** * Convert a null terminated ASCII multicast address string * (example: "224.0.0.1") or multicast name string (example: * "sap.mcast.net") directly into a Common C++ * IPV4Multicast object. Works like IPV4Address(const * char*). * * @param address null terminated C string. */ IPV4Multicast(const char *address); private: /** * Check the address in addr is a valid multicast * address. In case not, throws an exception. * * @param address a system network address * @return true if validation succeeded */ static const IPV4MulticastValidator validator; }; extern __EXPORT std::ostream& operator<<(std::ostream &os, const IPV4Address &ia); inline struct in_addr getaddress(const IPV4Address &ia) {return ia.getAddress();} #ifdef CCXX_IPV6 class IPV6Host; /** * Classes derived from IPV6Address would require an specific * validator to pass to the IPV6Address constructor. This is a base * class for classes of function objects used by such derived classes. * * @author Federico Montesino * @short Abstract base class for derived inet addresses validators. */ class __EXPORT IPV6Validator { public: /** * Constructor. Does not deal with any state. */ IPV6Validator() { }; /** * Keeps compilers happy. */ virtual ~IPV6Validator() {}; /** * Pure virtual application operator. Apply the validation * algorithm specific to derived classes. */ virtual void operator()(const in6_addr address) const = 0; }; /** * Class for the function object that validates multicast addresses. * Implements a specific application operator to validate multicast * addresses. * * @author Federico Montesino * @short Validating class specialized for multicast addresses. */ class __EXPORT IPV6MulticastValidator: public IPV6Validator { public: /** * Constructor. Does not deal with any state. */ IPV6MulticastValidator(){}; /** * Keeps compilers happy... */ virtual ~IPV6MulticastValidator(){}; /** * Application operator. Apply the validation algorithm * specific to multicast addresses */ void operator()(const in6_addr address) const; }; /** * The network name and address objects are all derived from a common * IPV6Address base class. Specific classes, such as IPV4Host, * IPV6Mask, etc, are defined from IPV6Address entirely so that the * manner a network address is being used can easily be documented and * understood from the code and to avoid common errors and accidental misuse * of the wrong address object. For example, a "connection" to something * that is declared as a "IPV6Host" can be kept type-safe from a * "connection" accidently being made to something that was declared a * "IPV6Broadcast". * * @author David Sugar * @short Internet Address binary data type. */ class __EXPORT IPV6Address { private: // The validator given to an IPV4Address object must not be a // transient object, but that must exist at least until the // last address object of its kind is deleted. This is an // artifact to be able to do specific checks for derived // classes inside constructors. const IPV6Validator *validator; protected: struct in6_addr * ipaddr; size_t addr_count; mutable char* hostname; // hostname for ipaddr[0]. Used by getHostname #if defined(_MSWINDOWS_) static MutexCounter counter; #else static Mutex mutex; #endif /** * Sets the IP address from a string representation of the * numeric address, ie "127.0.0.1" * * @param host The string representation of the IP address * @return true if successful */ bool setIPAddress(const char *host); /** * Used to specify a host name or numeric internet address. * * @param host The string representation of the IP address or * a hostname, , if NULL, it will default to INADDR_ANY */ void setAddress(const char *host); public: /** * Create an Internet Address object with an empty (0.0.0.0) * address. * * @param validator optional validator function object, intended for * derived classes. */ IPV6Address(const IPV6Validator *validator = NULL); /** * Convert the system internet address data type (struct in_addr) * into a Common C++ IPV6Address object. * * @param addr struct of system used binary internet address. * @param validator optional validator function object, intended for * derived classes. */ IPV6Address(struct in6_addr addr, const IPV6Validator *validator = NULL); /** * Convert a null terminated ASCII host address string * (example: "127.0.0.1") or host address name (example: * "www.voxilla.org") directly into a Common C++ IPV6Address * object. * * @param address null terminated C string. * @param validator optional validator function object, intended for * derived classes. */ IPV6Address(const char *address, const IPV6Validator *validator = NULL); /** * Copy constructor */ IPV6Address(const IPV6Address &rhs); /** * Destructor */ virtual ~IPV6Address(); /** * Provide a string representation of the value (Internet Address) * held in the IPV6Address object. * * @return string representation of IPV6Address. */ const char *getHostname(void) const; /** * May be used to verify if a given IPV6Address returned * by another function contains a "valid" address, or "0.0.0.0" * which is often used to mark "invalid" IPV6Address values. * * @return true if address != 0.0.0.0. */ bool isInetAddress(void) const; /** * Provide a low level system usable struct in_addr object from * the contents of IPV6Address. This is needed for services such * as bind() and connect(). * * @return system binary coded internet address. */ struct in6_addr getAddress(void) const; /** * Provide a low level system usable struct in_addr object from * the contents of IPV6Address. This is needed for services such * as bind() and connect(). * * @param i for IPV6Addresses with multiple addresses, returns the * address at this index. User should call getAddressCount() * to determine the number of address the object contains. * @return system binary coded internet address. If parameter i is * out of range, the first address is returned. */ struct in6_addr getAddress(size_t i) const; /** * Returns the number of internet addresses that an IPV6Address object * contains. This usually only happens with IPV6Host objects * where multiple IP addresses are returned for a DNS lookup */ size_t getAddressCount() const { return addr_count; } IPV6Address &operator=(const char *str); IPV6Address &operator=(struct in6_addr addr); IPV6Address &operator=(const IPV6Address &rhs); inline bool operator!() const {return !isInetAddress();}; /** * Compare two internet addresses to see if they are equal * (if they specify the physical address of the same internet host). * * If there is more than one IP address in either IPV6Address object, * this will return true if all of the IP addresses in the smaller * are in the larger in any order. */ bool operator==(const IPV6Address &a) const; /** * Compare two internet addresses to see if they are not * equal (if they each refer to unique and different physical * ip addresses). * * This is implimented in terms of operator== */ bool operator!=(const IPV6Address &a) const; }; /** * Internet addresses used specifically as masking addresses (such as " * 255.255.255.0") are held in the IPV6Mask derived object. The * seperate class is used so that C++ type casting can automatically * determine when an IPV6Address object is really a mask address object * rather than simply using the base class. This also allows manipulative * operators for address masking to operate only when presented with a * Masked address as well as providing cleaner and safer source. * * @author David Sugar * @short Internet Address Mask such as subnet masks. */ class __EXPORT IPV6Mask : public IPV6Address { public: /** * Create the mask from a null terminated ASCII string such as * "255.255.255.128". * * @param mask null terminated ASCII mask string. */ IPV6Mask(const char *mask); /** * Masks are usually used to coerce host addresses into a specific * router or class domain. This can be done by taking the Inet * Host Address object and "and"ing it with an address mask. This * operation can be directly expressed in C++ through the & operator. * * @return a internet host address that has been masked. * @param addr host address to be masked by subnet. * @param mask inetnet mask address object to mask by. */ friend __EXPORT IPV6Host operator&(const IPV6Host &addr, const IPV6Mask &mask); }; /** * This object is used to hold the actual and valid internet address of a * specific host machine that will be accessed through a socket. * * @author David Sugar * @short Address of a specific Internet host machine. */ class __EXPORT IPV6Host : public IPV6Address { public: /** * Create a new host address for a specific internet host. The * internet host can be specified in a null terminated ASCII * string and include either the physical host address or the * DNS name of a host machine. Hence, an IPV6Host * ("www.voxilla.org") can be directly declaired in this manner. * * Defaults to the IP address that represents the interface matching * "gethostname()". * * @param host dns or physical address of an Internet host. */ IPV6Host(const char *host = NULL); /** * Convert a system socket binary address such as may be * returned through the accept() call or getsockpeer() into * an internet host address object. * * @param addr binary address of internet host. */ IPV6Host(struct in6_addr addr); /** * Mask the internet host address object with a network mask address. * This is commonly used to coerce an address by subnet. */ IPV6Host &operator&=(const IPV6Mask &mask); friend class IPV6Mask; friend __EXPORT IPV6Host operator&(const IPV6Host &addr, const IPV6Mask &mask); }; /** * The broadcast address object is used to store the broadcast address for * a specific subnet. This is commonly used for UDP broadcast operations. */ class __EXPORT IPV6Broadcast : public IPV6Address { public: /** * Specify the physical broadcast address to use and create a new * broadcast address object based on a null terminated ASCII * string. * * @param net null terminated ASCII network address. */ IPV6Broadcast(const char *net = "255.255.255.255"); }; /** * A specialization of IPV6Address that provides address validation * for multicast addresses. Whenever its value changes the new value * is checked to be in the range from 224.0.0.1 through * 239.255.255.255. If it is not, an exception is thrown. * * @short A multicast network address. * @author Federico Montesino */ class __EXPORT IPV6Multicast: public IPV6Address { public: /** * Create an Internet Multicast Address object with an empty * (0.0.0.0) address. */ IPV6Multicast(); /** * Convert the system internet address data type (struct in_addr) * into a Common C++ IPV4Multicast object. * * @param address struct of system used binary internet address. */ IPV6Multicast(const struct in6_addr address); /** * Convert a null terminated ASCII multicast address string * (example: "224.0.0.1") or multicast name string (example: * "sap.mcast.net") directly into a Common C++ * IPV6Multicast object. Works like IPV6Address(const * char*). * * @param address null terminated C string. */ IPV6Multicast(const char *address); private: /** * Check the address in addr is a valid multicast * address. In case not, throws an exception. * * @param address a system network address * @return true if validation succeeded */ static const IPV6MulticastValidator validator; }; extern __EXPORT std::ostream& operator<<(std::ostream &os, const IPV6Address &ia); inline struct in6_addr getaddress(const IPV6Address &ia) {return ia.getAddress();} #endif END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/exception.h0000644000175000017500000001040212163025062015027 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/exception.h * @short GNU Common C++ exception model base classes. **/ #ifndef COMMONCPP_EXCEPTION_H_ #define COMMONCPP_EXCEPTION_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif // see if we support useful and std exception handling, else we ignore // it for the rest of the system. #if defined(CCXX_EXCEPTIONS) #define COMMONCPP_EXCEPTIONS #include #include NAMESPACE_COMMONCPP /** * Mainline exception handler, this is the root for all Common C++ * exceptions and assures the ansi C++ exception class hierarchy is both * followed and imported into the gnu Common C++ class hierarchy. * * @author David Sugar * @short Base exception class for all Common C++ exceptions. */ class __EXPORT Exception : public std::exception { private: String _what; public: Exception(const String& what_arg) throw(); virtual ~Exception() throw(); virtual const char *getString() const; virtual const char *what() const throw(); }; /** * A sub-hierarchy for all Common C++ I/O related classes. * * @author David Sugar * @short I/O operation exception hierarchy. */ class __EXPORT IOException : public Exception { private: long _systemError; mutable char* _systemErrorString; public: IOException(const String &what_arg, long systemError = 0) throw(); virtual ~IOException() throw(); virtual long getSystemError() const throw(); virtual const char* getSystemErrorString() const throw(); }; /** * A sub-hierarchy for thread exceptions. * * @author David Sugar * @short thread exception hierarchy. */ class __EXPORT ThrException : public Exception { public: inline ThrException(const String &what_arg) : Exception(what_arg) {}; }; /** * A sub-hierarchy for all task synchronizion related exceptions. * * @author David Sugar * @short Synchronization object exception hierarchy. */ class __EXPORT SyncException : public ThrException { public: inline SyncException(const String &what_arg) : ThrException(what_arg) {}; }; class __EXPORT InterruptException : public ThrException { public: inline InterruptException() : ThrException("interrupted") {}; }; END_NAMESPACE #endif #endif ucommon-6.0.7/inc/commoncpp/file.h0000644000175000017500000005640712163025062013767 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file file.h * @short Files and dynamic loader services. **/ #ifndef COMMONCPP_FILE_H_ #define COMMONCPP_FILE_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_THREAD_H_ #include #endif #ifndef COMMONCPP_EXCEPTION_H_ #include #endif #ifndef WIN32 # ifdef __BORLANDC__ # include # include # else # include # include # endif # include # include # include #else # if __BORLANDC__ >= 0x0560 # include # include # else # include # endif #endif NAMESPACE_COMMONCPP typedef unsigned long pos_t; #ifndef _MSWINDOWS_ // use a define so that if the sys/types.h header already defines caddr_t // as it may on BSD systems, we do not break it by redefining again. #undef caddr_t #define caddr_t char * typedef size_t ccxx_size_t; #else typedef DWORD ccxx_size_t; #endif #ifndef PATH_MAX #define PATH_MAX 256 #endif #ifndef NAME_MAX #define NAME_MAX 64 #endif class __EXPORT File { public: enum Error { errSuccess = 0, errNotOpened, errMapFailed, errInitFailed, errOpenDenied, errOpenFailed, errOpenInUse, errReadInterrupted, errReadIncomplete, errReadFailure, errWriteInterrupted, errWriteIncomplete, errWriteFailure, errLockFailure, errExtended }; typedef enum Error Error; enum Access { #ifndef _MSWINDOWS_ accessReadOnly = O_RDONLY, accessWriteOnly= O_WRONLY, accessReadWrite = O_RDWR #else accessReadOnly = GENERIC_READ, accessWriteOnly = GENERIC_WRITE, accessReadWrite = GENERIC_READ | GENERIC_WRITE #endif }; typedef enum Access Access; protected: typedef struct _fcb { struct _fcb *next; caddr_t address; ccxx_size_t len; off_t pos; bool locked; } fcb_t; public: #ifdef _MSWINDOWS_ enum Open { openReadOnly, // = FILE_OPEN_READONLY, openWriteOnly, // = FILE_OPEN_WRITEONLY, openReadWrite, // = FILE_OPEN_READWRITE, openAppend, // = FILE_OPEN_APPEND, openTruncate // = FILE_OPEN_TRUNCATE }; #else enum Open { openReadOnly = O_RDONLY, openWriteOnly = O_WRONLY, openReadWrite = O_RDWR, openAppend = O_WRONLY | O_APPEND, #ifdef O_SYNC openSync = O_RDWR | O_SYNC, #else openSync = O_RDWR, #endif openTruncate = O_RDWR | O_TRUNC }; typedef enum Open Open; /* to be used in future */ #ifndef S_IRUSR #define S_IRUSR 0400 #define S_IWUSR 0200 #define S_IRGRP 0040 #define S_IWGRP 0020 #define S_IROTH 0004 #define S_IWOTH 0002 #endif #endif // !WIN32 #ifndef _MSWINDOWS_ enum Attr { attrInvalid = 0, attrPrivate = S_IRUSR | S_IWUSR, attrGroup = attrPrivate | S_IRGRP | S_IWGRP, attrPublic = attrGroup | S_IROTH | S_IWOTH }; #else // defined WIN32 enum Attr { attrInvalid=0, attrPrivate, attrGroup, attrPublic }; #endif // !WIN32 typedef enum Attr Attr; #ifdef _MSWINDOWS_ enum Complete { completionImmediate, // = FILE_COMPLETION_IMMEDIATE, completionDelayed, // = FILE_COMPLETION_DELAYED, completionDeferred // = FILE_COMPLETION_DEFERRED }; enum Mapping { mappedRead, mappedWrite, mappedReadWrite }; #else enum Mapping { mappedRead = accessReadOnly, mappedWrite = accessWriteOnly, mappedReadWrite = accessReadWrite }; enum Complete { completionImmediate, completionDelayed, completionDeferred }; #endif typedef enum Complete Complete; typedef enum Mapping Mapping; public: static const char *getExtension(const char *path); static const char *getFilename(const char *path); static char *getFilename(const char *path, char *buffer, size_t size = NAME_MAX); static char *getDirname(const char *path, char *buffer, size_t size = PATH_MAX); static char *getRealpath(const char *path, char *buffer, size_t size = PATH_MAX); }; /** * A low level portable directory class. Used to support ccstd Directory * container. This provides a basic mechanism for allocating and * accessing file entries. * * @author David Sugar * @short low level directory access class. */ class __EXPORT Dir : public File { private: #ifndef _MSWINDOWS_ DIR *dir; struct dirent *save; char save_space[sizeof(struct dirent) + PATH_MAX + 1]; struct dirent *entry; #else HANDLE hDir; WIN32_FIND_DATA data, fdata; char *name; #endif public: Dir(const char *name = NULL); static bool create(const char *path, Attr attr = attrGroup); static bool remove(const char *path); static bool setPrefix(const char *path); static bool getPrefix(char *path, size_t size = PATH_MAX); void open(const char *name); void close(void); virtual ~Dir(); const char *getName(void); const char *operator++() {return getName();}; const char *operator++(int) {return getName();}; const char *operator*(); bool rewind(void); bool operator!() #ifndef _MSWINDOWS_ {return !dir;}; #else {return hDir != INVALID_HANDLE_VALUE;}; #endif bool isValid(void); }; /** * A generic class to walk a hierarchical directory structure. * * @author David Sugar * @short Directory tree walking. */ class __EXPORT DirTree { private: char path[PATH_MAX + 1]; Dir *dir; unsigned max, current, prefixpos; protected: /** * Virtual method to filter results. Virtual override methods * should call baseclass method to assure . and .. names are * stripped out. * * @return true if current filename is accepted. * @param file path to examine * @param ino info of type, date, etc. */ virtual bool filter(const char *file, struct stat *ino); public: /** * Construct a directory tree walk starting at the specified * prefix. A maximum subdirectory depth is also specified. * * @param prefix to start walk. * @param maxdepth subdirectory depth to examine. */ DirTree(const char *prefix, unsigned maxdepth); /** * Construct an un-opened directory tree of a known maximum depth * * @param maxdepth subdirectory subdirectory depth. */ DirTree(unsigned maxdepth); virtual ~DirTree(); /** * Open a directory tree path. * * @param prefix directory path to open. */ void open(const char *prefix); /** * Close the directory path. */ void close(void); /** * Extract the next full pathname from the directory walk. * When returning directories, a '/' is appended. The * returned string is a buffer of MAX_PATH size. * * @return path of next subdirectory entry or NULL. */ char *getPath(void); /** * This is used to step through the filter virtual for an * entire subtree, and is used for cases where a derived * DirTree class performs it's primary operations through * filter rather than externally by calling getPath(). * * @return number of files and directories examined. * @param prefix directory path to examine. */ unsigned perform(const char *prefix); }; /** * The purpose of this class is to define a base class for low level * random file access that is portable between Win32 and Posix systems. * This class is a foundation both for optimized thread shared and * traditional locked file access that is commonly used to build * database services, rather than the standard C++ streaming file classes. * * @author David Sugar * @short Portable random disk file access. */ class __EXPORT RandomFile : protected Mutex, public File { private: Error errid; char *errstr; protected: #ifndef _MSWINDOWS_ int fd; // FIXME: WIN32 as no access member Access access; #else HANDLE fd; #endif char *pathname; struct { unsigned count : 16; bool thrown : 1; bool initial : 1; #ifndef _MSWINDOWS_ bool immediate : 1; #endif bool temp : 1; } flags; /** * Create an unopened random access file. */ RandomFile(const char *name = NULL); /** * Default copy constructor. */ RandomFile(const RandomFile &rf); /** * Post an error event. * * @return error code. * @param errid error code. * @param errstr error message string. */ Error error(Error errid, char *errstr = NULL); /** * Post an extended string error message. * * @return errExtended. * @param err error string. */ inline Error error(char *err) {return error(errExtended, err);}; /** * Used to enable or disable throwing of exceptions on * errors. * * @param enable true if errors will be thrown. */ inline void setError(bool enable) {flags.thrown = !enable;}; #ifndef _MSWINDOWS_ /** * Used to set file completion modes. * * @return errSuccess if okay. * @param mode completion mode. * @todo implement in win32 */ Error setCompletion(Complete mode); #endif /** * Used to set the temporary attribute for the file. Temporary * files are automatically deleted when closed. * * @param enable true for marking as temporary. */ inline void setTemporary(bool enable) {flags.temp = enable;}; /** * This method is used to initialize a newly created file as * indicated by the "initial" flag. This method also returns * the file access permissions that should be associated with * the file. This method should never be called directly, but * is instead used to impliment the "Initial" method. Typically * one would use this to build an empty database shell when a * previously empty database file is created. * * @return access, or attrInvalid if should be removed. */ virtual Attr initialize(void); /** * Close the file. */ void final(void); public: /** * Destroy a random access file or it's derived class. */ virtual ~RandomFile(); /** * This method should be called right after a RandomFile derived * object has been created. This method will invoke initialize * if the object is newly created, and set file access permissions * appropriately. * * @return true if file had to be initialized. */ bool initial(void); /** * Get current file capacity. * * @return total file size. */ off_t getCapacity(void); /** * This method is commonly used to close and re-open an existing * database. This may be used when the database has been unlinked * and an external process provides a new one to use. */ virtual Error restart(void); /** * Return current error id. * * @return last error identifier set. */ inline Error getErrorNumber(void) {return errid;}; /** * Return current error string. * * @return last error string set. */ inline char *getErrorString(void) {return errstr;}; bool operator!(void); }; /** * This class defines a database I/O file service that can be shared * by multiple processes. Each thread should access a dup of the database * object, and mutex locks can be used to preserve transaction * integrety if multiple threads are used. * * SharedFile is used when a database may be shared between multiple * processes. SharedFile automatically applies low level byte-range "file * locks", and provides an interface to fetch and release byte-range locked * portions of a file. * * @author David Sugar * @short This class defines a database I/O file service that can be shared by multiple processes. */ class __EXPORT SharedFile : public RandomFile { private: fcb_t fcb; Error open(const char *path); public: /** * Open or create a new database file. You should also use * Initial. * * @param path pathname of database to open. */ SharedFile(const char *path); /** * Create a shared file as a duplicate of an existing shared * file. * * @param file original file. */ SharedFile(const SharedFile &file); /** * Close and finish a database file. */ virtual ~SharedFile(); /** * Restart an existing database; close and re-open. * * @return errSuccess if successful. */ Error restart(void) {return open(pathname);}; /** * Lock and Fetch a portion of the file into physical memory. * This can use state information to fetch the current record * multiple times. * * @return errSuccess on success. * @param address address to use, or NULL if same as last I/O. * @param length length to use, or 0 if same as last I/O. * @param position file position to use -1 if same as last I/O. */ Error fetch(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1); /** * Update a portion of a file from physical memory. This can use * state information to commit the last read record. The current * lock is also cleared. * * @return errSuccess on success. * @param address address to use, or NULL if same as last I/O. * @param length length to use, or 0 if same as last I/O. * @param position file position to use or -1 if same as last I/O. */ Error update(caddr_t address = NULL, ccxx_size_t length = 0, off_t position = -1); /** * Clear a lock held from a previous fetch operation without * updating. * * @return errSuccess on success. * @param length length to use, or 0 if same as last I/O. * @param pos file position to use or -1 if same as last I/O. */ Error clear(ccxx_size_t length = 0, off_t pos = -1); /** * Add new data to the end of the file. Locks file during append. * * @param address address to use, or NULL if same as last I/O. * @param length length to use, or 0 if same as last I/O. */ Error append(caddr_t address = NULL, ccxx_size_t length = 0); /** * Fetch the current file position marker for this thread. * * @return file position offset. */ off_t getPosition(void); bool operator++(void); bool operator--(void); }; /** * Create and map a disk file into memory. This portable class works * under both Posix via mmap and under the win32 API. A mapped file * can be referenced directly by it's memory segment. One can map * and unmap portions of a file on demand, and update * changed memory pages mapped from files immediately through sync(). * * @author David Sugar * @short Map a named disk file into memory. */ class __EXPORT MappedFile : public RandomFile { private: fcb_t fcb; int prot; #ifdef _MSWINDOWS_ HANDLE map; char mapname[64]; #endif public: /** * Open a file for mapping. More than one segment of a file * may be mapped into seperate regions of memory. * * @param fname file name to access for mapping. * @param mode access mode to map file. */ MappedFile(const char *fname, Access mode); /** * Create if not exists, and map a file of specified size * into memory. * * @param fname file name to access for mapping. * @param mode access mode to map file. * @param size of file to map. */ MappedFile(const char *fname, Access mode, size_t size); /** * Map a portion or all of a specified file in the specified * shared memory access mode. Valid mapping modes include * mappedRead, mappedWrite, and mappedReadWrite. * * @param fname pathname of file to map into memory. * @param offset from start of file to begin mapping in bytes. * @param size of mapped area in bytes. * @param mode to map file. */ MappedFile(const char *fname, pos_t offset, size_t size, Access mode); /** * Release a mapped section of memory associated with a file. The * mapped area is updated back to disk. */ virtual ~MappedFile(); // FIXME: not use library function in header ?? /** * Synchronize the contents of the mapped portion of memory with * the disk file and wait for completion. This assures the memory * mapped from the file is written back. */ void sync(void); /** * Synchronize a segment of memory mapped from a segment fetch. * * @param address memory address to update. * @param len size of segment. */ void sync(caddr_t address, size_t len); /** * Map a portion of the memory mapped from the file back to the * file and do not wait for completion. This is useful when mapping * a database file and updating a single record. * * @param offset offset into the mapped region of memory. * @param len length of partial region (example, record length). */ void update(size_t offset = 0, size_t len = 0); /** * Update a mapped region back to disk as specified by address * and length. * * @param address address of segment. * @param len length of segment. */ void update(caddr_t address, size_t len); /** * Release (unmap) a memory segment. * * @param address address of memory segment to release. * @param len length of memory segment to release. */ void release(caddr_t address, size_t len); /** * Fetch a pointer to an offset within the memory mapped portion * of the disk file. This really is used for convience of matching * operations between Update and Fetch, as one could simply have * accessed the base pointer where the file was mapped directly. * * @param offset from start of mapped memory. */ inline caddr_t fetch(size_t offset = 0) {return ((char *)(fcb.address)) + offset;}; /** * Fetch and map a portion of a disk file to a logical memory * block. * * @return pointer to memory segment. * @param pos offset of file segment to map. * @param len size of memory segment to map. */ caddr_t fetch(off_t pos, size_t len); /** * Lock the currently mapped portion of a file. * * @return true if pages are locked. */ bool lock(void); /** * Unlock a locked mapped portion of a file. */ void unlock(void); /** * Compute map size to aligned page boundry. * * @param size request. * @return page aligned size. */ size_t pageAligned(size_t size); }; /** * The DSO dynamic loader class is used to load object files. On * elf based systems this is typically done with dlopen. A dummy * stub class is generated for non-dl capable systems. * * @author David Sugar * @short Dynamic class file loader. */ class __EXPORT DSO { private: const char *err; static Mutex mutex; static DSO *first; static DSO *last; DSO *next, *prev; const char *id; void *image; typedef ucommon::dso::addr_t addr_t; protected: void loader(const char *filename, bool resolve); public: /** * Construct and load a DSO object file. * * @param filename pathname of object file to load. */ DSO(const char *filename) {loader(filename, true);}; DSO(const char *filename, bool resolve) {loader(filename, resolve);}; /** * Retrieve error indicator associated with DSO failure. This * is often used in catch handlers. */ inline const char *getError(void) {return err;}; /** * Detach a DSO object from running memory. */ virtual ~DSO(); /** * Lookup a symbol in the loaded file. */ addr_t operator[](const char *sym); static void dynunload(void); /** * Find a specific DSO object by filename. * * @param name of DSO object file (partial). */ static DSO *getObject(const char *name); /** * See if DSO object is valid. * * @return true if valid. */ bool isValid(void); /** * Install debug handler... */ static void setDebug(void); }; /** @relates RandomFile */ bool __EXPORT isDir(const char *path); /** @relates RandomFile */ bool __EXPORT isFile(const char *path); #ifndef WIN32 /** @relates RandomFile */ bool __EXPORT isDevice(const char *path); #else /** @relates RandomFile */ inline bool isDevice(const char *path) { return false; } #endif /** @relates RandomFile */ bool __EXPORT canAccess(const char *path); /** @relates RandomFile */ bool __EXPORT canModify(const char *path); /** @relates RandomFile */ time_t __EXPORT lastModified(const char *path); /** @relates RandomFile */ time_t __EXPORT lastAccessed(const char *path); #ifdef COMMON_STD_EXCEPTION class DirException : public IOException { public: DirException(const String &str) : IOException(str) {}; }; class __EXPORT DSOException : public IOException { public: DSOException(const String &str) : IOException(str) {}; }; class __EXPORT FileException : public IOException { public: FileException(const String &str) : IOException(str) {}; }; #endif END_NAMESPACE #endif /** EMACS ** * Local variables: * mode: c++ * c-basic-offset: 4 * End: */ ucommon-6.0.7/inc/commoncpp/export.h0000644000175000017500000000324412163025062014360 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Export interfaces for library interfaces. * This is a special header used when we have to build DLL's for dumb * platforms which require explicit declaration of imports and exports. * The real purpose is to include our local headers in a new library * module with external headers referenced as imports, and then to define * our own interfaces in our new library as exports. This allows native * construction of new DLL's based on/that use ucommon on Microsoft Windows * and perhaps for other similarly defective legacy platforms. Otherwise * this header is not used at all, and not when building applications. * @file commoncpp/export.h */ #if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) || defined(_MSWINDOWS_) #ifdef __EXPORT #undef __EXPORT #endif #if defined(UCOMMON_STATIC) || defined(UCOMMON_RUNTIME) #define __EXPORT #else #define __EXPORT __declspec(dllexport) #endif #endif ucommon-6.0.7/inc/commoncpp/config.h0000644000175000017500000000307012163025062014301 00000000000000#ifndef COMMONCPP_CONFIG_H_ #define COMMONCPP_CONFIG_H_ #ifndef _UCOMMON_UCOMMON_H_ #include #endif #ifdef __EXPORT #undef __EXPORT #endif #define __EXPORT __SHARED // #include #include #define COMMONCPP_HEADERS #define CCXX_NAMESPACES #define COMMONCPP_NAMESPACE ost #define NAMESPACE_COMMONCPP namespace ost { #define TIMEOUT_INF ucommon::Timer::inf #ifdef _UCOMMON_EXTENDED_ #define CCXX_EXCEPTIONS #endif #ifdef AF_INET6 #define CCXX_IPV6 #endif #ifdef AF_INET #define CCXX_IPV4 #endif typedef pthread_t cctid_t; typedef int8_t int8; typedef uint8_t uint8; typedef int16_t int16; typedef uint16_t uint16; typedef int32_t int32; typedef uint32_t uint32; typedef int64_t int64; typedef uint64_t uint64; #if !defined(_MSWINDOWS_) && !defined(__QNX__) /** * Convenience function for case insensitive null terminated string compare. * @param string1 to compare. * @param string2 to compare. * @return 0 if equal, > 0 if s2 > s1, < 0 if s2 < s1. */ extern "C" inline int stricmp(const char *string1, const char *string2) {return ucommon::String::case_compare(string1, string2);} /** * Convenience function for case insensitive null terminated string compare. * @param string1 to compare. * @param string2 to compare. * @param max size of string to compare. * @return 0 if equal, > 0 if s2 > s1, < 0 if s2 < s1. */ extern "C" inline int strnicmp(const char *string1, const char *string2, size_t max) {return ucommon::String::case_compare(string1, string2, max);} #endif #endif ucommon-6.0.7/inc/commoncpp/string.h0000644000175000017500000000425312163025062014346 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file commoncpp/string.h * @short Common C++ generic string class **/ #ifndef COMMONCPP_STRING_H_ #define COMMONCPP_STRING_H_ #ifndef COMMONCPP_CONFIG_H_ #include #endif NAMESPACE_COMMONCPP typedef ucommon::String String; __EXPORT char *lsetField(char *target, size_t size, const char *src, const char fill = 0); __EXPORT char *rsetField(char *target, size_t size, const char *src, const char fill = 0); __EXPORT char *newString(const char *src, size_t size = 0); __EXPORT void delString(char *str); __EXPORT char *setUpper(char *string, size_t size); __EXPORT char *setLower(char *string, size_t size); inline char *setString(char *target, size_t size, const char *str) {return String::set(target, size, str);} inline char *addString(char *target, size_t size, const char *str) {return String::add(target, size, str);} inline char *dupString(const char *src, size_t size = 0) {return newString(src, size);} /* __EXPORT char *find(const char *cs, char *str, size_t len = 0); __EXPORT char *rfind(const char *cs, char *str, size_t len = 0); __EXPORT char *ifind(const char *cs, char *str, size_t len = 0); __EXPORT char *strip(const char *cs, char *str, size_t len = 0); __EXPORT size_t strchop(const char *cs, char *str, size_t len = 0); __EXPORT size_t strtrim(const char *cs, char *str, size_t len = 0); */ END_NAMESPACE #endif ucommon-6.0.7/inc/commoncpp/tcp.h0000644000175000017500000005074412163025062013634 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // // This exception applies only to the code released under the name GNU // Common C++. If you copy code from other releases into a copy of GNU // Common C++, as the General Public License permits, the exception does // not apply to the code that you add in this way. To avoid misleading // anyone as to the status of such modified files, you must delete // this exception notice from them. // // If you write modifications of your own for GNU Common C++, it is your choice // whether to permit this exception to apply to your modifications. // If you do not wish that, delete this exception notice. // /** * @file commoncpp/tcp.h * @short tcp derived socket classes. **/ #ifndef COMMONCPP_TCP_H_ #define COMMONCPP_TCP_H_ #include #ifndef COMMONCPP_CONFIG_H_ #include #endif #ifndef COMMONCPP_STRING_H_ #include #endif #ifndef COMMONCPP_ADDRESS_H_ #include #endif #ifndef COMMONCPP_SOCKET_H_ #include #endif NAMESPACE_COMMONCPP /** * TCP sockets are used for stream based connected sessions between two * sockets. Both error recovery and flow control operate transparently * for a TCP socket connection. The TCP socket base class is primary used * to bind a TCP "server" for accepting TCP streams. * * An implicit and unique TCPSocket object exists in Common C++ to represent * a bound TCP socket acting as a "server" for receiving connection requests. * This class is not part of TCPStream because such objects normally perform * no physical I/O (read or write operations) other than to specify a listen * backlog queue and perform "accept" operations for pending connections. * The Common C++ TCPSocket offers a Peek method to examine where the next * pending connection is coming from, and a Reject method to flush the next * request from the queue without having to create a session. * * The TCPSocket also supports a "OnAccept" method which can be called when a * TCPStream related object is created from a TCPSocket. By creating a * TCPStream from a TCPSocket, an accept operation automatically occurs, and * the TCPSocket can then still reject the client connection through the * return status of it's OnAccept method. * * @author David Sugar * @short bound server for TCP streams and sessions. */ class __EXPORT TCPSocket : protected Socket { protected: int segsize; void setSegmentSize(unsigned mss); public: /** * A method to call in a derived TCPSocket class that is acting * as a server when a connection request is being accepted. The * server can implement protocol specific rules to exclude the * remote socket from being accepted by returning false. The * Peek method can also be used for this purpose. * * @return true if client should be accepted. * @param ia internet host address of the client. * @param port number of the client. */ virtual bool onAccept(const IPV4Host &ia, tpport_t port); /** * Fetch out the socket. */ inline SOCKET getSocket(void) {return so;}; /** * Get the buffer size for servers. */ inline int getSegmentSize(void) {return segsize;}; /** * A TCP "server" is created as a TCP socket that is bound * to a hardware address and port number on the local machine * and that has a backlog queue to listen for remote connection * requests. If the server cannot be created, an exception is * thrown. * * @param bind local ip address or interface to use. * @param port number to bind socket under. * @param backlog size of connection request queue. * @param mss maximum segment size for accepted streams. */ TCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog = 5, unsigned mss = 536); /** * Create a named tcp socket by service and/or interface id. * For IPV4 we use [host:]svc or [host/]svc for the string. * If we have getaddrinfo, we use that to obtain the addr to * bind for. * * @param name of host interface and service port to bind. * @param backlog size of connection request queue. * @param mss maximum segment size for streaming buffers. */ TCPSocket(const char *name, unsigned backlog = 5, unsigned mss = 536); /** * Return address and port of next connection request. This * can be used instead of OnAccept() to pre-evaluate connection * requests. * * @return host requesting a connection. * @param port number of requestor. */ inline IPV4Host getRequest(tpport_t *port = NULL) const {return Socket::getIPV4Sender(port);} /** * Used to reject the next incoming connection request. */ void reject(void); /** * Used to get local bound address. */ inline IPV4Host getLocal(tpport_t *port = NULL) const {return Socket::getIPV4Local(port);} /** * Used to wait for pending connection requests. * @return true if data packets available. * @param timeout in milliseconds. TIMEOUT_INF if not specified. */ inline bool isPendingConnection(timeout_t timeout = TIMEOUT_INF) /* not const -- jfc */ {return Socket::isPending(Socket::pendingInput, timeout);} /** * Use base socket handler for ending this socket. */ virtual ~TCPSocket(); }; #ifdef CCXX_IPV6 /** * TCPV6 sockets are used for stream based connected sessions between two * ipv6 sockets. Both error recovery and flow control operate transparently * for a TCP socket connection. The TCP socket base class is primary used * to bind a TCP "server" for accepting TCP streams. * * An implicit and unique TCPV6Socket object exists in Common C++ to represent * a bound ipv6 TCP socket acting as a "server" for receiving connection requests. * This class is not part of TCPStream because such objects normally perform * no physical I/O (read or write operations) other than to specify a listen * backlog queue and perform "accept" operations for pending connections. * The Common C++ TCPV6Socket offers a Peek method to examine where the next * pending connection is coming from, and a Reject method to flush the next * request from the queue without having to create a session. * * The TCPV6Socket also supports a "OnAccept" method which can be called when a * TCPStream related object is created from a TCPSocket. By creating a * TCPStream from a TCPV6Socket, an accept operation automatically occurs, and * the TCPV6Socket can then still reject the client connection through the * return status of it's OnAccept method. * * @author David Sugar * @short bound server for TCP streams and sessions. */ class __EXPORT TCPV6Socket : protected Socket { private: int segsize; void setSegmentSize(unsigned mss); public: /** * A method to call in a derived TCPSocket class that is acting * as a server when a connection request is being accepted. The * server can implement protocol specific rules to exclude the * remote socket from being accepted by returning false. The * Peek method can also be used for this purpose. * * @return true if client should be accepted. * @param ia internet host address of the client. * @param port number of the client. */ virtual bool onAccept(const IPV6Host &ia, tpport_t port); /** * Fetch out the socket. */ inline SOCKET getSocket(void) {return so;}; inline int getSegmentSize(void) {return segsize;}; /** * A TCP "server" is created as a TCP socket that is bound * to a hardware address and port number on the local machine * and that has a backlog queue to listen for remote connection * requests. If the server cannot be created, an exception is * thrown. * * @param bind local ip address or interface to use. * @param port number to bind socket under. * @param backlog size of connection request queue. * @param mss maximum segment size of streaming buffer. */ TCPV6Socket(const IPV6Address &bind, tpport_t port, unsigned backlog = 5, unsigned mss = 536); /** * Create a TCP server for a named host interface and service * port. We use [host/]port for specifying the optional host * name and service port since ':' is a valid char for ipv6 * addresses. * * @param name of host interface and service to use. * @param backlog size of connection request queue. * @param mss maximum segment size of streaming buffers. */ TCPV6Socket(const char *name, unsigned backlog = 5, unsigned mss = 536); /** * Return address and port of next connection request. This * can be used instead of OnAccept() to pre-evaluate connection * requests. * * @return host requesting a connection. * @param port number of requestor. */ inline IPV6Host getRequest(tpport_t *port = NULL) const {return Socket::getIPV6Sender(port);} /** * Used to reject the next incoming connection request. */ void reject(void); /** * Used to get local bound address. */ inline IPV6Host getLocal(tpport_t *port = NULL) const {return Socket::getIPV6Local(port);} /** * Used to wait for pending connection requests. * @return true if data packets available. * @param timeout in milliseconds. TIMEOUT_INF if not specified. */ inline bool isPendingConnection(timeout_t timeout = TIMEOUT_INF) /* not const -- jfc */ {return Socket::isPending(Socket::pendingInput, timeout);} /** * Use base socket handler for ending this socket. */ virtual ~TCPV6Socket(); }; #endif /** * TCP streams are used to represent TCP client connections to a server * by TCP protocol servers for accepting client connections. The TCP * stream is a C++ "stream" class, and can accept streaming of data to * and from other C++ objects using the << and >> operators. * * TCPStream itself can be formed either by connecting to a bound network * address of a TCP server, or can be created when "accepting" a * network connection from a TCP server. * * @author David Sugar * @short streamable TCP socket connection. */ class __EXPORT TCPStream : protected std::streambuf, public Socket, public std::iostream { private: int doallocate(); void segmentBuffering(unsigned mss); friend TCPStream& crlf(TCPStream&); friend TCPStream& lfcr(TCPStream&); // no copy constructor... TCPStream(const TCPStream &source); protected: timeout_t timeout; size_t bufsize; Family family; char *gbuf, *pbuf; public: /** * The constructor required for building other classes or to * start an unconnected TCPStream for connect. */ TCPStream(Family family = IPV4, bool throwflag = true, timeout_t to = 0); /** * Disconnect the current session and prepare for a new one. */ void disconnect(void); /** * Get protocol segment size. */ int getSegmentSize(void); protected: /** * Used to allocate the buffer space needed for iostream * operations. This function is called by the constructor. * * @param size of stream buffers from constructor. */ void allocate(size_t size); /** * Used to terminate the buffer space and cleanup the socket * connection. This fucntion is called by the destructor. */ void endStream(void); /** * This streambuf method is used to load the input buffer * through the established tcp socket connection. * * @return char from get buffer, EOF if not connected. */ int underflow(); /** * This streambuf method is used for doing unbuffered reads * through the establish tcp socket connection when in interactive mode. * Also this method will handle proper use of buffers if not in * interative mode. * * @return char from tcp socket connection, EOF if not connected. */ int uflow(); /** * This streambuf method is used to write the output * buffer through the established tcp connection. * * @param ch char to push through. * @return char pushed through. */ int overflow(int ch); /** * Create a TCP stream by connecting to a TCP socket (on * a remote machine). * * @param host address of remote TCP server. * @param port number to connect. * @param mss maximum segment size of streaming buffers. */ void connect(const IPV4Host &host, tpport_t port, unsigned mss = 536); #ifdef CCXX_IPV6 void connect(const IPV6Host &host, tpport_t port, unsigned mss = 536); #endif /** * Connect a TCP stream to a named destination host and port * number, using getaddrinfo interface if available. * * @param name of host and service to connect * @param mss maximum segment size of stream buffer */ void connect(const char *name, unsigned mss = 536); /** * Used in derived classes to refer to the current object via * it's iostream. For example, to send a set of characters * in a derived method, one might use *tcp() << "test". * * @return stream pointer of this object. */ std::iostream *tcp(void) {return ((std::iostream *)this);}; public: /** * Create a TCP stream by accepting a connection from a bound * TCP socket acting as a server. This performs an "accept" * call. * * @param server socket listening * @param throwflag flag to throw errors. * @param timeout for all operations. */ TCPStream(TCPSocket &server, bool throwflag = true, timeout_t timeout = 0); #ifdef CCXX_IPV6 TCPStream(TCPV6Socket &server, bool throwflag = true, timeout_t timeout = 0); #endif /** * Accept a connection from a TCP Server. * * @param server socket listening */ void connect(TCPSocket &server); #ifdef CCXX_IPV6 void connect(TCPV6Socket &server); #endif /** * Create a TCP stream by connecting to a TCP socket (on * a remote machine). * * @param host address of remote TCP server. * @param port number to connect. * @param mss maximum segment size of streaming buffers. * @param throwflag flag to throw errors. * @param timeout for all operations. */ TCPStream(const IPV4Host &host, tpport_t port, unsigned mss = 536, bool throwflag = true, timeout_t timeout = 0); #ifdef CCXX_IPV6 TCPStream(const IPV6Host &host, tpport_t port, unsigned mss = 536, bool throwflag = true, timeout_t timeout = 0); #endif /** * Construct a named TCP Socket connected to a remote machine. * * @param name of remote service. * @param family of protocol. * @param mss maximum segment size of streaming buffers. * @param throwflag flag to throw errors. * @param timer for timeout for all operations. */ TCPStream(const char *name, Family family = IPV4, unsigned mss = 536, bool throwflag = false, timeout_t timer = 0); /** * Set the I/O operation timeout for socket I/O operations. * * @param timer to change timeout. */ inline void setTimeout(timeout_t timer) {timeout = timer;}; /** * Flush and empty all buffers, and then remove the allocated * buffers. */ virtual ~TCPStream(); /** * Flushes the stream input and output buffers, writes * pending output. * * @return 0 on success. */ int sync(void); /** * Print content into a socket. * * @return count of bytes sent. * @param format string */ size_t printf(const char *format, ...); /** * Get the status of pending stream data. This can be used to * examine if input or output is waiting, or if an error or * disconnect has occured on the stream. If a read buffer * contains data then input is ready and if write buffer * contains data it is first flushed and then checked. */ bool isPending(Pending pend, timeout_t timeout = TIMEOUT_INF); /** * Examine contents of next waiting packet. * * @param buf pointer to packet buffer for contents. * @param len of packet buffer. * @return number of bytes examined. */ inline ssize_t peek(void *buf, size_t len) {return ::recv(so, (char *)buf, len, MSG_PEEK);}; /** * Return the size of the current stream buffering used. * * @return size of stream buffers. */ inline size_t getBufferSize(void) const {return bufsize;}; }; /** * The TCP session is used to primarily to represent a client connection * that can be managed on a seperate thread. The TCP session also supports * a non-blocking connection scheme which prevents blocking during the * constructor and moving the process of completing a connection into the * thread that executes for the session. * * @author David Sugar * @short Threaded streamable socket with non-blocking constructor. */ class __EXPORT TCPSession : public Thread, public TCPStream { private: TCPSession(const TCPSession &rhs); // not defined protected: /** * Normally called during the thread Initial() method by default, * this will wait for the socket connection to complete when * connecting to a remote socket. One might wish to use * setCompletion() to change the socket back to blocking I/O * calls after the connection completes. To implement the * session one must create a derived class which implements * run(). * * @return 0 if successful, -1 if timed out. * @param timeout to wait for completion in milliseconds. */ int waitConnection(timeout_t timeout = TIMEOUT_INF); /** * The initial method is used to esablish a connection when * delayed completion is used. This assures the constructor * terminates without having to wait for a connection request * to complete. */ void initial(void); public: /** * Create a TCP socket that will be connected to a remote TCP * server and that will execute under it's own thread. * * @param host internet address of remote TCP server. * @param port number of remote server. * @param size of streaming buffer. * @param pri execution priority relative to parent. * @param stack allocation needed on some platforms. */ TCPSession(const IPV4Host &host, tpport_t port, size_t size = 536, int pri = 0, size_t stack = 0); #ifdef CCXX_IPV6 TCPSession(const IPV6Host &host, tpport_t port, size_t size = 536, int pri = 0, size_t stack = 0); #endif /** * Create a TCP socket from a bound TCP server by accepting a pending * connection from that server and execute a thread for the accepted * connection. * * @param server tcp socket to accept a connection from. * @param pri execution priority relative to parent. * @param stack allocation needed on some platforms. */ TCPSession(TCPSocket &server, int pri = 0, size_t stack = 0); #ifdef CCXX_IPV6 TCPSession(TCPV6Socket &server, int pri = 0, size_t stack = 0); #endif /** * Make sure destruction happens through a virtual... */ virtual ~TCPSession(); }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon.cmake0000644000175000017500000000546212163025062013356 00000000000000# Copyright (C) 2009 David Sugar, Tycho Softworks # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. if (NOT UCOMMON_LIBS AND NOT UCOMMON_FLAGS) include(CheckCCompilerFlag) if(CMAKE_COMPILER_IS_GNUCXX) set(UCOMMON_VISIBILITY_FLAG "-fvisibility=hidden") if(MINGW OR MSYS OR CMAKE_SYSTEM MATCHES "Windows") set(CHECK_FLAGS -Wno-long-long -mthreads -fvisibility-inlines-hidden) else() if(CMAKE_SYSTEM MATCHES "SunOS.*") set(CHECK_FLAGS -Wno-long-long -mt -fvisibility-inlines-hidden) else() set(CHECK_FLAGS -Wno-long-long -pthread -mt -fvisibility-inlines-hidden) endif() endif() endif() if(BUILD_RUNTIME AND WIN32) set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_RUNTIME) else() if(BUILD_STATIC) set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_STATIC) endif() endif() # see if we are building with or without std c++ libraries... if (BUILD_STDLIB) # for now we assume only newer libstdc++ library set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DNEW_STDCPP) MESSAGE( STATUS "Configuring full ANSI C++ runtime") elseif (BUILD_OLDLIB) # for really old libstdc++ libraries... set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DOLD_STDCPP) MESSAGE( STATUS "Configuring compatible C++ runtime") else() MESSAGE( STATUS "Configuring minimal C++ runtime") if(CMAKE_COMPILER_IS_GNUCXX) set(CHECK_FLAGS ${CHECK_FLAGS} -fno-exceptions -fno-rtti -fno-enforce-eh-specs) if(MINGW OR MSYS OR CMAKE_SYSTEM MATCHES "Windows") set(UCOMMON_LINKING -nodefaultlibs -nostdinc++) else() set(UCOMMON_LINKING -nodefaultlibs -nostdinc++) endif() endif() endif() # check final for compiler flags foreach(flag ${CHECK_FLAGS}) check_c_compiler_flag(${flag} CHECK_${flag}) if(CHECK_${flag}) set(UCOMMON_FLAGS ${UCOMMON_FLAGS} ${flag}) endif() endforeach() # visibility support for linking reduction (gcc >4.1 only so far...) if(UCOMMON_VISIBILITY_FLAG) check_c_compiler_flag(${UCOMMON_VISIBILITY_FLAG} CHECK_VISIBILITY) endif() if(CHECK_VISIBILITY) set(UCOMMON_FLAGS ${UCOMMON_FLAGS} ${UCOMMON_VISIBILITY_FLAG} -DUCOMMON_VISIBILITY=1) else() set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_VISIBILITY=0) endif() endif() ucommon-6.0.7/inc/ucommon/0000755000175000017500000000000012175176705012443 500000000000000ucommon-6.0.7/inc/ucommon/numbers.h0000644000175000017500000001364112163025062014176 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Support classes for manipulation of numbers as strings. This is * used for things which parse numbers out of strings, such as in the * date and time classes. Other useful math related functions, templates, * and macros may also be found here. * @file ucommon/numbers.h */ #ifndef _UCOMMON_NUMBERS_H_ #define _UCOMMON_NUMBERS_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif NAMESPACE_UCOMMON /** * A number manipulation class. This is used to extract, convert, * and manage simple numbers that are represented in C ascii strings * in a very quick and optimal way. This class modifies the string * representation each time the value is changed. No math expressions * or explicit comparison operators are supported for the Numbers class * because these are best done by casting to long first. * * @author David Sugar * @short number manipulation. */ class __EXPORT Number { protected: char *buffer; unsigned size; public: /** * Create an instance of a number. * @param buffer or NULL if created internally. * @param size of field if not null terminated. */ Number(char *buffer, unsigned size); /** * Set string based on a new value. * @param value to set. */ void set(long value); /** * Get string buffer representing the number. * @return string buffer. */ inline const char *c_str() const {return buffer;}; /** * Get value of string buffer as a long integer. * @return long integer value of string buffer. */ long get() const; /** * Get value of string buffer as expression of object. * @return long integer value of string buffer. */ inline long operator()() {return get();}; /** * Cast string as long integer and get value of buffer. * @return long integer value of string buffer. */ inline operator long() {return get();}; /** * Cast object as a string to retrieve buffer. * @return string buffer of value. */ inline operator char*() {return buffer;}; /** * Assign a value to the number. This rewrites the string buffer. * @param value to assign. * @return new value of number object assigned. */ long operator=(long value); /** * Assign another number to this number. * @param number to assign to assign. * @return new value of number object assigned. */ long operator=(const Number& number); /** * Add a value to the number. This rewrites the string buffer. * @param value to add. * @return new value of number object. */ long operator+=(const long value); /** * Subtract a value from the number. This rewrites the string buffer. * @param value to subtract. * @return new value of number object. */ long operator-=(const long value); /** * Decrement the number object. This rewrites the string buffer. * @return new value of number object. */ long operator--(); /** * Increment the number object. This rewrites the string buffer. * @return new value of number object. */ long operator++(); inline bool operator==(const long value) const {return get() == value;} inline bool operator!=(const long value) const {return get() != value;} inline bool operator<(const long value) const {return get() < value;} inline bool operator>(const long value) const {return get() > value;} inline bool operator<=(const long value) const {return get() <= value;} inline bool operator>=(const long value) const {return get() >= value;} }; /** * A number manipulation class that maintains a zero lead filled string. * * @author David Sugar * @short zero filled number manipulation. */ class __EXPORT ZNumber : public Number { public: /** * Create a number class for zero fill. * @param pointer to field. * @param size of field to fill. */ ZNumber(char *pointer, unsigned size); /** * Set value of zero filled number. * @param value to set. */ void set(long value); /** * Assign number from value. * @param value to assign. * @return value assigned. */ long operator=(long value); }; /** * A convenience type for number. */ typedef Number number_t; /** * A convenience type for znumber. */ typedef ZNumber znumber_t; /** * Template for absolute value of a type. * @param value to check * @return absolute value */ template inline const T abs(const T& value) { if(value < (T)0) return -value; return value; } /** * Template for min value of a type. * @param v1 value to check * @param v2 value to check * @return v1 if < v2, else v2 */ template inline const T (min)(const T& v1, const T& v2) { return ((v1 < v2) ? v1 : v2); } /** * Template for max value of a type. * @param v1 value to check * @param v2 value to check * @return v1 if > v2, else v2 */ template inline const T (max)(const T& v1, const T& v2) { return ((v1 > v2) ? v1 : v2); } END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/buffer.h0000644000175000017500000000733012163025062013772 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Classes which use the buffer protocol to stream data. * @file ucommon/buffer.h */ #ifndef _UCOMMON_BUFFER_H_ #define _UCOMMON_BUFFER_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_SOCKET_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _UCOMMON_FSYS_H_ #include #endif #ifndef _UCOMMON_SHELL_H_ #include #endif NAMESPACE_UCOMMON /** * A generic tcp socket class that offers i/o buffering. All user i/o * operations are directly inherited from the IOBuffer base class public * members. Some additional members are added for layering ssl services. * @author David Sugar */ class __EXPORT TCPBuffer : public BufferProtocol, protected Socket { protected: void _buffer(size_t size); virtual size_t _push(const char *address, size_t size); virtual size_t _pull(char *address, size_t size); int _err(void) const; void _clear(void); bool _blocking(void); /** * Get the low level socket object. * @return socket we are using. */ inline socket_t getsocket(void) const {return so;}; public: /** * Construct an unconnected tcp client and specify our service profile. */ TCPBuffer(); /** * Construct a tcp server session from a listening socket. * @param server socket we are created from. * @param size of buffer and tcp fragments. */ TCPBuffer(const TCPServer *server, size_t size = 536); /** * Construct a tcp client session connected to a specific host uri. * @param host and optional :port we are connecting to. * @param service identifier of our client. * @param size of buffer and tcp fragments. */ TCPBuffer(const char *host, const char *service, size_t size = 536); /** * Destroy the tcp socket and release all resources. */ virtual ~TCPBuffer(); /** * Connect a tcp socket to a client from a listener. If the socket was * already connected, it is automatically closed first. * @param server we are connected from. * @param size of buffer and tcp fragments. */ void open(const TCPServer *server, size_t size = 536); /** * Connect a tcp client session to a specific host uri. If the socket * was already connected, it is automatically closed first. * @param host we are connecting. * @param service to connect to. * @param size of buffer and tcp fragments. */ void open(const char *host, const char *service, size_t size = 536); /** * Close active connection. */ void close(void); protected: /** * Check for pending tcp or ssl data. * @return true if data pending. */ virtual bool _pending(void); }; /** * Convenience type for pure tcp sockets. */ typedef TCPBuffer tcp_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/mapped.h0000644000175000017500000003777012163025062014002 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Support for memory mapped objects. * Memory mapped objects can be used to publish information so that it may be * accessible directly by external programs. The mapped memory objects will * usually be built as a vector vector or reusable type factory, in the latter * case using the allocated shared memory block itself as a local heap. A * simple template can be used to view the mapped contents that have been * published by another process. * @file ucommon/mapped.h */ #ifndef _UCOMMON_MAPPED_H_ #define _UCOMMON_MAPPED_H_ #ifndef _UCOMMON_LINKED_H_ #include #endif #ifndef _UCOMMON_THREAD_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _MSWINDOWS_ #include #endif NAMESPACE_UCOMMON /** * Construct or access a named section of memory. A logical name is used * which might map to something that is invoked from a call like shm_open * or a named w32 mapped swap segment. This is meant to support mapping a * vector onto shared memory and is often used as a supporting class for our * shared memory access templates. * @author David Sugar */ class __EXPORT MappedMemory { private: size_t mapsize; caddr_t map; fd_t fd; protected: size_t size, used; char idname[65]; bool erase; MappedMemory(); /** * Supporting function to construct a new or access an existing * shared memory segment. Used by primary constructors. * @param name of segment to create or access. * @param size of segment if creating new. Use 0 for read-only access. */ void create(const char *name, size_t size = (size_t)0); /** * Handler to invoke in derived class when accessing outside the * shared memory segment boundary. */ virtual void *invalid(void) const; /** * Handler for failure to map (allocate) memory. */ virtual void fault(void) const; public: /** * Construct a read/write access mapped shared segment of memory of a * known size. This constructs a new memory segment. * @param name of segment. * @param size of segment. */ MappedMemory(const char *name, size_t size); /** * Provide read-only mapped access to an existing named shared memory * segment. The size of the map is found by the size of the already * existing segment. * @param name of existing segment. */ MappedMemory(const char *name); /** * Unmap memory segment. */ virtual ~MappedMemory(); /** * Unmap memory segment. */ void release(void); /** * Destroy a previously existing memory segment under the specified name. * This is used both before creating a new one, and after a publishing * process unmaps the segment it created. * @param name of segment to remove. */ static void remove(const char *name); /** * Test if map active. * @return true if active map. */ inline operator bool() const {return (size != 0);}; /** * Test if map is inactive. * @return true if map inactive. */ inline bool operator!() const {return (size == 0);}; /** * Extend size of managed heap on shared memory segment. This does not * change the size of the mapped segment in any way, only that of any * heap space that is being allocated and used from the mapped segment. * @return start of space from map. * @param size of space requested. Will fault if past end of segment. */ void *sbrk(size_t size); /** * Get memory from a specific offset within the mapped memory segment. * @param offset from start of segment. Will fault if past end. * @return address of offset. */ void *offset(size_t offset) const; /** * Copy memory from specific offset within the mapped memory segment. * This function assures the copy is not in the middle of being modified. * @param offset from start of segment. * @param buffer to copy into. * @param size of object to copy. * @return true on success. */ bool copy(size_t offset, void *buffer, size_t size) const; /** * Get size of mapped segment. * @return size of mapped segment. */ inline size_t len(void) {return size;}; /** * Get starting address of mapped segment. * @return starting address of mapped segment. */ inline caddr_t addr(void) {return map;}; /** * An API that allows "disabling" of publishing shared memory maps. * This may be useful when an app doesn't want to use shared memory * as a runtime or build option, but does not want to have to be "recoded" * explicitly for non-shared memory either. Basically it substitutes a * dummy map running on the local heap. */ static void disable(void); }; /** * Map a reusable allocator over a named shared memory segment. This may be * used to form a resource bound fixed size managed heap in shared memory. * The request can either be fulfilled from the object reuse pool or from a * new section of memory, and if all memory in the segment has been exhausted, * it can wait until more objects are returned by another thread to the reuse * pool. * @author David Sugar */ class __EXPORT MappedReuse : protected ReusableAllocator, protected MappedMemory { private: unsigned objsize; unsigned reading; mutex_t mutex; protected: MappedReuse(size_t osize); inline void create(const char *fname, unsigned count) {MappedMemory::create(fname, count * objsize);}; public: /** * Construct a named memory segment for use with managed fixed size * reusable objects. The segment is created as writable. There is no * read-only version of mapped reuse since the mapped segment can be read * by another process directly as a mapped read-only vector. The actual * mapped type will be derived from ReusableObject to meet the needs of * the reusable allocator. The template version should be used to * assure type correctness rather than using this class directly. * @param name of shared memory segment. * @param size of the object type being mapped. * @param count of the maximum number of active mapped objects. */ MappedReuse(const char *name, size_t size, unsigned count); /** * Check whether there are objects available to be allocated. * @return true if objects are available. */ bool avail(void); /** * Request a reusable object from the free list or mapped space. * @return free object or NULL if pool is exhausted. */ ReusableObject *request(void); /** * Request a reusable object from the free list or mapped space. * This method blocks until an object becomes available. * @return free object. */ ReusableObject *get(void); /** * Request a reusable object from the free list or mapped space. * This method blocks until an object becomes available or the * timeout has expired. * @param timeout to wait in milliseconds. * @return free object or NULL if timeout. */ ReusableObject *getTimed(timeout_t timeout); /** * Used to get an object from the reuse pool when the mutex lock is * already held. * @return object from pool or NULL if exhausted. */ ReusableObject *getLocked(void); /** * Used to return an object to the reuse pool when the mutex lock is * already held. * @param object being returned. */ void removeLocked(ReusableObject *object); }; /** * Template class to map typed vector into shared memory. This is used to * construct a typed read/write vector of objects that are held in a named * shared memory segment. * @author David Sugar */ template class mapped_array : public MappedMemory { protected: inline mapped_array() : MappedMemory() {}; inline void create(const char *fn, unsigned members) {MappedMemory::create(fn, members * sizeof(T));}; public: /** * Construct mapped vector array of typed objects. This is constructed * for read/write access. mapped_view is used in all cases for read-only * access to mapped data. Member objects are linearly allocated from * the shared memory segment, or may simply be directly accessed by offset. * @param name of mapped segment to construct. * @param number of objects in the mapped vector. */ inline mapped_array(const char *name, unsigned number) : MappedMemory(name, number * sizeof(T)) {}; /** * Initialize typed data in mapped array. Assumes default constructor * for type. */ inline void initialize(void) {new((caddr_t)offset(0)) T[size / sizeof(T)];}; /** * Add mapped space while holding lock for one object. * @return address of object. */ inline void *addLock(void) {return sbrk(sizeof(T));}; /** * Get typed pointer to member object of vector in mapped segment. * @param member to access. * @return typed pointer or NULL if past end of array. */ inline T *operator()(unsigned member) {return static_cast(offset(member * sizeof(T)));} /** * Allocate mapped space for one object. * @return address of object. */ inline T *operator()(void) {return static_cast(sbrk(sizeof(T)));}; /** * Reference typed object of vector in mapped segment. * @param member to access. * @return typed reference. */ inline T& operator[](unsigned member) {return *(operator()(member));}; /** * Get member size of typed objects that can be held in mapped vector. * @return members mapped in segment. */ inline unsigned max(void) {return (unsigned)(size / sizeof(T));}; }; /** * Template class to map typed reusable objects into shared memory heap. * This is used to construct a read/write heap of objects that are held in a * named shared memory segment. Member objects are allocated from a reusable * heap but are stored in the shared memory segment as a vector. * @author David Sugar */ template class mapped_reuse : public MappedReuse { protected: inline mapped_reuse() : MappedReuse(sizeof(T)) {}; public: /** * Construct mapped reuse array of typed objects. This is constructed * for read/write access. mapped_view is used in all cases for read-only * access to mapped data. * @param name of mapped segment to construct. * @param number of objects in the mapped vector. */ inline mapped_reuse(const char *name, unsigned number) : MappedReuse(name, sizeof(T), number) {}; /** * Initialize typed data in mapped array. Assumes default constructor * for type. */ inline void initialize(void) {new((caddr_t)pos(0)) T[size / sizeof(T)];}; /** * Check whether there are typed objects available to be allocated. * @return true if objects are available. */ inline operator bool() const {return MappedReuse::avail();}; /** * Check whether there are typed objects available to be allocated. * @return true if no more typed objects are available. */ inline bool operator!() const {return !MappedReuse::avail();}; /** * Request a typed reusable object from the free list or mapped space. * This method blocks until an object becomes available. * @return free object. */ inline operator T*() {return mapped_reuse::get();}; /** * Request a typed reusable object from the free list or mapped space by * pointer reference. This method blocks until an object becomes available. * @return free object. */ inline T* operator*() {return mapped_reuse::get();}; /** * Get typed object from a specific member offset within the mapped segment. * @param member offset from start of segment. Will fault if past end. * @return typed object pointer. */ inline T *pos(size_t member) {return static_cast(MappedReuse::offset(member * sizeof(T)));}; /** * Request a typed reusable object from the free list or mapped space. * This method blocks until an object becomes available. * @return free typed object. */ inline T *get(void) {return static_cast(MappedReuse::get());}; /** * Request a typed reusable object from the free list or mapped space. * This method blocks until an object becomes available from another * thread or the timeout expires. * @param timeout in milliseconds. * @return free typed object. */ inline T *getTimed(timeout_t timeout) {return static_cast(MappedReuse::getTimed(timeout));}; /** * Request a typed reusable object from the free list or mapped space. * This method does not block or wait. * @return free typed object if available or NULL. */ inline T *request(void) {return static_cast(MappedReuse::request());}; /** * Used to return a typed object to the reuse pool when the mutex lock is * already held. * @param object being returned. */ inline void removeLocked(T *object) {MappedReuse::removeLocked(object);}; /** * Used to get a typed object from the reuse pool when the mutex lock is * already held. * @return typed object from pool or NULL if exhausted. */ inline T *getLocked(void) {return static_cast(MappedReuse::getLocked());}; /** * Used to release a typed object back to the reuse typed object pool. * @param object being released. */ inline void release(T *object) {ReusableAllocator::release(object);}; }; /** * Class to access a named mapped segment published from another process. * This offers a simple typed vector interface to access the shared memory * segment in read-only mode. * @author David Sugar */ template class mapped_view : protected MappedMemory { public: /** * Map existing named memory segment. The size of the map is derived * from the existing map alone. * @param name of memory segment to map. */ inline mapped_view(const char *name) : MappedMemory(name) {}; /** * Access typed member object in the mapped segment. * @param member to access. * @return typed object pointer. */ inline volatile const T *operator()(unsigned member) {return static_cast(offset(member * sizeof(T)));} /** * Reference typed member object in the mapped segment. * @param member to access. * @return typed object reference. */ inline volatile const T &operator[](unsigned member) {return *(operator()(member));}; inline volatile const T *get(unsigned member) {return static_cast(offset(member * sizeof(T)));}; inline void copy(unsigned member, T& buffer) {MappedMemory::copy(member * sizeof(T), &buffer, sizeof(T));}; /** * Get count of typed member objects held in this map. * @return count of typed member objects. */ inline unsigned count(void) {return (unsigned)(size / sizeof(T));}; }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/platform.h0000644000175000017500000002446312163025062014353 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Various miscellaneous platform specific headers and defines. * This is used to support ucommon on different platforms. The ucommon * library assumes at least a real posix threading library is present or * will build thread support native on Microsoft Windows legacy platform. * This header also deals with issues related to common base types. * @file ucommon/platform.h */ #ifndef _UCOMMON_PLATFORM_H_ #define _UCOMMON_PLATFORM_H_ #define UCOMMON_ABI 6 /** * Common namespace for all ucommon objects. * We are using a common namespace to easily separate ucommon from other * libraries. This namespace usage is set to the package name and controlled * by macros so future changes will be hidden from user applications so long * as the namespace macros (UCOMMON_NAMESPACE, NAMESPACE_UCOMMON, * END_NAMESPACE) are used in place of direct namespace declarations. * @namespace ucommon */ #define UCOMMON_NAMESPACE ucommon #define NAMESPACE_UCOMMON namespace ucommon { #define NAMESPACE_EXTERN_C extern "C" { #define END_NAMESPACE } #define EXTERN_C extern "C" #ifndef _REENTRANT #define _REENTRANT 1 #endif #ifndef __PTH__ #ifndef _THREADSAFE #define _THREADSAFE 1 #endif #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS #endif #endif #if defined(__GNUC__) && (__GNUC < 3) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif #if __GNUC__ > 3 || (__GNUC__ == 3 && (__GNU_MINOR__ > 3)) #define __PRINTF(x,y) __attribute__ ((format (printf, x, y))) #define __SCANF(x, y) __attribute__ ((format (scanf, x, y))) #define __MALLOC __attribute__ ((malloc)) #endif #ifndef __MALLOC #define __PRINTF(x, y) #define __SCANF(x, y) #define __MALLOC #endif #ifndef DEBUG #ifndef NDEBUG #define NDEBUG #endif #endif #ifdef DEBUG #ifdef NDEBUG #undef NDEBUG #endif #endif // see if we are building for or using extended stdc++ runtime library support #if defined(NEW_STDCPP) || defined(OLD_STDCPP) #define _UCOMMON_EXTENDED_ #endif // see if targeting legacy Microsoft windows platform #if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) #define _MSWINDOWS_ #if defined(_M_X64) || defined(_M_ARM) #define _MSCONDITIONALS_ #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #endif #endif //#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501 //#undef _WIN32_WINNT //#define _WIN32_WINNT 0x0501 //#endif //#ifndef _WIN32_WINNT //#define _WIN32_WINNT 0x0501 //#endif #ifdef _MSC_VER #pragma warning(disable: 4251) #pragma warning(disable: 4996) #pragma warning(disable: 4355) #pragma warning(disable: 4290) #pragma warning(disable: 4291) #endif #if defined(__BORLANDC__) && !defined(__MT__) #error Please enable multithreading #endif #if defined(_MSC_VER) && !defined(_MT) #error Please enable multithreading (Project -> Settings -> C/C++ -> Code Generation -> Use Runtime Library) #endif // Require for compiling with critical sections. #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif // Make sure we're consistent with _WIN32_WINNT #ifndef WINVER #define WINVER _WIN32_WINNT #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include #if defined(_MSC_VER) typedef signed long ssize_t; typedef int pid_t; #endif #include #ifndef __EXPORT #ifdef UCOMMON_STATIC #define __EXPORT #else #define __EXPORT __declspec(dllimport) #endif #endif #define __LOCAL // if runtime mode then non-runtime libraries are static on windows... #if defined(UCOMMON_RUNTIME) || defined(UCOMMON_STATIC) #define __SHARED #else #define __SHARED __EXPORT #endif #elif UCOMMON_VISIBILITY > 0 #define __EXPORT __attribute__ ((visibility("default"))) #define __LOCAL __attribute__ ((visibility("hidden"))) #define __SHARED __attribute__ ((visibility("default"))) #else #define __EXPORT #define __LOCAL #define __SHARED #endif #ifdef _MSWINDOWS_ #define _UWIN #include #include typedef DWORD pthread_t; typedef CRITICAL_SECTION pthread_mutex_t; typedef char *caddr_t; typedef HANDLE fd_t; typedef SOCKET socket_t; #ifdef _MSC_VER typedef struct timespec { time_t tv_sec; long tv_nsec; } timespec_t; #endif extern "C" { #define SERVICE_MAIN(id, argc, argv) void WINAPI service_##id(DWORD argc, LPSTR *argv) typedef LPSERVICE_MAIN_FUNCTION cpr_service_t; inline void sleep(int seconds) {::Sleep((seconds * 1000l));} inline void pthread_exit(void *p) {_endthreadex((DWORD)0);} inline pthread_t pthread_self(void) {return (pthread_t)GetCurrentThreadId();} inline int pthread_mutex_init(pthread_mutex_t *mutex, void *x) {InitializeCriticalSection(mutex); return 0;} inline void pthread_mutex_destroy(pthread_mutex_t *mutex) {DeleteCriticalSection(mutex);} inline void pthread_mutex_lock(pthread_mutex_t *mutex) {EnterCriticalSection(mutex);} inline void pthread_mutex_unlock(pthread_mutex_t *mutex) {LeaveCriticalSection(mutex);} inline char *strdup(const char *s) {return _strdup(s);} inline int stricmp(const char *s1, const char *s2) {return _stricmp(s1, s2);} inline int strnicmp(const char *s1, const char *s2, size_t l) {return _strnicmp(s1, s2, l);} } #elif defined(__PTH__) #include #include typedef int socket_t; typedef int fd_t; #define INVALID_SOCKET -1 #define INVALID_HANDLE_VALUE -1 #include #define pthread_mutex_t pth_mutex_t #define pthread_cond_t pth_cond_t #define pthread_t pth_t inline int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) {return pth_sigmask(how, set, oset);}; inline void pthread_exit(void *p) {pth_exit(p);}; inline void pthread_kill(pthread_t tid, int sig) {pth_raise(tid, sig);}; inline int pthread_mutex_init(pthread_mutex_t *mutex, void *x) {return pth_mutex_init(mutex) != 0;}; inline void pthread_mutex_destroy(pthread_mutex_t *mutex) {}; inline void pthread_mutex_lock(pthread_mutex_t *mutex) {pth_mutex_acquire(mutex, 0, NULL);}; inline void pthread_mutex_unlock(pthread_mutex_t *mutex) {pth_mutex_release(mutex);}; inline void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) {pth_cond_await(cond, mutex, NULL);}; inline void pthread_cond_signal(pthread_cond_t *cond) {pth_cond_notify(cond, FALSE);}; inline void pthread_cond_broadcast(pthread_cond_t *cond) {pth_cond_notify(cond, TRUE);}; #else #include typedef int socket_t; typedef int fd_t; #define INVALID_SOCKET -1 #define INVALID_HANDLE_VALUE -1 #include #endif #ifdef _MSC_VER typedef signed __int8 int8_t; typedef unsigned __int8 uint8_t; typedef signed __int16 int16_t; typedef unsigned __int16 uint16_t; typedef signed __int32 int32_t; typedef unsigned __int32 uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; typedef char *caddr_t; #include #define snprintf _snprintf #define vsnprintf _vsnprintf #else #include #include #include #include #include #endif #undef getchar #undef putchar #ifndef _GNU_SOURCE typedef void (*sighandler_t)(int); /**< Convenient typedef for signal handlers. */ #endif typedef unsigned long timeout_t; /**< Typedef for millisecond timer values. */ #include #include #include #include #ifdef _MSWINDOWS_ #ifndef ENETDOWN #define ENETDOWN ((int)(WSAENETDOWN)) #endif #ifndef EINPROGRESS #define EINPROGRESS ((int)(WSAEINPROGRESS)) #endif #ifndef ENOPROTOOPT #define ENOPROTOOPT ((int)(WSAENOPROTOOPT)) #endif #ifndef EADDRINUSE #define EADDRINUSE ((int)(WSAEADDRINUSE)) #endif #ifndef EADDRNOTAVAIL #define EADDRNOTAVAIL ((int)(WSAEADDRNOTAVAIL)) #endif #ifndef ENETUNREACH #define ENETUNREACH ((int)(WSAENETUNREACH)) #endif #ifndef EHOSTUNREACH #define EHOSTUNREACH ((int)(WSAEHOSTUNREACH)) #endif #ifndef EHOSTDOWN #define EHOSTDOWN ((int)(WSAEHOSTDOWN)) #endif #ifndef ENETRESET #define ENETRESET ((int)(WSAENETRESET)) #endif #ifndef ECONNABORTED #define ECONNABORTED ((int)(WSAECONNABORTED)) #endif #ifndef ECONNRESET #define ECONNRESET ((int)(WSAECONNRESET)) #endif #ifndef EISCONN #define EISCONN ((int)(WSAEISCONN)) #endif #ifndef ENOTCONN #define ENOTCONN ((int)(WSAENOTCONN)) #endif #ifndef ESHUTDOWN #define ESHUTDOWN ((int)(WSAESHUTDOWN)) #endif #ifndef ETIMEDOUT #define ETIMEDOUT ((int)(WSAETIMEDOUT)) #endif #ifndef ECONNREFUSED #define ECONNREFUSED ((int)(WSAECONNREFUSED)) #endif #endif #ifndef DEBUG #ifndef NDEBUG #define NDEBUG #endif #endif #ifdef DEBUG #ifdef NDEBUG #undef NDEBUG #endif #endif #ifndef PROGRAM_MAIN #define PROGRAM_MAIN(argc, argv) extern "C" int main(int argc, char **argv) #define PROGRAM_EXIT(code) return code #endif #ifndef SERVICE_MAIN #define SERVICE_MAIN(id, argc, argv) void service_##id(int argc, char **argv) typedef void (*cpr_service_t)(int argc, char **argv); #endif #include #ifdef DEBUG #define crit(x, text) assert(x) #else #define crit(x, text) if(!(x)) cpr_runtime_error(text) #endif /** * Template function to initialize memory by invoking default constructor. * If NULL is passed, then NULL is returned without any constructor called. * @param memory to initialize. * @return memory initialized. */ template inline T *init(T *memory) {return ((memory) ? new(((caddr_t)memory)) T : NULL);} typedef long Integer; typedef unsigned long Unsigned; typedef double Real; /** * Matching function for strdup(). * @param string to release from allocated memory. */ inline void strfree(char *str) {::free(str);} #endif ucommon-6.0.7/inc/ucommon/fsys.h0000644000175000017500000004742312175172317013525 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Thread-aware file system manipulation class. This is used to provide * generic file operations that are OS independent and thread-safe in * behavior. This is used in particular to wrap posix calls internally * to pth, and to create portable code between MSWINDOWS and Posix low-level * file I/O operations. * @file ucommon/fsys.h */ #ifndef _UCOMMON_FSYS_H_ #define _UCOMMON_FSYS_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_THREAD_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _UCOMMON_MEMORY_H_ #include #endif #ifndef _MSWINDOWS_ #include #else #include #ifndef R_OK #define F_OK 0 #define X_OK 1 #define W_OK 2 #define R_OK 4 #endif #endif #include #include #ifndef __S_ISTYPE #define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask)) #endif #if !defined(S_ISDIR) && defined(S_IFDIR) #define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR) #endif #if !defined(S_ISCHR) && defined(S_IFCHR) #define S_ISCHR(mode) __S_ISTYPE((mode), S_IFCHR) #elif !defined(S_ISCHR) #define S_ISCHR(mode) 0 #endif #if !defined(S_ISBLK) && defined(S_IFBLK) #define S_ISBLK(mode) __S_ISTYPE((mode), S_IFBLK) #elif !defined(S_ISBLK) #define S_ISBLK(mode) 0 #endif #if !defined(S_ISREG) && defined(S_IFREG) #define S_ISREG(mode) __S_ISTYPE((mode), S_IFREG) #elif !defined(S_ISREG) #define S_ISREG(mode) 1 #endif #if !defined(S_ISSOCK) && defined(S_IFSOCK) #define S_ISSOCK(mode) __S_ISTYPE((mode), S_IFSOCK) #elif !defined(S_ISSOCK) #define S_ISSOCK(mode) (0) #endif #if !defined(S_ISFIFO) && defined(S_IFIFO) #define S_ISFIFO(mode) __S_ISTYPE((mode), S_IFIFO) #elif !defined(S_ISFIFO) #define S_ISFIFO(mode) (0) #endif #if !defined(S_ISLNK) && defined(S_IFLNK) #define S_ISLNK(mode) __S_ISTYPE((mode), S_IFLNK) #elif !defined(S_ISLNK) #define S_ISLNK(mode) (0) #endif NAMESPACE_UCOMMON /** * Convenience type for loader operations. */ typedef void *mem_t; /** * A container for generic and o/s portable threadsafe file system functions. * These are based roughly on their posix equivilents. For libpth, the * system calls are wrapped. The native file descriptor or handle may be * used, but it is best to use "class fsys" instead because it can capture * the errno of a file operation in a threadsafe and platform independent * manner, including for mswindows targets. */ class __EXPORT fsys { protected: fd_t fd; int error; public: /** * Most of the common chmod values are predefined. */ enum { OWNER_READONLY = 0400, GROUP_READONLY = 0440, PUBLIC_READONLY = 0444, OWNER_PRIVATE = 0600, OWNER_PUBLIC = 0644, GROUP_PRIVATE = 0660, GROUP_PUBLIC = 0664, EVERYONE = 0666, DIR_TEMPORARY = 01777 }; typedef struct stat fileinfo_t; #ifdef _MSWINDOWS_ static int remapError(void); #else inline static int remapError(void) {return errno;}; #endif /** * Enumerated file access modes. */ typedef enum { RDONLY, WRONLY, REWRITE, RDWR = REWRITE, APPEND, SHARED, EXCLUSIVE, DEVICE, STREAM, RANDOM } access_t; /** * File offset type. */ typedef long offset_t; /** * Used to mark "append" in set position operations. */ static const offset_t end; /** * Construct an unattached fsys descriptor. */ fsys(); /** * Contruct fsys from raw file handle. */ fsys(fd_t handle); /** * Copy (dup) an existing fsys descriptor. * @param descriptor to copy from. */ fsys(const fsys& descriptor); /** * Create a fsys descriptor by opening an existing file or directory. * @param path of file to open for created descriptor. * @param access mode of file. */ fsys(const char *path, access_t access); /** * Create a fsys descriptor by creating a file. * @param path of file to create for descriptor. * @param access mode of file access. * @param permission mode of file. */ fsys(const char *path, unsigned permission, access_t access); /** * Close and release a file descriptor. */ ~fsys(); /** * Get the descriptor from the object by pointer reference. * @return low level file handle. */ inline fd_t operator*() const {return fd;}; /** * Get the descriptor from the object by casting reference. * @return low level file handle. */ inline operator fd_t() const {return fd;} /** * Reset error flag. */ inline void reset(void) {error = 0;} /** * Test if file descriptor is open. * @return true if open. */ inline operator bool() const {return fd != INVALID_HANDLE_VALUE;} /** * Test if file descriptor is closed. * @return true if closed. */ inline bool operator!() const {return fd == INVALID_HANDLE_VALUE;} /** * Assign file descriptor by duplicating another descriptor. * @param descriptor to dup from. */ void operator=(const fsys& descriptor); /** * Replace current file descriptor with an external descriptor. This * does not create a duplicate. The external descriptor object is * marked as invalid. */ void operator*=(fd_t& descriptor); /** * Assing file descriptor from system descriptor. * @param descriptor to dup from. */ void operator=(fd_t descriptor); /** * Get the native system descriptor handle of the file descriptor. * @return native os descriptor. */ inline fd_t handle(void) const {return fd;}; /** * Set with external descriptor. Closes existing file if open. * @param descriptor of open file. */ void set(fd_t descriptor); /** * Release descriptor, do not close. * @return handle being released. */ fd_t release(void); /** * Set the position of a file descriptor. * @param offset from start of file or "end" to append. * @return error number or 0 on success. */ int seek(offset_t offset); /** * Drop cached data from start of file. * @param size of region to drop or until end of file. * @return error number or 0 on success. */ int drop(offset_t size = 0); /** * See if current file stream is a tty device. * @return true if device. */ bool is_tty(void); /** * See if the file handle is a tty device. * @return true if device. */ static bool is_tty(fd_t fd); /** * Read data from descriptor or scan directory. * @param buffer to read into. * @param count of bytes to read. * @return bytes transferred, -1 if error. */ ssize_t read(void *buffer, size_t count); /** * Write data to descriptor. * @param buffer to write from. * @param count of bytes to write. * @return bytes transferred, -1 if error. */ ssize_t write(const void *buffer, size_t count); /** * Get status of open descriptor. * @param buffer to save status info in. * @return error number or 0 on success. */ int info(fileinfo_t *buffer); /** * Truncate file to specified length. The file pointer is positioned * to the new end of file. * @param offset to truncate to. * @return true if truncate successful. */ int trunc(offset_t offset); /** * Commit changes to the filesystem. * @return error number or 0 on success. */ int sync(void); /** * Set directory prefix (chdir). * @param path to change to. * @return error number or 0 on success. */ static int prefix(const char *path); /** * Get current directory prefix (pwd). * @param path to save directory into. * @param size of path we can save. * @return error number or 0 on success. */ static int prefix(char *path, size_t size); static string_t prefix(void); /** * Stat a file. * @param path of file to stat. * @param buffer to save stat info. * @return error number or 0 on success. */ static int info(const char *path, fileinfo_t *buffer); /** * Erase (remove) a file only. * @param path of file. * @return error number or 0 on success. */ static int erase(const char *path); /** * Copy a file. * @param source file. * @param target file. * @param size of buffer. * @return error number or 0 on success. */ static int copy(const char *source, const char *target, size_t size = 1024); /** * Rename a file. * @param oldpath to rename from. * @param newpath to rename to. * @return error number or 0 on success. */ static int rename(const char *oldpath, const char *newpath); /** * Change file access mode. * @param path to change. * @param value of mode to assign. * @return error number or 0 on success. */ static int mode(const char *path, unsigned value); /** * Test if path exists. * @param path to test. * @return if true. */ static bool is_exists(const char *path); /** * Test if path readable. * @param path to test. * @return if true. */ static bool is_readable(const char *path); /** * Test if path writable. * @param path to test. * @return if true. */ static bool is_writable(const char *path); /** * Test if path is executable. * @param path to test. * @return if true. */ static bool is_executable(const char *path); /** * Test if path is a file. * @param path to test. * @return true if exists and is file. */ static bool is_file(const char *path); /** * Test if path is a directory. * @param path to test. * @return true if exists and is directory. */ static bool is_dir(const char *path); /** * Test if path is a symlink. * @param path to test. * @return true if exists and is symlink. */ static bool is_link(const char *path); /** * Test if path is a device path. * @param path to test. * @return true of is a device path. */ static bool is_device(const char *path); /** * Test if path is a hidden file. * @param path to test. * @return true if exists and is hidden. */ static bool is_hidden(const char *path); /** * Open a file or directory. * @param path of file to open. * @param access mode of descriptor. */ void open(const char *path, access_t access); /** * Assign descriptor directly. * @param descriptor to assign. */ inline void assign(fd_t descriptor) {close(); fd = descriptor;}; /** * Assign a descriptor directly. * @param object to assign descriptor to. * @param descriptor to assign. */ inline static void assign(fsys& object, fd_t descriptor) {object.close(); object.fd = descriptor;}; /** * Open a file descriptor directly. * @param path of file to create. * @param access mode of descriptor. * @param mode of file if created. */ void open(const char *path, unsigned mode, access_t access); /** * Remove a symbolic link explicitly. Other kinds of files are also * deleted. This should be used when uncertain about symlinks requiring * special support. * @param path to remove. * @return error number or 0 on success. */ static int unlink(const char *path); /** * Create a symbolic link. * @param path to create. * @param target of link. * @return error number or 0 on success. */ static int link(const char *path, const char *target); /** * Create a hard link. * @param path to create link to. * @param target of link. * @return error number or 0 on success. */ static int hardlink(const char *path, const char *target); /** * Read a symbolic link to get it's target. * @param path of link. * @param buffer to save target into. * @param size of buffer. */ static int linkinfo(const char *path, char *buffer, size_t size); /** * Close a fsys resource. * @return error code as needed. */ int close(void); /** * Get last error. * @return error number. */ inline int err(void) const {return error;} /** * Direct means to open a read-only file path and return a descriptor. * @param path to open. * @return descriptor on success, invalid handle on failure. */ static fd_t input(const char *path); /** * Direct means to create or access a writable path and return descriptor. * @param path to create. * @return descriptor on success, invalid handle on failure. */ static fd_t output(const char *path); /** * Direct means to create or append a writable path and return descriptor. * @param path to create. * @return descriptor on success, invalid handle on failure. */ static fd_t append(const char *path); /** * Release a file descriptor. * @param descriptor to release. */ static void release(fd_t descriptor); /** * Create pipe. These are created inheritable by default. * @param input descriptor. * @param output descriptor. * @param size of buffer if supported. * @return 0 or error code. */ static int pipe(fd_t& input, fd_t& output, size_t size = 0); /** * Changle inheritable handle. On windows this is done by creating a * duplicate handle and then closing the original. Elsewhere this * is done simply by setting flags. * @param descriptor to modify. * @param enable child process inheritence. * @return 0 on success, error on failure. */ static int inherit(fd_t& descriptor, bool enable); /** * Create inheritable /dev/null handle. * @return null device handle. */ static fd_t null(void); /** * Load a library into memory. * @param path to plugin. * @return 0 on success, else error. */ static int load(const char *path); /** * Execute a process and get exit code. * @param path to execute. * @param argv list. * @param optional env. * @return exit code. */ static int exec(const char *path, char **argv, char **envp = NULL); static inline bool is_file(struct stat *inode) {return S_ISREG(inode->st_mode);} static inline bool is_dir(struct stat *inode) {return S_ISDIR(inode->st_mode);} static inline bool is_link(struct stat *inode) {return S_ISLNK(inode->st_mode);} static inline bool is_dev(struct stat *inode) {return S_ISBLK(inode->st_mode) || S_ISCHR(inode->st_mode);} static inline bool is_char(struct stat *inode) {return S_ISCHR(inode->st_mode);} static inline bool is_disk(struct stat *inode) {return S_ISBLK(inode->st_mode);} static inline bool is_sys(struct stat *inode) {return S_ISSOCK(inode->st_mode) || S_ISFIFO(inode->st_mode);} }; /** * Convenience class for library plugins. * @author David Sugar */ class __EXPORT dso { private: friend class fsys; #ifdef _MSWINDOWS_ HINSTANCE ptr; #else void *ptr; #endif int error; public: #ifdef _MSWINDOWS_ typedef int (FAR WINAPI *addr_t)(); #else typedef void *addr_t; #endif /** * Create dso object for use by load functions. */ dso(); /** * Create and map a dso object. * @param path of library to map. */ dso(const char *path); /** * Destroy dso and release library. */ ~dso(); /** * Map library object with library. * @param name of library to load. */ void map(const char *path); /** * Release loaded library. */ void release(void); /** * Find symbol in loaded module. * @param module to search. * @param symbol to search for. * @return address of symbol or NULL if not found. */ addr_t find(const char *symbol) const; inline int err(void) const {return error;} inline addr_t operator[](const char *symbol) const {return find(symbol);} inline addr_t operator()(const char *symbol) const {return find(symbol);} inline operator bool() {return ptr != NULL;} inline bool operator!() {return ptr == NULL;} }; /** * Convenience class for directories. * @author David Sugar */ class __EXPORT dir : private fsys { private: #ifdef _MSWINDOWS_ WIN32_FIND_DATA *ptr; HINSTANCE mem; #else void *ptr; #endif public: /** * Construct and open a directory path. * @param path of directory. */ dir(const char *path); /** * Construct an unopened directory. */ dir(); /** * Close and release directory. */ ~dir(); /** * Simple direct method to create a directory. * @param path of directory to create. * @param mode of directory. * @return error number or 0 on success. */ static int create(const char *path, unsigned mode); /** * Remove an empty directory. * @param path of directory. * @return error number or 0 on success. */ static int remove(const char *path); /** * Open a directory path for reading. * @param path to open. */ void open(const char *path); /** * Read data from directory. * @param buffer to read into. * @param count of bytes to read. * @return bytes transferred, -1 if error. */ ssize_t read(char *buffer, size_t count); /** * Close and release directory object. */ void close(void); inline int err(void) const {return fsys::err();} inline void reset(void) {fsys::reset();} /** * Test if file descriptor is open. * @return true if open. */ inline operator bool() const {return ptr != NULL;}; /** * Test if file descriptor is closed. * @return true if closed. */ inline bool operator!() const {return ptr == NULL;}; }; /** * Convience type for fsys. */ typedef fsys fsys_t; typedef dir dir_t; typedef dso dso_t; inline bool is_exists(const char *path) {return fsys::is_exists(path);} inline bool is_readable(const char *path) {return fsys::is_readable(path);} inline bool is_writable(const char *path) {return fsys::is_writable(path);} inline bool is_executable(const char *path) {return fsys::is_executable(path);} inline bool is_file(const char *path) {return fsys::is_file(path);} inline bool is_dir(const char *path) {return fsys::is_dir(path);} inline bool is_link(const char *path) {return fsys::is_link(path);} inline bool is_device(const char *path) {return fsys::is_device(path);} END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/persist.h0000644000175000017500000004214712163025062014217 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * The GNU Common C++ persistance engine by Daniel Silverstone. * @file ucommon/persist.h */ #if defined(OLD_STDCPP) || defined(NEW_STDCPP) #if !defined(_MSC_VER) || _MSC_VER >= 1400 #ifndef _UCOMMON_PERSIST_H_ #define _UCOMMON_PERSIST_H_ #ifndef _UCOMMON_PLATFORM_H_ #include #endif #include #include #include #include #include NAMESPACE_UCOMMON #define NS_PREFIX ucc:: // This typedef allows us to declare NewPersistObjectFunction now typedef class PersistObject* (*NewPersistObjectFunction) (void); class __EXPORT PersistException { public: PersistException(const std::string& reason); const std::string& getString() const; virtual ~PersistException() throw(); protected: std::string _what; }; /** * Type manager for persistence engine. * This class manages the types for generation of the persistent objects. * Its data structures are managed automatically by the system. They are * implicitly filled by the constructors who declare classes to the system. * * @author Daniel Silverstone */ class __EXPORT TypeManager { public: /** * This manages a registration to the typemanager - attempting to * remove problems with the optimizers */ class registration { public: registration(const char* name, NewPersistObjectFunction func); virtual ~registration(); private: std::string myName; }; /** * This adds a new construction function to the type manager */ static void add(const char* name, NewPersistObjectFunction construction); /** * And this one removes a type from the managers lists */ static void remove(const char* name); /** * This function creates a new object of the required type and * returns a pointer to it. NULL is returned if we couldn't find * the type */ static PersistObject* createInstanceOf(const char* name); typedef std::map StringFunctionMap; }; /* * The following defines are used to declare and define the relevant code * to allow a class to use the Persistence::Engine code. */ #define DECLARE_PERSISTENCE(ClassType) \ public: \ friend NS_PREFIX PersistEngine& operator>>( NS_PREFIX PersistEngine& ar, ClassType *&ob); \ friend NS_PREFIX PersistEngine& operator<<( NS_PREFIX PersistEngine& ar, ClassType const &ob); \ friend NS_PREFIX PersistObject *createNew##ClassType(); \ virtual const char* getPersistenceID() const; \ static NS_PREFIX TypeManager::Registration registrationFor##ClassType; #define IMPLEMENT_PERSISTENCE(ClassType, FullyQualifiedName) \ NS_PREFIX PersistObject *createNew##ClassType() { return new ClassType; } \ const char* ClassType::getPersistenceID() const {return FullyQualifiedName;} \ NS_PREFIX PersistEngine& operator>>(NS_PREFIX PersistEngine& ar, ClassType &ob) \ { ar >> (NS_PREFIX PersistObject &) ob; return ar; } \ NS_PREFIX PersistEngine& operator>>(NS_PREFIX PersistEngine& ar, ClassType *&ob) \ { ar >> (NS_PREFIX PersistObject *&) ob; return ar; } \ NS_PREFIX PersistEngine& operator<<(NS_PREFIX PersistEngine& ar, ClassType const &ob) \ { ar << (NS_PREFIX PersistObject const *)&ob; return ar; } \ NS_PREFIX TypeManager::Registration \ ClassType::registrationFor##ClassType(FullyQualifiedName, \ createNew##ClassType); class PersistEngine; /** * PersistObject * * Base class for classes that will be persistent. This object is the base * for all Persistent data which is not natively serialized by the * persistence::engine * * It registers itself with the persistence::TypeManager * using a global constructor function. A matching deregister call * is made in a global destructor, to allow DLL's to use the * persistence::engine in a main executable. * * Persistable objects must never maintain bad pointers. If a pointer * doesn't point to something valid, it must be NULL. This is so * the persistence engine knows whether to allocate memory for an object * or whether the memory has been pre-allocated. * * @author Daniel Silverstone */ class __EXPORT PersistObject { public: /** * This constructor is used in serialization processes. * It is called in CreateNewInstance in order to create * an instance of the class to have Read() called on it. */ PersistObject(); /** * Default destructor */ virtual ~PersistObject(); /** * This returns the ID of the persistent object (Its type) */ virtual const char* getPersistenceID() const; /** * This method is used to write to the Persistence::Engine * It is not equivalent to the << operator as it writes only the data * and not the object type etc. */ virtual bool write(PersistEngine& archive) const; /** * This method is used to read from a Persistence::Engine * It is not equivalent to the >> operator as it does no * typesafety or anything. */ virtual bool read(PersistEngine& archive); }; /** * Stream serialization of persistent classes. * This class constructs on a standard C++ STL stream and then * operates in the mode specified. The stream passed into the * constructor must be a binary mode to function properly. * * @author Daniel Silverstone */ class __EXPORT PersistEngine { public: /** * These are the modes the Persistence::Engine can work in */ enum EngineMode { modeRead, modeWrite }; /** * Constructs a Persistence::Engine with the specified stream in * the given mode. The stream must be initialized properly prior * to this call or problems will ensue. */ PersistEngine(std::iostream& stream, EngineMode mode) throw(PersistException); virtual ~PersistEngine(); // Write operations /** * writes a PersistObject from a reference. */ inline void write(const PersistObject &object) throw(PersistException) {write(&object); }; /** * writes a PersistObject from a pointer. */ void write(const PersistObject *object) throw(PersistException); // writes supported primitive types // shortcut, to make the following more readable #define CCXX_ENGINEWRITE_REF(valref) writeBinary((const uint8_t*)&valref,sizeof(valref)) inline void write(int8_t i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(uint8_t i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(int16_t i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(uint16_t i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(int32_t i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(uint32_t i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(float i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(double i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } inline void write(bool i) throw(PersistException) { CCXX_ENGINEWRITE_REF(i); } #undef CCXX_ENGINEWRITE_REF void write(const std::string& str) throw(PersistException); // Every write operation boils down to one or more of these void writeBinary(const uint8_t* data, const uint32_t size) throw(PersistException); // Read Operations /** * reads a PersistObject into a reference overwriting the object. */ void read(PersistObject &object) throw(PersistException); /** * reads a PersistObject into a pointer allocating memory for the object if necessary. */ void read(PersistObject *&object) throw(PersistException); // reads supported primitive types // shortcut, to make the following more readable #define CCXX_ENGINEREAD_REF(valref) readBinary((uint8_t*)&valref,sizeof(valref)) inline void read(int8_t& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(uint8_t& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(int16_t& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(uint16_t& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(int32_t& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(uint32_t& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(float& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(double& i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } inline void read(bool &i) throw(PersistException) { CCXX_ENGINEREAD_REF(i); } #undef CCXX_ENGINEREAD_REF void read(std::string& str) throw(PersistException); // Every read operation boiled down to one or more of these void readBinary(uint8_t* data, uint32_t size) throw(PersistException); private: /** * reads the actual object data into a pre-instantiated object pointer * by calling the read function of the derived class. */ void readObject(PersistObject* object) throw(PersistException); /** * reads in a class name, and caches it into the ClassMap. */ const std::string readClass() throw(PersistException); /** * The underlying stream */ std::iostream& myUnderlyingStream; /** * The mode of the engine. read or write */ EngineMode myOperationalMode; /** * Typedefs for the Persistence::PersistObject support */ typedef std::vector ArchiveVector; typedef std::map ArchiveMap; typedef std::vector ClassVector; typedef std::map ClassMap; ArchiveVector myArchiveVector; ArchiveMap myArchiveMap; ClassVector myClassVector; ClassMap myClassMap; }; #define CCXX_RE(ar,ob) ar.read(ob); return ar #define CCXX_WE(ar,ob) ar.write(ob); return ar // Standard >> and << stream operators for PersistObject /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, PersistObject &ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, PersistObject *&ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, PersistObject const &ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, PersistObject const *ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, int8_t& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, int8_t ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, uint8_t& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, uint8_t ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, int16_t& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, int16_t ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, uint16_t& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, uint16_t ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, int32_t& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, int32_t ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, uint32_t& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, uint32_t ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, float& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, float ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, double& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, double ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, std::string& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, std::string ob) throw(PersistException) {CCXX_WE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator >>( PersistEngine& ar, bool& ob) throw(PersistException) {CCXX_RE(ar,ob);} /** @relates PersistEngine */ inline PersistEngine& operator <<( PersistEngine& ar, bool ob) throw(PersistException) {CCXX_WE(ar,ob);} #undef CCXX_RE #undef CCXX_WE /** * The following are template classes */ /** * @relates PersistEngine * serialize a vector of some serializable content to * the engine */ template PersistEngine& operator <<( PersistEngine& ar, typename std::vector const& ob) throw(PersistException) { ar << (uint32_t)ob.size(); for(unsigned int i=0; i < ob.size(); ++i) ar << ob[i]; return ar; } /** * @relates PersistEngine * deserialize a vector of deserializable content from * an engine. */ template PersistEngine& operator >>( PersistEngine& ar, typename std::vector& ob) throw(PersistException) { ob.clear(); uint32_t siz; ar >> siz; ob.resize(siz); for(uint32_t i=0; i < siz; ++i) ar >> ob[i]; return ar; } /** * @relates PersistEngine * serialize a deque of some serializable content to * the engine */ template PersistEngine& operator <<( PersistEngine& ar, typename std::deque const& ob) throw(PersistException) { ar << (uint32_t)ob.size(); for(typename std::deque::const_iterator it=ob.begin(); it != ob.end(); ++it) ar << *it; return ar; } /** * @relates PersistEngine * deserialize a deque of deserializable content from * an engine. */ template PersistEngine& operator >>( PersistEngine& ar, typename std::deque& ob) throw(PersistException) { ob.clear(); uint32_t siz; ar >> siz; //ob.resize(siz); for(uint32_t i=0; i < siz; ++i) { T node; ar >> node; ob.push_back(node); //ar >> ob[i]; } return ar; } /** * @relates PersistEngine * serialize a map with keys/values which both are serializeable * to an engine. */ template PersistEngine& operator <<( PersistEngine& ar, typename std::map const & ob) throw(PersistException) { ar << (uint32_t)ob.size(); for(typename std::map::const_iterator it = ob.begin();it != ob.end();++it) ar << it->first << it->second; return ar; } /** * @relates PersistEngine * deserialize a map with keys/values which both are serializeable * from an engine. */ template PersistEngine& operator >>( PersistEngine& ar, typename std::map& ob) throw(PersistException) { ob.clear(); uint32_t siz; ar >> siz; for(uint32_t i=0; i < siz; ++i) { Key a; ar >> a; ar >> ob[a]; } return ar; } /** * @relates PersistEngine * serialize a pair of some serializable content to the engine. */ template PersistEngine& operator <<( PersistEngine& ar, std::pair &ob) throw(PersistException) { ar << ob.first << ob.second; return ar; } /** * @relates PersistEngine * deserialize a pair of some serializable content to the engine. */ template PersistEngine& operator >>(PersistEngine& ar, std::pair &ob) throw(PersistException) { ar >> ob.first >> ob.second; return ar; } END_NAMESPACE #endif #endif #endif ucommon-6.0.7/inc/ucommon/socket.h0000644000175000017500000016265412163025062014024 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Common socket class and address manipulation. * This offers a common socket base class that exposes socket functionality * based on what the target platform supports. Support for multicast, IPV6 * addressing, and manipulation of cidr policies are all supported here. * @file ucommon/socket.h */ #ifndef _UCOMMON_SOCKET_H_ #define _UCOMMON_SOCKET_H_ #ifndef _UCOMMON_TIMERS_H_ #include #endif #ifndef _UCOMMON_LINKED_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif extern "C" { struct addrinfo; } #ifdef _MSWINDOWS_ #define SHUT_RDWR SD_BOTH #define SHUT_WR SD_SEND #define SHUT_RD SD_RECV #else #include #include #include #include #include #endif #include #include #ifndef IPTOS_LOWDELAY #define IPTOS_LOWDELAY 0x10 #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 #define IPTOS_MINCOST 0x02 #endif #ifdef AF_UNSPEC #define DEFAULT_FAMILY AF_UNSPEC #else #define DEFAULT_FAMILY AF_INET #endif struct sockaddr_internet; typedef struct sockaddr *sockaddr_t; typedef struct sockaddr sockaddr_struct; // older gcc needs...? /** * An object that holds ipv4 or ipv6 binary encoded host addresses. */ typedef struct hostaddr_internet { union { struct in_addr ipv4; #ifdef AF_INET6 struct in6_addr ipv6; #endif }; } inethostaddr_t; #if defined(AF_INET6) || defined(__CYGWIN__) /** * An object that can hold a ipv4 or ipv6 socket address. This would be * used for tcpip socket connections. We do not use sockaddr_storage * because it is not present in pre ipv6 stacks, and because the storage * size also includes the size of the path of a unix domain socket on * posix systems. */ typedef struct sockaddr_internet { union { #ifdef AF_INET6 struct sockaddr_in6 ipv6; #endif struct sockaddr_in ipv4; struct sockaddr address; }; } inetsockaddr_t; #else typedef struct sockaddr_internet { union { struct sockaddr_in ipv4; struct sockaddr address; }; } inetsockaddr_t; struct sockaddr_storage { #ifdef AF_UNIX char sa_data[128]; #else char sa_data[sizeof(struct sockaddr_in)]; #endif }; #endif #ifndef SOCK_DCCP #define SOCK_DCCP 6 #endif #ifndef IPPROTO_DCCP #define IPPROTO_DCCP 23 #endif #ifndef SOL_DCCP #define SOL_DCCP 269 #endif #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12 #define DCCP_SOCKOPT_CCID 13 #define DCCP_SOCKOPT_TX_CCID 14 #define DCCP_SOCKOPT_RX_CCID 15 NAMESPACE_UCOMMON /** * A class to hold internet segment routing rules. This class can be used * to provide a stand-alone representation of a cidr block of internet * addresses or chained together into some form of access control list. The * cidr class can hold segments for both IPV4 and IPV6 addresses. The class * accepts cidr's defined as C strings, typically in the form of address/bits * or address/submask. These routines auto-detect ipv4 and ipv6 addresses. * @author David Sugar */ class __EXPORT cidr : public LinkedObject { protected: int Family; inethostaddr_t Netmask, Network; char Name[16]; unsigned mask(const char *cp) const; inethostaddr_t broadcast(void) const; unsigned mask(void) const; public: /** * A convenience type for using a pointer to a linked list as a policy chain. */ typedef LinkedObject policy; /** * Create an uninitialized cidr. */ cidr(); /** * Create an unlinked cidr from a string. The string is typically in * the form base-host-address/range, where range might be a bit count * or a network mask. * @param string for cidr block. */ cidr(const char *string); /** * Create an unnamed cidr entry on a specified policy chain. * @param policy chain to link cidr to. * @param string for cidr block. */ cidr(policy **policy, const char *string); /** * Create a named cidr entry on a specified policy chain. * @param policy chain to link cidr to. * @param string for cidr block. * @param name of this policy object. */ cidr(policy **policy, const char *string, const char *name); /** * Construct a copy of an existing cidr. * @param existing cidr we copy from. */ cidr(const cidr& existing); /** * Find the smallest cidr entry in a list that matches the socket address. * @param policy chain to search. * @param address to search for. * @return smallest cidr or NULL if none match. */ static const cidr *find(const policy *policy, const struct sockaddr *address); /** * Get the largest container cidr entry in a list that matches the * socket address. * @param policy chain to search. * @param address to search for. * @return largest cidr or NULL if none match. */ static const cidr *container(const policy *policy, const struct sockaddr *address); /** * Get the saved name of our cidr. This is typically used with find * when the same policy name might be associated with multiple non- * overlapping cidr blocks. A typical use might to have a cidr * block like 127/8 named "localdomain", as well as the ipv6 "::1". * @return name of cidr. */ inline const char *getName(void) const {return Name;}; /** * Get the address family of our cidr block object. * @return family of our cidr. */ inline int getFamily(void) const {return Family;}; /** * Get the network host base address of our cidr block. * @return binary network host address. */ inline inethostaddr_t getNetwork(void) const {return Network;}; /** * Get the effective network mask for our cidr block. * @return binary network mask for our cidr. */ inline inethostaddr_t getNetmask(void) const {return Netmask;}; /** * Get the broadcast host address represented by our cidr. * @return binary broadcast host address. */ inline inethostaddr_t getBroadcast(void) const {return broadcast();} /** * Get the number of bits in the cidr bitmask. * @return bit mask of cidr. */ inline unsigned getMask(void) const {return mask();} /** * Set our cidr to a string address. Replaces prior value. * @param string to set for cidr. */ void set(const char *string); /** * Test if a given socket address falls within this cidr. * @param address of socket to test. * @return true if address is within cidr. */ bool is_member(const struct sockaddr *address) const; /** * Test if a given socket address falls within this cidr. * @param address of socket to test. * @return true if address is within cidr. */ inline bool operator==(const struct sockaddr *address) const {return is_member(address);}; /** * Test if a given socket address falls outside this cidr. * @param address of socket to test. * @return true if address is outside cidr. */ inline bool operator!=(const struct sockaddr *address) const {return !is_member(address);}; }; /** * A generic socket base class. This class can be used directly or as a * base class for building network protocol stacks. This common base tries * to handle UDP and TCP sockets, as well as support multicast, IPV4/IPV6 * addressing, and additional addressing domains (such as Unix domain sockets). * @author David Sugar */ class __EXPORT Socket { protected: socket_t so; int ioerr; timeout_t iowait; public: /** * Get an address list directly. This is used internally by some derived * socket types when generic address lists would be invalid. * @param host name in the form address or "address:port" * @param service id or port to use if not specified in host string. * @param type of service to get. * @param protocol of service to get. */ static struct addrinfo *query(const char *host, const char *service, int type = SOCK_STREAM, int protocol = 0); /** * Release an address list directly. This is used internally by some * derived socket types which do not use generic address lists. * @param list of addresses. */ static void release(struct addrinfo *list); /** * A generic socket address class. This class uses the addrinfo list * to store socket multiple addresses in a protocol and family * independent manner. Hence, this address class can be used for ipv4 * and ipv6 sockets, for assigning connections to multiple hosts, etc. * The address class will call the resolver when passed host names. * @author David Sugar */ class __EXPORT address { protected: struct addrinfo *list; public: /** * Construct a socket address. This is used to get an address to * bind a socket interface to. The address can be specified as the * ip address of the interface or as a "hostname". If a hostname * is used, then family should be specified for clarity. * @param family of socket address. Needed when host names are used. * @param address or hostname. * @param type of socket (stream, dgram, etc). * @param protocol number of socket. */ address(int family, const char *address, int type = SOCK_STREAM, int protocol = 0); /** * Construct a socket address for an existing socket. This can be the * name of a host or to perform a lookup in a domain for a service. * Family can be used to restrict the set of results returned, however * since things like connecto() already filter by family and create * will use family from the addrinfo, in most cases AF_UNSPEC can be * used. This may be depreciated in favor of the constructor that * matches a set() method. * @param family of hosts to filter by or AF_UNSPEC. * @param hostname or ip address. The socket family is used for hostnames. * @param service port or name we are referencing or NULL. */ address(int family, const char *hostname, const char *service = NULL); /** * Construct a socket address list for a service. * @param host address for service. * @param service name or port number. * @param type of service, stream, dgram, etc. */ address(const char *host, const char *service, int type = SOCK_STREAM); /** * Construct a socket address from host and service. This is primarily * used to construct a list of potential service connections by pure * port numbers or for host lookup only. * @param hostname or address to use. * @param service port or 0. */ address(const char *hostname, unsigned service = 0); /** * Construct an empty address. */ address(); /** * Copy constructor. * @param reference to object to copy from. */ address(const address& reference); /** * Destroy address. Deallocate addrinfo structure. */ ~address(); /** * Get the first socket address in our address list. * @return first socket address or NULL if none. */ struct sockaddr *get(void) const; inline struct sockaddr *getAddr(void) const {return get();} inline struct sockaddr *operator()(void) const {return get();} /** * Get the first socket address by casted reference. * @return first socket address we resolved or NULL if none. */ inline operator struct sockaddr *() const {return get();}; /** * Get the first socket address of specified family from our list. * @param family to seek. * @return first socket address of family or NULL if none. */ struct sockaddr *get(int family) const; inline struct sockaddr *operator()(int family) const {return get(family);} inline operator struct sockaddr_in *() const {return (struct sockaddr_in *)get(AF_INET);} #ifdef AF_INET6 inline operator struct sockaddr_in6 *() const {return (struct sockaddr_in6 *)get(AF_INET6);} #endif /** * Get the family of the first member in a list of services. * @return family of first socket address or 0 if none. */ int family(void) const; /** * Find a specific socket address in our address list. * @return matching address from list or NULL if not found. */ struct sockaddr *find(const struct sockaddr *addr) const; /** * Get the full socket address list from the object. * @return addrinfo list we resolved or NULL if none. */ inline struct addrinfo *getList(void) const {return list;}; /** * Get the full socket address list by casted reference. * @return addrinfo list we resolved or NULL if none. */ inline operator struct addrinfo *() const {return list;}; /** * Return the full socket address list by pointer reference. * @return addrinfo list we resolved or NULL if none. */ inline struct addrinfo *operator*() const {return list;}; /** * Test if the address list is valid. * @return true if we have an address list. */ inline operator bool() const {return list != NULL;}; /** * Test if we have no address list. * @return true if we have no address list. */ inline bool operator!() const {return list == NULL;}; /** * Clear current object. */ void clear(void); /** * Set the host addresses to form a new list. * @param hostname or address to resolve. * @param service name or port number, or NULL if not used. * @param type of socket (stream or dgram) to filter list by. */ void set(const char *hostname, const char *service = NULL, int type = SOCK_STREAM); /** * Append additional host addresses to our list. * @param hostname or address to resolve. * @param service name or port number, or NULL if not used. * @param type of socket (stream or dgram). */ void add(const char *hostname, const char *service = NULL, int type = SOCK_STREAM); /** * Set an entry for host binding. * @param family of socket address. Needed when hostnames are used. * @param address or hostname. * @param type of socket (stream, dgram, etc). * @param protocol number of socket. */ void set(int family, const char *address, int type = SOCK_STREAM, int protocol = 0); /** * Add an individual socket address to our address list. * @param address to add. */ void add(sockaddr *address); /** * Insert unique members from another socket address list to ours. * @param address list to insert into list. * @return count of addresses added. */ unsigned insert(struct addrinfo *address); /** * Remove members from another socket address list from ours. * @param address list to remove from list. * @return count of addresses removed. */ unsigned remove(struct addrinfo *address); /** * Remove an individual socket address from our address list. * @param address to remove. * @return true if found and removed, false if not found. */ bool remove(struct sockaddr *address); /** * Insert an individual socket address to our address list only if * unique. * @param address to insert into list. * @return true if inserted, false if duplicate. */ bool insert(struct sockaddr *address); /** * Copy an existing addrinfo into our object. This is also used * to support the copy constructor. * @param address list to copy from. */ void copy(const struct addrinfo *address); /** * Set an individual socket address for our address list. * @param address to add. */ void set(struct sockaddr *address); /** * Set a socket address from host and service. * @param hostname or address to use. * @param service port or 0. */ void set(const char *hostname, unsigned service = 0); /** * Duplicate a socket address. * @param address to duplicate. * @return duplicate address object. */ static struct sockaddr *dup(struct sockaddr *address); /** * Convert address object into ipv4 address. * @param address to convert. * @return new ipv4 address or NULL if not ipv4. */ static struct sockaddr_in *ipv4(struct sockaddr *address); #ifdef AF_INET6 /** * Convert address object into ipv6 address. * @param address to convert. * @return new ipv6 address or NULL if not ipv6. */ static struct sockaddr_in6 *ipv6(struct sockaddr *address); #endif }; friend class address; /** * Create a socket object for use. */ Socket(); /** * Create socket as duped handle of existing socket. * @param existing socket to dup. */ Socket(const Socket& existing); /** * Create socket from existing socket descriptor. * @param socket descriptor to use. */ Socket(socket_t socket); /** * Create and connect a socket to an address from an address list. The * type of socket created is based on the type we are connecting to. * @param address list to connect with. */ Socket(struct addrinfo *address); /** * Create an unbound socket of a specific type. * @param family of our new socket. * @param type (stream, udp, etc) of our new socket. * @param protocol number of our new socket.' */ Socket(int family, int type, int protocol = 0); /** * Create a bound socket. If one wishes to listen for connections on * a protocol, then ListenSocket should be used instead. * @param address to bind or "*" for all. * @param port number of service to bind. * @param family to bind as. * @param type of socket to bind (stream, udp, etc). * @param protocol of socket to bind. */ Socket(const char *address, const char *port, int family = AF_UNSPEC, int type = 0, int protocol = 0); /** * Shutdown, close, and destroy socket. */ virtual ~Socket(); /** * Cancel pending i/o by shutting down the socket. */ void cancel(void); /** * Cancel pending i/o by shutting down the socket. * @param socket to shutdown. */ static void cancel(socket_t socket); /** * Shutdown and close the socket. */ void release(void); /** * Get error code. */ inline int err(void) const {return ioerr;} /** * See the number of bytes in the receive queue. * @param value to test for. * @return true if at least that many bytes waiting in receive queue. */ bool is_pending(unsigned value) const; /** * Test if socket is connected. * @return true if connected. */ bool connected(void) const; /** * Test for pending input data. This function can wait up to a specified * timeout for data to appear. * @param timeout or 0 if none. * @return true if input data waiting. */ bool wait(timeout_t timeout = 0) const; /** * Set nodelay option for tcp socket. * @return 0 if successful, -1 on error. */ inline int nodelay(void) const {return nodelay(so);}; /** * Test for pending input data. This function can wait up to a specified * timeout for data to appear. * @param socket to test. * @param timeout or 0 if none. * @return true if input data waiting. */ static bool wait(socket_t socket, timeout_t timeout = 0); /** * Test for output data sent. This function can wait up to a specified * timeout for data to appear sent. * @param timeout or 0 if none. * @return false if cannot send more output/out of buffer space. */ bool waitSending(timeout_t timeout = 0) const; /** * Get the number of bytes of data in the socket receive buffer. * @return bytes pending. */ inline unsigned pending(void) const {return pending(so);}; /** * Set socket for unicast mode broadcasts. * @param enable broadcasting if true. * @return 0 on success, -1 if error. */ inline int broadcast(bool enable) {return broadcast(so, enable);}; /** * Set socket for keepalive packets. * @param enable keep-alive if true. * @return 0 on success, -1 if error. */ inline int keepalive(bool enable) {return keepalive(so, enable);}; /** * Set socket blocking I/O mode. * @param enable true for blocking I/O. * @return 0 on success, -1 if error. */ inline int blocking(bool enable) {return blocking(so, enable);}; /** * Set multicast mode and multicast broadcast range. * @param ttl to set for multicast socket or 0 to disable multicast. * @return 0 on success, -1 if error. */ inline int multicast(unsigned ttl = 1) {return multicast(so, ttl);}; /** * Set loopback to read multicast packets we broadcast. * @param enable true to loopback, false to ignore. * @return 0 on success, -1 if error. */ inline int loopback(bool enable) {return loopback(so, enable);}; /** * Get socket error code. * @return socket error code. */ inline int getError(void) {return error(so);}; /** * Set the time to live before packets expire. * @param time to live to set. * @return 0 on success, -1 on error. */ inline int ttl(unsigned char time) {return ttl(so, time);}; /** * Set the size of the socket send buffer. * @param size of send buffer to set. * @return 0 on success, -1 on error. */ inline int sendsize(unsigned size) {return sendsize(so, size);}; /** * Set the size to wait before sending. * @param size of send wait buffer to set. * @return 0 on success, -1 on error. */ inline int sendwait(unsigned size) {return sendwait(so, size);}; /** * Set the size of the socket receive buffer. * @param size of recv buffer to set. * @return 0 on success, -1 on error. */ inline int recvsize(unsigned size) {return recvsize(so, size);}; /** * Get the type of a socket. * @param socket descriptor. * @return socket type. */ static int type(socket_t socket); /** * Set segment size and get MTU. * @param socket to modify. * @param size of segment or zero to not set. * @return mtu size of socket. */ static unsigned segsize(socket_t socket, unsigned size = 0); /** * Set congestion control id. * @param socket to modify. * @param ccid value to set. * @return true if success, false if not dccp or not supported ccid used. */ static bool ccid(socket_t socket, uint8_t id); /** * Get the type of a socket. * @return socket type. */ inline int type(void) {return type(so);}; /** * Set segment size and get mtu of a socket. * @param size of segment or 0 to leave unchanged. * @return mtu size. */ inline unsigned segsize(unsigned size) {return segsize(so, size);}; /** * Set ccid of dccp socket. * @param ccid to set. * @return true if success, false if not dccp or not supported ccid used. */ inline bool ccid(uint8_t id) {return ccid(so, id);}; /** * Set the type of service field of outgoing packets. Some useful * values include IPTOS_LOWDELAY to minimize delay for interactive * traffic, IPTOS_THROUGHPUT to optimize throughput, OPTOS_RELIABILITY * to optimize for reliability, and IPTOS_MINCOST for low speed use. * @param type of service value. * @return 0 on success or -1 on error. */ inline int tos(int type) {return tos(so, type);}; /** * Set packet priority, 0 to 6 unless privileged. Should be set before * type-of-service. * @param scheduling priority for packet scheduling. * @return 0 on success, -1 on error. */ inline int priority(int scheduling) {return priority(so, scheduling);}; /** * Shutdown the socket communication channel. */ inline void shutdown(void) {::shutdown(so, SHUT_RDWR);}; /** * Connect our socket to a remote host from an address list. * For TCP (and DCCP) sockets, the entire list may be tried. For UDP, * connect is only a state and the first valid entry in the list is used. * @param list of addresses to connect to. * @return 0 on success or error. */ int connectto(struct addrinfo *list); /** * Disconnect a connected socket. Depending on the implementation, this * might be done by connecting to AF_UNSPEC, connecting to a 0 address, * or connecting to self. * @return 0 on success or error. */ int disconnect(void); /** * Join socket to multicast group. * @param list of groups to join. * @return 0 on success, -1 on error. */ int join(const struct addrinfo *list); /** * Drop socket from multicast group. * @param list of groups to drop. * @return 0 on success, -1 on error. */ int drop(const struct addrinfo *list); /** * Socket i/o timer setting. * @param timeout to wait, inf for blocking, 0 pure non-blocking. * @return 0 on success or error code. */ int wait(timeout_t timeout = Timer::inf); /** * Peek at data waiting in the socket receive buffer. * @param data pointer to save data in. * @param number of bytes to peek. * @return number of bytes actually read, or 0 if no data waiting. */ size_t peek(void *data, size_t number) const; /** * Read data from the socket receive buffer. This will be used in abi 4. * @param data pointer to save data in. * @param number of bytes to read. * @param address of peer data was received from. * @return number of bytes actually read, 0 if none, -1 if error. */ size_t readfrom(void *data, size_t number, struct sockaddr_storage *address = NULL); /** * Write data to the socket send buffer. This will be used in abi 4. * @param data pointer to write data from. * @param number of bytes to write. * @param address of peer to send data to if not connected. * @return number of bytes actually sent, 0 if none, -1 if error. */ size_t writeto(const void *data, size_t number, const struct sockaddr *address = NULL); /** * Read a newline of text data from the socket and save in NULL terminated * string. This uses an optimized I/O method that takes advantage of * socket peeking. This presumes a connected socket on a streamble * protocol. Because the trailing newline is dropped, the return size * may be greater than the string length. If there was no data read * because of eof of data, an error has occured, or timeout without * input, then 0 will be returned. * @param data to save input line. * @param size of input line buffer. * @return number of bytes read, 0 if none, err() has error. */ size_t readline(char *data, size_t size); /** * Print formatted string to socket. * @param format string. * @return number of bytes sent. */ size_t printf(const char *format, ...) __PRINTF(2,3); /** * Read a string of input from the socket and strip trailing newline. * This uses an optimized I/O method that takes advantage of * socket peeking. This presumes a connected socket on a streamble * protocol. Because the trailing newline is dropped, the return size * may be greater than the string length. If there was no data read * because of eof of data, an error has occured, or timeout without * input, then 0 will be returned. * @param buffer to save input line. * @return number of bytes read, 0 if none, err() has error. */ size_t readline(String& buffer); /** * Read a newline of text data from the socket and save in NULL terminated * string. This uses an optimized I/O method that takes advantage of * socket peeking. As such, it has to be rewritten to be used in a ssl * layer socket. * @param socket to read from. * @param data to save input line. * @param size of input line buffer. * @param timeout to wait for a complete input line. * @return number of bytes read, 0 if none, -1 if error. */ static ssize_t readline(socket_t socket, char *data, size_t size, timeout_t timeout = Timer::inf); /** * Print formatted string to socket. * @param socket to write to. * @param format string. * @return number of bytes sent, -1 if error. */ static ssize_t printf(socket_t socket, const char *format, ...) __PRINTF(2,3); /** * Write a null terminated string to the socket. This exists because * we messed up consistency with the original puts() method. In the * future there will be a single puts() that has a NULL default. * @param string to write. * @return number of bytes sent, 0 if none, -1 if error. */ size_t writes(const char *string); /** * Test if socket is valid. * @return true if valid socket. */ operator bool(); /** * Test if socket is invalid. * @return true if socket is invalid. */ bool operator!() const; /** * Assign socket from a socket descriptor. Release existing socket if * one present. * @param socket descriptor to assign to object. */ Socket& operator=(socket_t socket); /** * Get the socket descriptor by casting. * @return socket descriptor of object. */ inline operator socket_t() const {return so;}; /** * Get the socket descriptor by pointer reference. * @return socket descriptor of object. */ inline socket_t operator*() const {return so;}; /** * Get the number of bytes pending in the receive buffer of a socket * descriptor. * @param socket descriptor. * @return number of pending bytes. */ static unsigned pending(socket_t socket); /** * Set the send size of a socket descriptor. * @param socket descriptor. * @param size of send buffer to set. * @return 0 on success, -1 on error. */ static int sendsize(socket_t socket, unsigned size); /** * Set the size to wait before sending. * @param socket descriptor. * @param size of send wait buffer to set. * @return 0 on success, -1 on error. */ static int sendwait(socket_t socket, unsigned size); /** * Set the receive size of a socket descriptor. * @param socket descriptor. * @param size of receive buffer to set. * @return 0 on success, -1 on error. */ static int recvsize(socket_t socket, unsigned size); /** * Connect socket descriptor to a remote host from an address list. * For TCP (and DCCP) sockets, the entire list may be tried. For UDP, * connect is only a state and the first valid entry in the list is used. * @param socket descriptor. * @param list of addresses to connect to. * @return 0 on success, -1 on error. */ static int connectto(socket_t socket, struct addrinfo *list); /** * Disconnect a connected socket descriptor. * @param socket descriptor. * @return 0 on success, -1 on error. */ static int disconnect(socket_t socket); /** * Drop socket descriptor from multicast group. * @param socket descriptor. * @param list of groups to drop. * @return 0 on success, -1 on error. */ static int drop(socket_t socket, const struct addrinfo *list); /** * Join socket descriptor to multicast group. * @param socket descriptor. * @param list of groups to join. * @return 0 on success, -1 on error. */ static int join(socket_t socket, const struct addrinfo *list); /** * Get socket error code of socket descriptor. * @param socket descriptor. * @return socket error code. */ static int error(socket_t socket); /** * Set multicast mode and multicast broadcast range for socket descriptor. * @param socket descriptor. * @param ttl to set for multicast socket or 0 to disable multicast. * @return 0 if success, -1 if error. */ static int multicast(socket_t socket, unsigned ttl = 1); /** * Set loopback to read multicast packets socket descriptor broadcasts. * @param socket descriptor. * @param enable true to loopback, false to ignore. * @return 0 if success, -1 if error. */ static int loopback(socket_t socket, bool enable); /** * Set socket blocking I/O mode of socket descriptor. * @param socket descriptor. * @param enable true for blocking I/O. * @return 0 if success, -1 if error. */ static int blocking(socket_t socket, bool enable); /** * Set socket for keepalive packets for socket descriptor. * @param socket descriptor. * @param enable keep-alive if true. * @return 0 if success, -1 if error. */ static int keepalive(socket_t socket, bool enable); /** * Set socket for unicast mode broadcasts on socket descriptor. * @param socket descriptor. * @param enable broadcasting if true. * @return 0 if success, -1 if error. */ static int broadcast(socket_t socket, bool enable); /** * Set tcp nodelay option on socket descriptor. * @param socket descriptor. * @return 0 if success, -1 if error. */ static int nodelay(socket_t socket); /** * Set packet priority of socket descriptor. * @param socket descriptor. * @param scheduling priority for packet scheduling. * @return 0 on success, -1 on error. */ static int priority(socket_t socket, int scheduling); /** * Set type of service of socket descriptor. * @param socket descriptor. * @param type of service. * @return 0 on success, -1 on error. */ static int tos(socket_t socket, int type); /** * Set the time to live for the socket descriptor. * @param socket descriptor. * @param time to live to set. * @return 0 on success, -1 on error. */ static int ttl(socket_t socket, unsigned char time); /** * Get the address family of the socket descriptor. * @return address family. */ static int family(socket_t socket); /** * Get the address family of a socket address object. * @param address to examine. * @return address family. */ inline static int family(const struct sockaddr_storage& address) {return ((const struct sockaddr *)&address)->sa_family;}; /** * Get the address family of an internet socket address object. * @param address to examine. * @return address family. */ inline static int family(const struct sockaddr_internet& address) {return address.address.sa_family;}; /** * Get data waiting in receive queue. * @param socket to get from. * @param buffer to save. * @param size of data buffer to request. * @param flags for i/o operation (MSG_OOB, MSG_PEEK, etc). * @param address of source. * @return number of bytes received, -1 if error. */ static ssize_t recvfrom(socket_t socket, void *buffer, size_t size, int flags = 0, struct sockaddr_storage *address = NULL); /** * Send data on socket. * @param socket to send to. * @param buffer to send. * @param size of data buffer to send. * @param flags for i/o operation (MSG_OOB, MSG_PEEK, etc). * @param address of destination, NULL if connected. * @return number of bytes sent, -1 if error. */ static ssize_t sendto(socket_t socket, const void *buffer, size_t size, int flags = 0, const struct sockaddr *address = NULL); /** * Send reply on socket. Used to reply to a recvfrom message. * @param socket to send to. * @param buffer to send. * @param size of data buffer to send. * @param flags for i/o operation (MSG_OOB, MSG_PEEK, etc). * @param address to reply to. * @return number of bytes sent, -1 if error. */ inline static ssize_t replyto(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_storage *address) {return sendto(socket, buffer, size, flags, (const struct sockaddr *)address);}; /** * Send to internet socket. * @param socket to send to. * @param buffer to send. * @param size of data buffer to send. * @param flags for i/o operation (MSG_OOB, MSG_PEEK, etc). * @param address to send to. * @return number of bytes sent, -1 if error. */ inline static ssize_t sendinet(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_internet *address) {return sendto(socket, buffer, size, flags, (const struct sockaddr *)address);}; /** * Get internet data waiting in receive queue. * @param socket to get from. * @param buffer to save. * @param size of data buffer to request. * @param flags for i/o operation (MSG_OOB, MSG_PEEK, etc). * @param address of source. * @return number of bytes received, -1 if error. */ static ssize_t recvinet(socket_t socket, void *buffer, size_t size, int flags = 0, struct sockaddr_internet *address = NULL); /** * Bind the socket descriptor to a known interface and service port. * @param socket descriptor to bind. * @param address to bind to or "*" for all. * @param service port to bind. * @param protocol to use or 0 if default. * @return 0 on success, -1 if error. */ static int bindto(socket_t socket, const char *address, const char *service, int protocol = 0); /** * Bind the socket descriptor to a known interface listen on service port. * @param socket descriptor to bind. * @param address of interface to bind to. * @param backlog for service. * @return 0 on success, -1 if error. */ static int listento(socket_t socket, const struct sockaddr *address, int backlog = 5); /** * Bind the socket descriptor to a known interface. * @param socket descriptor to bind. * @param address of interface to bind to. * @return 0 on success, -1 if error. */ static int bindto(socket_t socket, const struct sockaddr *address); /** * Accept a socket connection from a remote host. * @param socket descriptor to accept from. * @param address of socket accepting. * @return new socket accepted. */ static socket_t acceptfrom(socket_t socket, struct sockaddr_storage *address = NULL); /** * Create a socket object unbound. * @param family of socket. * @param type of socket. * @param protocol of socket. * @return socket descriptor created or INVALID_SOCKET. */ static socket_t create(int family, int type, int protocol); /** * Create a connected socket. * @param address list to connect to. * @param type of socket to create. * @param protocol of socket. * @return socket descriptor created or INVALID_SOCKET. */ static socket_t create(const struct addrinfo *address, int type, int protocol); /** * Create a bound socket for a service. * @param iface to bind. * @param service port to bind. * @param family to select or AF_UNSPEC * @param type of socket to create. * @param protocol of socket to create. * @return socket descriptor created or INVALID_SOCKET. */ static socket_t create(const char *iface, const char *service, int family = AF_UNSPEC, int type = 0, int protocol = 0); /** * Create a connected socket for a service. * @param address of service for connect. * @return socket descriptor. */ static socket_t create(const Socket::address &address); /** * Release (close) a socket. * @param socket to close. */ static void release(socket_t socket); /** * Lookup and return the host name associated with a socket address. * @param address to lookup. * @param buffer to save hostname into. * @param size of buffer to save hostname into. * @return buffer or NULL if lookup fails. */ static char *hostname(const struct sockaddr *address, char *buffer, size_t size); /** * Create an address info lookup hint based on the family and type * properties of a socket descriptor. * @param socket descriptor. * @param hint buffer. * @return hint buffer. */ static struct addrinfo *hinting(socket_t socket, struct addrinfo *hint); /** * Lookup a host name and service address based on the addressing family * and socket type of a socket descriptor. Store the result in a socket * address structure. * @param socket descriptor. * @param address that is resolved. * @param hostname to resolve. * @param service port. * @return socket address size. */ static socklen_t query(socket_t socket, struct sockaddr_storage *address, const char *hostname, const char *service); /** * Get the size of a socket address. * @param address of socket. * @return size to use for this socket address object. */ static socklen_t len(const struct sockaddr *address); /** * Compare socket addresses. Test if the address and service matches * or if there is no service, then just the host address values. * @param address1 to compare. * @param address2 to compare. * @return true if same family and equal. */ static bool equal(const struct sockaddr *address1, const struct sockaddr *address2); /** * Copy a socket address. * @param target address pointer to copy into. * @param origin address pointer to copy from. * @return number of bytes copied, 0 if invalid. */ static unsigned copy(struct sockaddr *target, const struct sockaddr *origin); /** * Store an address into an address object. * @param storage for address. * @param address to store. * @return number of bytes stored. */ inline static unsigned store(struct sockaddr_storage *storage, const struct sockaddr *address) {return copy((struct sockaddr*)storage, address);}; /** * Store an address into an internet address object. * @param storage for address. * @param address to store. * @return number of bytes stored. */ static unsigned store(struct sockaddr_internet *storage, const struct sockaddr *address); /** * Compare socket host addresses. Test if the host address matches * or if there is no service, then just the host address values. * @param address1 to compare. * @param address2 to compare. * @return true if same family and equal. */ static bool eq_host(const struct sockaddr *address1, const struct sockaddr *address2); /** * Compare socket addresses. Test if the stored addresses received match. * or if there is no service, then just the host address values. * @param address1 to compare. * @param address2 to compare. * @return true if same family and equal. */ inline static bool eq_from(const struct sockaddr_storage *address1, const struct sockaddr_storage *address2) {return equal((const struct sockaddr *)address1, (const struct sockaddr *)address2);}; /** * Compare socket addresses. Test if the internet addresses received match. * or if there is no service, then just the host address values. * @param address1 to compare. * @param address2 to compare. * @return true if same family and equal. */ inline static bool eq_inet(const struct sockaddr_internet *address1, const struct sockaddr_internet *address2) {return equal((const struct sockaddr *)address1, (const struct sockaddr *)address2);}; /** * See if both addresses are in the same subnet. This is only relevant * to IPV4 and class domain routing. * @param address1 to test. * @param address2 to test. * @return true if in same subnet. */ static bool eq_subnet(const struct sockaddr *address1, const struct sockaddr *address2); /** * Get the socket address of the interface needed to reach a destination * address. * @param address of interface found. * @param destination address. * @return 0 on success, -1 on error. */ static int via(struct sockaddr *address, const struct sockaddr *destination); /** * Get the hostname of a socket address. * @param address to lookup. * @param buffer to save hostname in. * @param size of hostname buffer. * @return buffer if found or NULL if not. */ static char *query(const struct sockaddr *address, char *buffer, socklen_t size); /** * Get the service port of a socket. * @param address of socket to examine. * @return service port number. */ static short service(const struct sockaddr *address); /** * Get the service port of an inet socket. * @param address of internet socket to examine. * @return service port number. */ inline static short service(const struct sockaddr_internet *address) {return service((const struct sockaddr *)address);}; /** * Convert a socket address and service into a hash map index. * @param address to convert. * @param size of map index. * @return key index path. */ static unsigned keyindex(const struct sockaddr *address, unsigned size); /** * Convert a socket host address into a hash map index. * @param address to convert. * @param size of map index. * @return key index path. */ static unsigned keyhost(const struct sockaddr *address, unsigned size); /** * Initialize socket subsystem. */ static void init(void); /** * Initialize with program name. Used by socks, for example. * @param program name. */ static void init(const char *program); /** * Set default socket family preference for query options when the * socket type is otherwise not specified. * @param family to select. */ static void query(int family); /** * Set the default socket behavior for v6-v4 mapping. This also * effects v6 address lookup as to whether v4 remapped addresses * can be used if no v6 address is found. * @param enable true to set mapping. This is default. */ static void v4mapping(bool enable); /** * Return error code of last socket operation, * @return errno style error code. */ static int error(void); /** * Simple function to validate that a given IP address string is a "zero" * address. Such address strings are used for example in SIP to indicate * "hold" by re-inviting peers to a null address. Supports IPV4 and * IPV6 addresses. * @param string address to check. * @return true if zero/null address. */ static bool is_null(const char *string); /** * Simple function to validate that a given IP address string is a numeric * address. This can be used to verify an address is not a "host" name. * Supports IPV4 and IPV6 address strings. * @param string address to check. * @return true if zero/null address. */ static bool is_numeric(const char *string); /** * Get local address to which the socket is bound. This is defined here * because we may re-define the backend linkage for the socks proxy in * the future. * @param socket descriptor to examine. * @param address storage for local address. * @return 0 on success, -1 on failure. */ static int local(socket_t socket, struct sockaddr_storage *address); /** * Get remote address to which the socket is connected. This is defined * here because we may re-define the backend linkage for the socks proxy in * the future. * @param socket descriptor to examine. * @param address storage for remote address. * @return 0 on success, -1 on failure. */ static int remote(socket_t socket, struct sockaddr_storage *address); }; /** * A bound socket used to listen for inbound socket connections. This class * is commonly used for TCP and DCCP listener sockets. * @author David Sugar */ class __EXPORT ListenSocket : protected Socket { public: /** * Create and bind a listener socket. * @param address to bind on or "*" for all. * @param service port to bind listener. * @param backlog size for buffering pending connections. * @param family of socket. * @param type of socket. * @param protocol for socket if not TCPIP. */ ListenSocket(const char *address, const char *service, unsigned backlog = 5, int family = AF_UNSPEC, int type = 0, int protocol = 0); /** * Create a listen socket directly. * @param address to bind on or "*" for all. * @param service port to bind listener. * @param backlog size for buffering pending connections. * @param family of socket. * @param type of socket. * @param protocol for socket if not TCPIP. * @return bound and listened to socket. */ static socket_t create(const char *address, const char *service, unsigned backlog = 5, int family = AF_UNSPEC, int type = 0, int protocol = 0); /** * Accept a socket connection. * @param address to save peer connecting. * @return socket descriptor of connected socket. */ socket_t accept(struct sockaddr_storage *address = NULL) const; /** * Wait for a pending connection. * @param timeout to wait. * @return true when acceptable connection is pending. */ inline bool wait(timeout_t timeout = Timer::inf) const {return Socket::wait(timeout);}; /** * Get the socket descriptor of the listener. * @return socket descriptor. */ inline operator socket_t() const {return so;} /** * Get the socket descriptor of the listener by pointer reference. * @return socket descriptor. */ inline socket_t operator*() const {return so;} /** * Get the socket descriptor of the listener. * @return socket descriptor. */ inline socket_t getsocket(void) const {return so;} inline socket_t handle(void) const {return so;} }; /** * A generic tcp server class. This saves the service id tag so that it * can be propagated. * @author David Sugar */ class __EXPORT TCPServer : public ListenSocket { public: /** * Create and bind a tcp server. This mostly is used to preserve the * service tag for TCP Socket when derived from a server instance. * @param service tag to use. * @param address of interface to bind or "*" for all. * @param backlog size for pending connections. */ TCPServer(const char *address, const char *service, unsigned backlog = 5); }; /** * Helper function for linked_pointer. */ __EXPORT struct addrinfo *_nextaddrinfo(struct addrinfo *addrinfo); /** * Helper function for linked_pointer. */ __EXPORT struct sockaddr *_getaddrinfo(struct addrinfo *addrinfo); /** * Helper function for linked_pointer. */ __EXPORT socket_t _getaddrsock(struct addrinfo *addrinfo); /** * Linked pointer for address lists. This can be used to iterate through * the list of a Socket::address object using the linked_pointer method. * @author David Sugar */ template <> class linked_pointer { private: struct addrinfo *ptr; public: inline linked_pointer(struct addrinfo *list) {ptr = list;} inline linked_pointer() {ptr = NULL;} inline linked_pointer(Socket::address& list) {ptr = list.getList();}; /** * Get the full socket address list by casted reference. * @return addrinfo list we resolved or NULL if none. */ inline operator struct sockaddr *() const {return _getaddrinfo(ptr);}; /** * Return the full socket address list by pointer reference. * @return addrinfo list we resolved or NULL if none. */ inline struct sockaddr *operator*() const {return _getaddrinfo(ptr);}; inline operator struct sockaddr_in *() const {return (struct sockaddr_in *)_getaddrinfo(ptr);}; inline struct sockaddr_in *in(void) const {return (struct sockaddr_in *)_getaddrinfo(ptr);}; #ifdef AF_INET6 inline operator struct sockaddr_in6 *() const {return (struct sockaddr_in6 *)_getaddrinfo(ptr);}; inline struct sockaddr_in6 *in6(void) const {return (struct sockaddr_in6 *)_getaddrinfo(ptr);}; #endif /** * Get socket as expression operator. */ inline socket_t operator()(void) const {return _getaddrsock(ptr);}; /** * Test if the address list is valid. * @return true if we have an address list. */ inline operator bool() const {return ptr != NULL;}; /** * Assign our pointer from an address list. * @param pointer of linked list. */ inline void operator=(struct addrinfo *list) {ptr = list;}; /** * Assign our pointer from an address list. * @param pointer of linked list. */ inline void operator=(Socket::address& list) {ptr = list.getList();}; /** * Assign our pointer from an address list. * @param pointer of linked list. */ inline void set(struct addrinfo *list) {ptr = list;}; /** * Assign our pointer from an address list. * @param pointer of linked list. */ inline void set(Socket::address& list) {ptr = list.getList();}; /** * Return member from typed object our pointer references. * @return evaluated member of object we point to. */ inline struct sockaddr* operator->() const {return _getaddrinfo(ptr);}; /** * Test if we have no address list. * @return true if we have no address list. */ inline bool operator!() const {return ptr == NULL;}; inline void next(void) {ptr = _nextaddrinfo(ptr);}; }; /** * A convenience function to convert a socket address list into an addrinfo. * @param address list object. * @return addrinfo list or NULL if empty. */ inline struct addrinfo *addrinfo(Socket::address& address) {return address.getList();} /** * A convenience function to convert a socket address list into a socket * address. * @param address list object. * @return first socket address in list or NULL if empty. */ inline struct sockaddr *addr(Socket::address& address) {return address.get();} /** * Compare two socket addresses to see if equal. If the port is zero * then this is the same as comparing host address alone. * @param s1 socket address to compare. * @param s2 socket address to compare. * @return true if addresses same. */ inline bool eq(const struct sockaddr *s1, const struct sockaddr *s2) {return Socket::equal(s1, s2);} /** * Compare two stored socket addresses to see if equal. If the port is zero * then this is the same as comparing host address alone. * @param s1 stored socket address to compare. * @param s2 stored socket address to compare. * @return true if addresses same. */ inline bool eq(const struct sockaddr_storage *s1, const struct sockaddr_storage *s2) {return Socket::equal((const struct sockaddr *)s1, (const struct sockaddr *)s2);} /** * Compare two host addresses to see if equal. The port numbers are * ignored. * @param s1 socket address to compare. * @param s2 socket address to compare. * @return true if addresses same. */ inline bool eq_host(const struct sockaddr *s1, const struct sockaddr *s2) {return Socket::eq_host(s1, s2);} inline bool eq_subnet(const struct sockaddr *s1, const struct sockaddr *s2) {return Socket::eq_subnet(s1, s2);} String str(Socket& so, strsize_t size); typedef TCPServer tcpserv_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/counter.h0000644000175000017500000001250712163025062014202 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Support for various automatic counting objects. * This header defines templates for various kinds of automatic counting * and sequencing objects. Templates are used to allow manipulation of * various numerical-like types. * @file ucommon/counter.h */ #ifndef _UCOMMON_COUNTER_H_ #define _UCOMMON_COUNTER_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif NAMESPACE_UCOMMON /** * Automatic integer counting class. This is an automatic counting object * that is used to retrieve a new integer value between 0 and n each time * the object is referenced. When reaching the last n value, the object * restarts at 0, and so is used to retrieve a sequence of values in order. * @author David Sugar */ class __EXPORT counter { private: unsigned value, cycle; public: /** * Initialize integer counter of unknown size. */ counter(); /** * Initialize integer counter for a range of values. * @param limit before recycling to zero. */ counter(unsigned limit); /** * Get the next counter value. * @return next counter value. */ unsigned get(void); /** * Get the range of values before recycling. * @return counter limit. */ inline unsigned range(void) {return cycle;}; /** * Reference next counter value through pointer operation. * @return next counter value. */ inline unsigned operator*() {return get();}; /** * Reference next counter value by casting to integer. * @return next counter value. */ inline operator unsigned() {return get();}; /** * Assign the value of the counter. * @param value to assign. */ void operator=(unsigned value); }; /** * Automatically return a sequence of untyped objects. This is an automatic * counter based class which returns the next pointer in an array of pointers * and restarts the list when reaching the end. This is used to support the * sequence template. * @author David Sugar */ class __EXPORT SeqCounter : protected counter { private: void *item; size_t offset; protected: SeqCounter(void *start, size_t size, unsigned count); void *get(void); void *get(unsigned idx); public: /** * Used to directly assign sequence position in template. * @param inc_offset in sequence to reset sequencing to. */ inline void operator=(unsigned inc_offset) {counter::operator=(inc_offset);}; }; /** * Automatically toggle a bool on each reference. * @author David Sugar */ class __EXPORT toggle { private: bool value; public: inline toggle() {value = false;}; bool get(void); inline bool operator*() {return get();}; inline void operator=(bool v) {value = v;}; inline operator bool() {return get();}; }; /** * A template to return a sequence of objects of a specified type. * This is used to return a different member in a sequence of objects of * a specified type during each reference to the sequencer. * @author David Sugar */ template class sequence : public SeqCounter { protected: inline T *get(unsigned idx) {return static_cast(SeqCounter::get(idx));}; public: /** * Create a template auto-sequence from a list of typed pointers. * @param array of typed values to sequence on reference. * @param size of list of typed values. */ inline sequence(T *array, unsigned size) : SeqCounter(array, sizeof(T), size) {}; /** * Return next typed member of the sequence. * @return next typed member of sequence. */ inline T* get(void) {return static_cast(SeqCounter::get());}; /** * Return next typed member of the sequence by pointer reference. * @return next typed member of sequence. */ inline T& operator*() {return *get();}; /** * Return next typed member of the sequence by casted reference. * @return next typed member of sequence. */ inline operator T&() {return *get();}; /** * Return a specific typed member from the sequence list. * @param offset of member to return. * @return typed value at the specified offset. */ inline T& operator[](unsigned offset) {return *get(offset);}; }; /** * A convenience typecast for integer counters. */ typedef counter counter_t; /** * A convenience typecast for auto-toggled bools. */ typedef toggle toggle_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/generics.h0000644000175000017500000003277712163025062014335 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Generic templates for C++. These are templates that do not depend * on any ucommon classes. They can be used for generic C++ programming. * @file ucommon/generics.h */ #ifndef _UCOMMON_GENERICS_H_ #define _UCOMMON_GENERICS_H_ #ifndef _UCOMMON_CPR_H_ #include #endif #include #include #ifdef NEW_STDLIB #include #endif #if defined(NEW_STDLIB) || defined(OLD_STDLIB) #define THROW(x) throw x #define THROWS(x) throw(x) #define THROWS_ANY throw() #else #define THROW(x) ::abort() #define THROWS(x) #define THROWS_ANY #endif NAMESPACE_UCOMMON /** * Generic smart pointer class. This is the original Common C++ "Pointer" * class with a few additions. * @author David Sugar */ template class pointer { protected: unsigned *counter; T *object; public: inline void release(void) { if(counter && --(*counter)==0) { delete counter; delete object; } object = NULL; counter = NULL; } inline void retain(void) { if(counter) ++*counter; } inline void set(T* ptr) { if(object != ptr) { release(); counter = new unsigned; *counter = 1; object = ptr; } } inline void set(const pointer &ref) { if(object == ref.object) return; if(counter && --(*counter)==0) { delete counter; delete object; } object = ref.object; counter = ref.counter; if(counter) ++(*counter); } inline pointer() { counter = NULL; object = NULL; } inline explicit pointer(T* ptr = NULL) : object(ptr) { if(object) { counter = new unsigned; *counter = 1; } else counter = NULL; } inline pointer(const pointer &ref) { object = ref.object; counter = ref.counter; if(counter) ++(*counter); } inline pointer& operator=(const pointer &ref) { this->set(ref); return *this; } inline pointer& operator=(T *ptr) { this->set(ptr); return *this; } inline ~pointer() {release();} inline T& operator*() const {return *object;}; inline T* operator->() const {return object;}; inline bool operator!() const {return (counter == NULL);}; inline operator bool() const {return counter != NULL;}; }; /** * Generic smart array class. This is the original Common C++ "Pointer" class * with a few additions for arrays. * @author David Sugar */ template class array_pointer { protected: unsigned *counter; T *array; public: inline void release(void) { if(counter && --(*counter)==0) { delete counter; delete[] array; } array = NULL; counter = NULL; } inline void retain(void) { if(counter) ++*counter; } inline void set(T* ptr) { if(array != ptr) { release(); counter = new unsigned; *counter = 1; array = ptr; } } inline void set(const array_pointer &ref) { if(array == ref.array) return; if(counter && --(*counter)==0) { delete counter; delete[] array; } array = ref.array; counter = ref.counter; if(counter) ++(*counter); } inline array_pointer() { counter = NULL; array = NULL; } inline explicit array_pointer(T* ptr = NULL) : array(ptr) { if(array) { counter = new unsigned; *counter = 1; } else counter = NULL; } inline array_pointer(const array_pointer &ref) { array = ref.array; counter = ref.counter; if(counter) ++(*counter); } inline array_pointer& operator=(const array_pointer &ref) { this->set(ref); return *this; } inline array_pointer& operator=(T *ptr) { this->set(ptr); return *this; } inline ~array_pointer() {release();} inline T* operator*() const {return array;}; inline T& operator[](size_t offset) const {return array[offset];}; inline T* operator()(size_t offset) const {return &array[offset];}; inline bool operator!() const {return (counter == NULL);}; inline operator bool() const {return counter != NULL;}; }; /** * Manage temporary object stored on the heap. This is used to create a * object on the heap who's scope is controlled by the scope of a member * function call. Sometimes we have data types and structures which cannot * themselves appear as auto variables. We may also have a limited stack * frame size in a thread context, and yet have a dynamic object that we * only want to exist during the life of the method call. Using temporary * allows any type to be created from the heap but have a lifespan of a * method's stack frame. * @author David Sugar */ template class temporary { protected: T *object; public: /** * Construct a temporary object, create our stack frame reference. */ inline temporary() {object = NULL;}; /** * Disable copy constructor. */ temporary(const temporary&) {::abort();}; /** * Construct an assigned pointer. */ inline temporary(T *ptr) {object = ptr;}; /** * Assign a temporary object. This adds a pointer to an existing * type to the current temporary pointer. If the temporary was * already assigned, then it is deleted. * @param temp object to assign. */ inline T& operator=(T *temp) { if(object) delete object; object = temp; return *this; } /** * Assign a temporary object. This adds a pointer to an existing * type to the current temporary pointer. If the temporary was * already assigned, then it is deleted. * @param temp object to assign. */ inline void set(T *temp) { if(object) delete object; object = temp; } /** * Access heap object through our temporary directly. * @return reference to heap resident object. */ inline T& operator*() const {return *object;}; /** * Access members of our heap object through our temporary. * @return member reference of heap object. */ inline T* operator->() const {return object;}; inline operator bool() const {return object != NULL;}; inline bool operator!() const {return object == NULL;}; inline ~temporary() { if(object) delete object; object = NULL; } }; /** * Manage temporary array stored on the heap. This is used to create an * array on the heap who's scope is controlled by the scope of a member * function call. Sometimes we have data types and structures which cannot * themselves appear as auto variables. We may also have a limited stack * frame size in a thread context, and yet have a dynamic object that we * only want to exist during the life of the method call. Using temporary * allows any type to be created from the heap but have a lifespan of a * method's stack frame. * @author David Sugar */ template class temp_array { protected: T *array; size_t size; public: /** * Construct a temporary object, create our stack frame reference. */ inline temp_array(size_t s) {array = new T[s]; size = s;}; /** * Construct a temporary object with a copy of some initial value. * @param initial object value to use. */ inline temp_array(const T& initial, size_t s) { array = new T[s]; size = s; for(size_t p = 0; p < s; ++p) array[p] = initial; } inline void reset(size_t s) {delete[] array; array = new T[s]; size = s;}; inline void reset(const T& initial, size_t s) { if(array) delete[] array; array = new T[s]; size = s; for(size_t p = 0; p < s; ++p) array[p] = initial; } inline void set(const T& initial) { for(size_t p = 0; p < size; ++p) array[p] = initial; } /** * Disable copy constructor. */ temp_array(const temp_array&) {::abort();}; inline operator bool() const {return array != NULL;}; inline bool operator!() const {return array == NULL;}; inline ~temp_array() { if(array) delete[] array; array = NULL; size = 0; } inline T& operator[](size_t offset) const { crit(offset < size, "array out of bound"); return array[offset]; } inline T* operator()(size_t offset) const { crit(offset < size, "array out of bound"); return &array[offset]; } }; /** * Save and restore global objects in function call stack frames. * @author David Sugar */ template class save_restore { private: T *original; T temp; public: /** * Save object into local copy and keep reference to the original object. * @param object to save. */ inline save_restore(T& object) {original = &object; temp = object;}; /** * Restore original when stack frame is released. */ inline ~save_restore() {*original = temp;}; }; /** * Convenience function to validate object assuming it is castable to bool. * @param object we are testing. * @return true if object valid. */ template inline bool is(T& object) {return object.operator bool();} /** * Convenience function to test pointer object. This solves issues where * some compilers get confused between bool and pointer operators. * @param object we are testing. * @return true if object points to NULL. */ template inline bool isnull(T& object) {return (bool)(object.operator*() == NULL);} /** * Convenience function to test pointer-pointer object. This solves issues * where some compilers get confused between bool and pointer operators. * @param object we are testing. * @return true if object points to NULL. */ template inline bool isnullp(T *object) {return (bool)(object->operator*() == NULL);} /** * Convenience function to duplicate object pointer to heap. * @param object we are duping. * @return heap pointer instance. */ template inline T* dup(const T& object) {return new T(object);} template inline void dupfree(T object) {delete object;} template<> inline char *dup(const char& object) {return strdup(&object);} template<> inline void dupfree(char* object) {::free(object);} /** * Convenience function to reset an existing object. * @param object type to reset. */ template inline void reset_unsafe(T& object) {new((caddr_t)&object) T;} /** * Convenience function to zero an object and restore type info. * @param object to zero in memory. */ template inline void zero_unsafe(T& object) {memset((void *)&object, 0, sizeof(T)); new((caddr_t)&object) T;} /** * Convenience function to copy class. * @param target to copy into. * @param source to copy from. */ template inline void copy_unsafe(T* target, const T* source) {memcpy((void *)target, (void *)source, sizeof(T));} /** * Convenience function to store object pointer into object. * @param target to copy into. * @param source to copy from. */ template inline void store_unsafe(T& target, const T* source) {memcpy((void *)&target, (void *)source, sizeof(T));} /** * Convenience function to swap objects. * @param o1 to swap. * @param o2 to swap. */ template inline void swap(T& o1, T& o2) {cpr_memswap(&o1, &o2, sizeof(T));} /** * Convenience function to return max of two objects. * @param o1 to check. * @param o2 to check. * @return max object. */ template inline T& (max)(T& o1, T& o2) { return o1 > o2 ? o1 : o2; } /** * Convenience function to return min of two objects. * @param o1 to check. * @param o2 to check. * @return min object. */ template inline T& (min)(T& o1, T& o2) { return o1 < o2 ? o1 : o2; } /** * Convenience macro to range restrict values. * @param value to check. * @param low value. * @param high value. * @return adjusted value. */ template inline T& (limit)(T& value, T& low, T& high) { return (value < low) ? low : ((value > high) ? high : value); } END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/cpr.h0000644000175000017500000001436112163025062013307 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Runtime functions. This includes common runtime library functions we * may need portably. * @file ucommon/cpr.h * @author David Sugar */ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_CPR_H_ #define _UCOMMON_CPR_H_ #ifdef _MSWINDOWS_ extern "C" { __EXPORT int cpr_setenv(const char *s, const char *v, int p); inline int setenv(const char *s, const char *v, int overwrite) {return cpr_setenv(s, v, overwrite);} } #endif /** * Function to handle runtime errors. When using the standard C library, * runtime errors are handled by a simple abort. When using the stdc++ * library with stdexcept, then std::runtime_error will be thrown. * @param text of runtime error. */ __EXPORT void cpr_runtime_error(const char *text); /** * Portable memory allocation helper function. Handles out of heap error * as a runtime error. * @param size of memory block to allocate from heap. * @return memory address of allocated heap space. */ extern "C" __EXPORT void *cpr_memalloc(size_t size) __MALLOC; /** * Portable memory placement helper function. This is used to process * "placement" new operators where a new object is constructed over a * pre-allocated area of memory. This handles invalid values through * runtime error. * @param size of object being constructed. * @param address where the object is being placed. * @param known size of the location we are constructing the object in. */ extern "C" __EXPORT void *cpr_memassign(size_t size, caddr_t address, size_t known) __MALLOC; /** * Portable swap code. * @param mem1 to swap. * @param mem2 to swap. * @param size of swap area. */ extern "C" __EXPORT void cpr_memswap(void *mem1, void *mem2, size_t size); #ifndef _UCOMMON_EXTENDED_ /** * Our generic new operator. Uses our heap memory allocator. * @param size of object being constructed. * @return memory allocated from heap. */ inline void *operator new(size_t size) {return cpr_memalloc(size);} /** * Our generic new array operator. Uses our heap memory allocator. * @param size of memory needed for object array. * @return memory allocated from heap. */ inline void *operator new[](size_t size) {return cpr_memalloc(size);} #endif #ifndef _UCOMMON_EXTENDED_ /** * A placement new array operator where we assume the size of memory is good. * We construct the array at a specified place in memory which we assume is * valid for our needs. * @param size of memory needed for object array. * @param address where to place object array. * @return memory we placed object array. */ inline void *operator new[](size_t size, caddr_t address) {return cpr_memassign(size, address, size);} /** * A placement new array operator where we know the allocated size. We * find out how much memory is needed by the new and can prevent arrayed * objects from exceeding the available space we are placing the object. * @param size of memory needed for object array. * @param address where to place object array. * @param known size of location we are placing array. * @return memory we placed object array. */ inline void *operator new[](size_t size, caddr_t address, size_t known) {return cpr_memassign(size, address, known);} #endif /** * Overdraft new to allocate extra memory for object from heap. This is * used for objects that must have a known class size but store extra data * behind the class. The last member might be an unsized or 0 element * array, and the actual size needed from the heap is hence not the size of * the class itself but is known by the routine allocating the object. * @param size of object. * @param extra heap space needed for data. */ inline void *operator new(size_t size, size_t extra) {return cpr_memalloc(size + extra);} /** * A placement new operator where we assume the size of memory is good. * We construct the object at a specified place in memory which we assume is * valid for our needs. * @param size of memory needed for object. * @param address where to place object. * @return memory we placed object. */ inline void *operator new(size_t size, caddr_t address) {return cpr_memassign(size, address, size);} /** * A placement new operator where we know the allocated size. We * find out how much memory is needed by the new and can prevent the object * from exceeding the available space we are placing the object. * @param size of memory needed for object. * @param address where to place object. * @param known size of location we are placing object. * @return memory we placed object. */ inline void *operator new(size_t size, caddr_t address, size_t known) {return cpr_memassign(size, address, known);} #ifndef _UCOMMON_EXTENDED_ /** * Delete an object from the heap. * @param object to delete. */ inline void operator delete(void *object) {free(object);} /** * Delete an array from the heap. All array element destructors are called. * @param array to delete. */ inline void operator delete[](void *array) {free(array);} #ifdef __GNUC__ extern "C" __EXPORT void __cxa_pure_virtual(void); #endif #endif extern "C" { __EXPORT uint16_t lsb_getshort(uint8_t *b); __EXPORT uint32_t lsb_getlong(uint8_t *b); __EXPORT uint16_t msb_getshort(uint8_t *b); __EXPORT uint32_t msb_getlong(uint8_t *b); __EXPORT void lsb_setshort(uint8_t *b, uint16_t v); __EXPORT void lsb_setlong(uint8_t *b, uint32_t v); __EXPORT void msb_setshort(uint8_t *b, uint16_t v); __EXPORT void msb_setlong(uint8_t *b, uint32_t v); } #endif ucommon-6.0.7/inc/ucommon/linked.h0000644000175000017500000016116112163025062013772 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Linked objects, lists, templates, and containers. * Common support for objects that might be organized as single and double * linked lists, rings and queues, and tree oriented data structures. These * generic classes may be used to help form anything from callback * registration systems and indexed memory hashes to xml parsed tree nodes. * @file ucommon/linked.h */ /** * An example of the linked object classes and their use. * @example linked.cpp */ #ifndef _UCOMMON_LINKED_H_ #define _UCOMMON_LINKED_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_OBJECT_H_ #include #endif NAMESPACE_UCOMMON class OrderedObject; /** * Common base class for all objects that can be formed into a linked list. * This base class is used directly for objects that can be formed into a * single linked list. It is also used directly as a type for a pointer to the * start of list of objects that are linked together as a list. * @author David Sugar */ class __EXPORT LinkedObject : public ObjectProtocol { protected: friend class OrderedIndex; friend class LinkedRing; friend class NamedObject; friend class ObjectStack; LinkedObject *Next; /** * Construct base class attached to a chain of objects. * @param root pointer to chain of objects we are part of. */ LinkedObject(LinkedObject **root); /** * Construct base class unattached to anyone. This might be * used to construct intermediary base classes that may form * lists through indexing objects. */ LinkedObject(); public: static const LinkedObject *nil; /**< Marker for end of linked list. */ static const LinkedObject *inv; /**< Marker for invalid list pointer */ virtual ~LinkedObject(); /** * Release list, mark as no longer linked. Inherited from base Object. */ virtual void release(void); /** * Retain by marking as self referenced list. Inherited from base Object. */ virtual void retain(void); /** * Add our object to an existing linked list through a pointer. This * forms a container sorted in lifo order since we become the head * of the list, and the previous head becomes our next. * @param root pointer to list we are adding ourselves to. */ void enlist(LinkedObject **root); /** * Locate and remove ourselves from a list of objects. This searches * the list to locate our object and if found relinks the list around * us. * @param root pointer to list we are removing ourselves from. */ void delist(LinkedObject **root); /** * Search to see if we are a member of a specific list. * @return true if we are member of the list. */ bool is_member(LinkedObject *list) const; /** * Release all objects from a list. * @param root pointer to list we are purging. */ static void purge(LinkedObject *root); /** * Count the number of linked objects in a list. * @param root pointer to list we are counting. */ static unsigned count(const LinkedObject *root); /** * Get member by index. * @return indexed member in linked list. * @param root pointer to list we are indexing. * @param index member to find. */ static LinkedObject *getIndexed(LinkedObject *root, unsigned index); /** * Get next effective object when iterating. * @return next linked object in list. */ inline LinkedObject *getNext(void) const {return Next;}; }; /** * Reusable objects for forming private heaps. Reusable objects are * linked objects that may be allocated in a private heap, and are * returned to a free list when they are no longer needed so they can * be reused without having to be re-allocated. The free list is the * root of a linked object chain. This is used as a base class for those * objects that will be managed through reusable heaps. * @author David Sugar */ class __EXPORT ReusableObject : public LinkedObject { friend class ReusableAllocator; protected: virtual void release(void); public: /** * Get next effective reusable object when iterating. * @return next reusable object in list. */ inline ReusableObject *getNext(void) {return static_cast(LinkedObject::getNext());}; }; /** * An index container for maintaining an ordered list of objects. * This index holds a pointer to the head and tail of an ordered list of * linked objects. Fundamental methods for supporting iterators are * also provided. * @author David Sugar */ class __EXPORT OrderedIndex { protected: friend class OrderedObject; friend class DLinkedObject; friend class LinkedList; friend class NamedObject; OrderedObject *head, *tail; void copy(const OrderedIndex& source); public: /** * Create and initialize an empty index. */ OrderedIndex(); inline OrderedIndex(const OrderedIndex& source) {copy(source);} /** * Destroy index. */ virtual ~OrderedIndex(); /** * Find a specific member in the ordered list. * @param offset to member to find. */ LinkedObject *find(unsigned offset) const; /** * Count of objects this list manages. * @return number of objects in the list. */ unsigned count(void) const; /** * Purge the linked list and then set the index to empty. */ void purge(void); /** * Reset linked list to empty without purging. */ void reset(void); /** * Used to synchronize lists managed by multiple threads. A derived * locking method would be invoked. */ virtual void lock_index(void); /** * Used to synchronize lists managed by multiple threads. A derived * unlocking method would be invoked. */ virtual void unlock_index(void); /** * Return a pointer to the head of the list. This allows the head * pointer to be used like a simple root list pointer for pure * LinkedObject based objects. * @return LinkedIndex style object. */ LinkedObject **index(void) const; /** * Get (pull) object off the list. The start of the list is advanced to * the next object. * @return LinkedObject based object that was head of the list. */ LinkedObject *get(void); /** * Add an object into the ordered index. * @param ordered object to add to the index. */ void add(OrderedObject *ordered); /** * Get an indexed member from the ordered index. * @param index of member to fetch. * @return LinkedObject member of index. */ inline LinkedObject *getIndexed(unsigned index) const {return LinkedObject::getIndexed((LinkedObject*)head, index);}; /** * Return first object in list for iterators. * @return first object in list. */ inline LinkedObject *begin(void) const {return (LinkedObject*)(head);}; /** * Return last object in list for iterators. * @return last object in list. */ inline LinkedObject *end(void) const {return (LinkedObject*)(tail);}; /** * Return head object pointer. * @return head pointer. */ inline LinkedObject *operator*() const {return (LinkedObject*)(head);}; /** * Assign ordered index. * @param object to copy from. */ OrderedIndex& operator=(const OrderedIndex& object) {copy(object); return *this;} /** * Add object to our list. * @param object to add. */ void operator*=(OrderedObject *object); }; /** * A linked object base class for ordered objects. This is used for * objects that must be ordered and listed through the OrderedIndex * class. * @author David Sugar */ class __EXPORT OrderedObject : public LinkedObject { protected: friend class LinkedList; friend class OrderedIndex; friend class DLinkedObject; friend class ObjectQueue; /** * Construct an ordered object aot end of a an index. * @param index we are listed on. */ OrderedObject(OrderedIndex *index); /** * Construct an ordered object unattached. */ OrderedObject(); public: /** * List our ordered object at end of a linked list on an index. * @param index we are listing on. */ void enlistTail(OrderedIndex *index); /** * List our ordered object at start of a linked list on an index. * @param index we are listing on. */ void enlistHead(OrderedIndex *index); /** * List our ordered object in default strategy mode. The default * base class uses enlistTail. * @param index we are listing on. */ virtual void enlist(OrderedIndex *index); /** * Remove our ordered object from an existing index. * @param index we are listed on. */ void delist(OrderedIndex *index); /** * Get next ordered member when iterating. * @return next ordered object. */ inline OrderedObject *getNext(void) const {return static_cast(LinkedObject::getNext());}; }; /** * A double-linked Object, used for certain kinds of lists. * @author David Sugar */ class __EXPORT DLinkedObject : public OrderedObject { public: friend class ObjectQueue; /** * Construct an empty object. */ DLinkedObject(); protected: /** * Remove a cross-linked list from itself. */ void delist(void); private: DLinkedObject *Prev; }; /** * A linked object base class with members found by name. This class is * used to help form named option lists and other forms of name indexed * associative data structures. The id is assumed to be passed from a * dupped or dynamically allocated string. If a constant string is used * then you must not call delete for this object. * * Named objects are either listed on an ordered list or keyed through an * associate hash map table. When using a hash table, the name id string is * used to determine the slot number to use in a list of n sized linked * object lists. Hence, a hash index refers to a specific sized array of * object indexes. * @author David Sugar */ class __EXPORT NamedObject : public OrderedObject { protected: char *Id; /** * Create an empty unnamed cell object. */ NamedObject(); /** * Create a named object and add to hash indexed list. * @param hash map table to list node on. * @param name of the object we are listing. * @param size of hash map table used. */ NamedObject(NamedObject **hash, char *name, unsigned size = 1); /** * Created a named object on an ordered list. This is commonly used * to form attribute lists. * @param index to list object on. * @param name of the object we are listing. */ NamedObject(OrderedIndex *index, char *name); /** * Destroy named object. We do not always destroy named objects, since * we may use them in reusable pools or we may initialize a list that we * keep permanently. If we do invoke delete for something based on * NamedObject, then be aware the object id is assumed to be formed from * a dup'd string which will also be freed unless clearId is overridden. */ ~NamedObject(); /** * The behavior of clearing id's can be overridden if they are not * assigned as strdup's from the heap... */ virtual void clearId(void); public: /** * Add object to hash indexed list. * @param hash map table to list node on. * @param name of the object we are listing. * @param size of hash map table used. */ void add(NamedObject **hash, char *name, unsigned size = 1); /** * Purge a hash indexed table of named objects. * @param hash map table to purge. * @param size of hash map table used. */ static void purge(NamedObject **hash, unsigned size); /** * Convert a hash index into a linear object pointer array. The * object pointer array is created from the heap and must be deleted * when no longer used. * @param hash map table of objects to index. * @param size of hash map table used. * @return array of named object pointers. */ static NamedObject **index(NamedObject **hash, unsigned size); /** * Count the total named objects in a hash table. * @param hash map table of objects to index. * @param size of hash map table used. */ static unsigned count(NamedObject **hash, unsigned size); /** * Find a named object from a simple list. This may also use the * begin() member of an ordered index of named objects. * @param root node of named object list. * @param name of object to find. * @return object pointer or NULL if not found. */ static NamedObject *find(NamedObject *root, const char *name); /** * Remove a named object from a simple list. * @param root node of named object list. * @param name of object to find. * @return object pointer or NULL if not found. */ static NamedObject *remove(NamedObject **root, const char *name); /** * Find a named object through a hash map table. * @param hash map table of objects to search. * @param name of object to find. * @param size of hash map table. * @return object pointer or NULL if not found. */ static NamedObject *map(NamedObject **hash, const char *name, unsigned size); /** * Remove an object from a hash map table. * @param hash map table of object to remove from. * @param name of object to remove. * @param size of hash map table. * @return object that is removed or NULL if not found. */ static NamedObject *remove(NamedObject **hash, const char *name, unsigned size); /** * Iterate through a hash map table. * @param hash map table to iterate. * @param current named object we iterated or NULL to find start of list. * @param size of map table. * @return next named object in hash map or NULL if no more objects. */ static NamedObject *skip(NamedObject **hash, NamedObject *current, unsigned size); /** * Internal function to convert a name to a hash index number. * @param name to convert into index. * @param size of map table. */ static unsigned keyindex(const char *name, unsigned size); /** * Sort an array of named objects in alphabetical order. This would * typically be used to sort a list created and returned by index(). * @param list of named objects to sort. * @param count of objects in the list or 0 to find by NULL pointer. * @return list in sorted order. */ static NamedObject **sort(NamedObject **list, size_t count = 0); /** * Get next effective object when iterating. * @return next linked object in list. */ inline NamedObject *getNext(void) const {return static_cast(LinkedObject::getNext());}; /** * Get the named id string of this object. * @return name id. */ inline char *getId(void) const {return Id;}; /** * Compare the name of our object to see if equal. This is a virtual * so that it can be overridden when using named lists or hash lookups * that must be case insensitive. * @param name to compare our name to. * @return 0 if effectivily equal, used for sorting keys. */ virtual int compare(const char *name) const; /** * Equal function which calls compare. * @param name to compare our name to. * @return true if equal. */ inline bool equal(const char *name) const {return (compare(name) == 0);}; /** * Comparison operator between our name and a string. * @param name to compare with. * @return true if equal. */ inline bool operator==(const char *name) const {return compare(name) == 0;}; /** * Comparison operator between our name and a string. * @param name to compare with. * @return true if not equal. */ inline bool operator!=(const char *name) const {return compare(name) != 0;}; }; /** * The named tree class is used to form a tree oriented list of associated * objects. Typical uses for such data structures might be to form a * parsed XML document, or for forming complex configuration management * systems or for forming system resource management trees. * @author David Sugar */ class __EXPORT NamedTree : public NamedObject { protected: NamedTree *Parent; OrderedIndex Child; /** * Create a stand-alone or root tree node, with an optional name. * @param name for this node. */ NamedTree(char *name = NULL); /** * Create a tree node as a child of an existing node. * @param parent node we are listed under. * @param name of our node. */ NamedTree(NamedTree *parent, char *name); /** * Construct a copy of the tree. * @param source object to copy from. */ NamedTree(const NamedTree& source); /** * Delete node in a tree. If we delete a node, we must delist it from * it's parent. We must also delink any child nodes. This is done by * calling the purge() member. */ virtual ~NamedTree(); /** * Performs object destruction. Note, if we delete a named tree object * the name of our member object is assumed to be a dynamically allocated * string that will also be free'd. */ void purge(void); public: /** * Find a child node of our object with the specified name. This will * also recursivily search all child nodes that have children until * the named node can be found. This seeks a child node that has * children. * @param name to search for. * @return tree object found or NULL. */ NamedTree *find(const char *name) const; /** * Find a subnode by a dot separated list of node names. If one or * more lead dots are used, then the search will go through parent * node levels of our node. The dot separated list could be thought * of as a kind of pathname where dot is used like slash. This implies * that individual nodes can never use names which contain dot's if * the path function will be used. * @param path name string being sought. * @return tree node object found at the path or NULL. */ NamedTree *path(const char *path) const; /** * Find a child leaf node of our object with the specified name. This * will recursively search all our child nodes until it can find a leaf * node containing the specified id but that holds no further children. * @param name of leaf node to search for. * @return tree node object found or NULL. */ NamedTree *leaf(const char *name) const; /** * Find a direct child of our node which matches the specified name. * @param name of child node to find. * @return tree node object of child or NULL. */ NamedTree *getChild(const char *name) const; /** * Find a direct leaf node on our node. A leaf node is a node that has * no children of it's own. This does not perform a recursive search. * @param name of leaf child node to find. * @return tree node object of leaf or NULL. */ NamedTree *getLeaf(const char *name) const; /** * Get first child node in our ordered list of children. This might * be used to iterate child nodes. This may also be used to get * unamed child nodes. * @return first child node or NULL if no children. */ inline NamedTree *getFirst(void) const {return static_cast(Child.begin());}; /** * Get parent node we are listed as a child on. * @return parent node or NULL if none. */ inline NamedTree *getParent(void) const {return Parent;}; /** * Get child by index number. * @param index of child to fetch. * @return indexed child node. */ inline NamedTree *getIndexed(unsigned index) const {return static_cast(Child.getIndexed(index));}; /** * Get the ordered index of our child nodes. * @return ordered index of our children. */ inline OrderedIndex *getIndex(void) const {return const_cast(&Child);}; /** * Test if this node has a name. * @return true if name is set. */ inline operator bool() const {return (Id != NULL);}; /** * Test if this node is unnamed. * @return false if name is set. */ inline bool operator!() const {return (Id == NULL);}; /** * Set or replace the name id of this node. This will free the string * if a name had already been set. * @param name for this node to set. */ void setId(char *name); /** * Remove our node from our parent list. The name is set to NULL to * keep delete from freeing the name string. */ void remove(void); /** * Test if node has children. * @return true if node contains child nodes. */ inline bool is_leaf(void) const {return (Child.begin() == NULL);}; /** * Test if node is root node. * @return true if node is root node. */ inline bool is_root(void) const {return (Parent == NULL);}; /** * Add leaf to a trunk, by order. If NULL, just remove. * @param trunk we add leaf node to. */ void relistTail(NamedTree *trunk); /** * Add leaf to a trunk, by reverse order. If NULL, just remove. * @param trunk we add leaf node to. */ void relistHead(NamedTree *trunk); /** * Default relist is by tail... * @param trunk we add leaf node to, NULL to delist. */ inline void relist(NamedTree *trunk = NULL) {relistTail(trunk);}; }; /** * A double linked list object. This is used as a base class for objects * that will be organized through ordered double linked lists which allow * convenient insertion and deletion of list members anywhere in the list. * @author David Sugar */ class __EXPORT LinkedList : public OrderedObject { protected: friend class ObjectQueue; LinkedList *Prev; OrderedIndex *Root; /** * Construct and add our object to an existing double linked list at end. * @param index of linked list we are listed in. */ LinkedList(OrderedIndex *index); /** * Construct an unlinked object. */ LinkedList(); /** * Delete linked list object. If it is a member of a list of objects, * then the list is reformed around us. */ virtual ~LinkedList(); public: /** * Remove our object from the list it is currently part of. */ void delist(void); /** * Attach our object to the start of a linked list though an ordered index. * If we are already attached to a list we are delisted first. * @param index of linked list we are joining. */ void enlistHead(OrderedIndex *index); /** * Attach our object to the end of a linked list though an ordered index. * If we are already attached to a list we are delisted first. * @param index of linked list we are joining. */ void enlistTail(OrderedIndex *index); /** * Attach our object to a linked list. The default strategy is to add * to tail. * @param index of linked list we are joining. */ void enlist(OrderedIndex *index); /** * Test if we are at the head of a list. * @return true if we are the first node in a list. */ inline bool is_head(void) const {return Root->head == (OrderedObject *)this;}; /** * Test if we are at the end of a list. * @return true if we are the last node in a list. */ inline bool is_tail(void) const {return Root->tail == (OrderedObject *)this;}; /** * Get previous node in the list for reverse iteration. * @return previous node in list. */ inline LinkedList *getPrev(void) const {return Prev;}; /** * Get next node in the list when iterating. * @return next node in list. */ inline LinkedList *getNext(void) const {return static_cast(LinkedObject::getNext());}; /** * Insert object behind our object. * @param object to add to list. */ void insertTail(LinkedList *object); /** * Insert object in front of our object. * @param object to add to list. */ void insertHead(LinkedList *object); /** * Insert object, method in derived object. * @param object to add to list. */ virtual void insert(LinkedList *object); /** * Insert object behind our object. * @param object to add to list. */ inline void operator+=(LinkedList *object) {insertTail(object);}; /** * Insert object in front of our object. * @param object to add to list. */ inline void operator-=(LinkedList *object) {insertHead(object);}; /** * Insert object in list with our object. * @param object to add to list. */ inline void operator*=(LinkedList *object) {insert(object);}; }; /** * A queue of double linked object. This uses the linkedlist class to * form a basic queue of objects. * @author David Sugar */ class __EXPORT ObjectQueue : public OrderedIndex { public: /** * Create an empty object queue. */ ObjectQueue(); /** * Add an object to the end of the queue. * @param object to add. */ void add(DLinkedObject *object); /** * Push an object to the front of the queue. * @param object to push. */ void push(DLinkedObject *object); /** * Pull an object from the front of the queue. * @return object pulled or NULL if empty. */ DLinkedObject *pull(void); /** * Pop an object from the end of the queue. * @return object popped or NULL if empty. */ DLinkedObject *pop(void); }; class __EXPORT ObjectStack { protected: LinkedObject *root; public: /** * Create an empty stack. */ ObjectStack(); /** * Create a stack from an existing list of objects. * @param list of already linked objects. */ ObjectStack(LinkedObject *list); /** * Push an object onto the stack. * @param object to push. */ void push(LinkedObject *object); /** * Pull an object from the stack. * @return object popped from stack or NULL if empty. */ LinkedObject *pull(void); /** * Pop an object from the stack. * @return object popped from stack or NULL if empty. */ inline LinkedObject *pop(void) {return ObjectStack::pull();}; }; /** * A multipath linked list where membership is managed in multiple * lists. * @author David Sugar */ class __EXPORT MultiMap : public ReusableObject { private: typedef struct { const char *key; size_t keysize; MultiMap *next; MultiMap **root; } link_t; unsigned paths; link_t *links; protected: /** * Initialize a multilist object. * @param count of link paths. */ MultiMap(unsigned count); /** * Destroy a multilist object. */ virtual ~MultiMap(); /** * Modifiable interface for key matching. * @param path to check. * @param key to check. * @param size of key to check or 0 if NULL terminated string. * @return true if matches key. */ virtual bool equal(unsigned path, caddr_t key, size_t size) const; public: /** * Enlist on a single linked list. * @param path to attach through. * @param root of list to attach. */ void enlist(unsigned path, MultiMap **root); /** * Enlist binary key on a single map path. * @param path to attach through. * @param index to attach to. * @param key value to use. * @param size of index. * @param keysize of key or 0 if NULL terminated string. */ void enlist(unsigned path, MultiMap **index, caddr_t key, unsigned size, size_t keysize = 0); /** * De-list from a single map path. * @param path to detach from. */ void delist(unsigned path); /** * Get next node from single chain. * @param path to follow. */ MultiMap *next(unsigned path) const; /** * Compute binary key index. * @param key memory to compute. * @param max size of index. * @param size of key or 0 if NULL terminated string. * @return associated hash value. */ static unsigned keyindex(caddr_t key, unsigned max, size_t size = 0); /** * Find a multikey node. * @return node that is found or NULL if none. * @param path of table. * @param index of hash table. * @param key to locate. * @param max size of index. * @param size of key or 0 if NULL terminated string. */ static MultiMap *find(unsigned path, MultiMap **index, caddr_t key, unsigned max, size_t size = 0); }; /** * Template value class to embed data structure into a named list. * This is used to form a class which can be searched by name and that * contains a member value object. Most of the core logic for this * template is found in and derived from the object_value template. * @author David Sugar */ template class named_value : public object_value { public: /** * Construct embedded named object on a linked list. * @param root node or pointer for list. * @param name of our object. */ inline named_value(LinkedObject **root, char *name) {LinkedObject::enlist(root); O::id = name;}; /** * Assign embedded value from related type. * @param typed_value to assign. */ inline void operator=(const T& typed_value) {this->set(typed_value);}; /** * Find embedded object in chain by name. * @param first object in list to search from. * @param name to search for. * @return composite object found by name or NULL if not found. */ inline static named_value find(named_value *first, const char *name) {return static_cast(NamedObject::find(first, name));}; }; /** * Template value class to embed data structure into a linked list. * This is used to form a class which can be linked together using * either an ordered index or simple linked pointer chain and that * contains a member value object. Most of the core logic for this * template is found in and derived from the object_value template. * @author David Sugar */ template class linked_value : public object_value { public: /** * Create embedded value object unlinked. */ inline linked_value() {}; /** * Construct embedded object on a linked list. * @param root node or pointer for list. */ inline linked_value(LinkedObject **root) {LinkedObject::enlist(root);}; /** * Construct embedded object on an ordered list. * @param index pointer for the ordered list. */ inline linked_value(OrderedIndex *index) {O::enlist(index);}; /** * Assign embedded value from related type and link to list. * @param root node or pointer for list. * @param typed_value to assign. */ inline linked_value(LinkedObject **root, const T& typed_value) {LinkedObject::enlist(root); this->set(typed_value);}; /** * Assign embedded value from related type and add to list. * @param index to list our object on. * @param typed_value to assign. */ inline linked_value(OrderedIndex *index, const T& typed_value) {O::enlist(index); this->set(typed_value);}; /** * Assign embedded value from related type. * @param typed_value to assign. */ inline void operator=(const T& typed_value) {this->set(typed_value);}; }; /** * Template for typesafe basic object stack container. The object type, T, * that is contained in the stack must be derived from LinkedObject. * @author David Sugar */ template class objstack : public ObjectStack { public: /** * Create a new object stack. */ inline objstack() : ObjectStack() {} /** * Create an object stack from a list of objects. */ inline objstack(T *list) : ObjectStack(list) {} /** * Push an object onto the object stack. * @param object of specified type to push. */ inline void push(T *object) {ObjectStack::push(object);} /** * Add an object onto the object stack. * @param object of specified type to push. */ inline void add(T *object) {ObjectStack::push(object);} /** * Pull an object from the object stack. * @return object of specified type or NULL if empty. */ inline T *pull(void) {return (T *)ObjectStack::pull();} /** * Pull (pop) an object from the object stack. * @return object of specified type or NULL if empty. */ inline T *pop(void) {return (T *)ObjectStack::pull();} }; /** * Template for typesafe basic object fifo container. The object type, T, * that is contained in the fifo must be derived from OrderedObject or * LinkedObject. * @author David Sugar */ template class objfifo : public OrderedIndex { public: /** * Create a new object stack. */ inline objfifo() : OrderedIndex() {} /** * Push an object onto the object fifo. * @param object of specified type to push. */ inline void push(T *object) {OrderedIndex::add((OrderedObject *)object);} /** * Add an object onto the object fifo. * @param object of specified type to push. */ inline void add(T *object) {OrderedIndex::add((OrderedObject *)object);} /** * Pull an object from the object stack. * @return object of specified type or NULL if empty. */ inline T *pull(void) {return (T *)OrderedIndex::get();} /** * Pull (pop) an object from the object stack. * @return object of specified type or NULL if empty. */ inline T *pop(void) {return (T *)OrderedIndex::get();} }; /** * Template for typesafe basic object queue container. The object type, T, * that is contained in the fifo must be derived from DLinkedObject. * @author David Sugar */ template class objqueue : public ObjectQueue { public: /** * Create a new object stack. */ inline objqueue() : ObjectQueue() {} /** * Push an object to start of queue. * @param object of specified type to push. */ inline void push(T *object) {ObjectQueue::push((DLinkedObject *)object);} /** * Add an object to the end of the object queue. * @param object of specified type to add. */ inline void add(T *object) {ObjectQueue::add((DLinkedObject *)object);} /** * Pull an object from the start of the object queue. * @return object of specified type or NULL if empty. */ inline T *pull(void) {return (T *)ObjectQueue::pull();} /** * Pop an object from the end of the object queue. * @return object of specified type or NULL if empty. */ inline T *pop(void) {return (T *)ObjectQueue::pop();} }; /** * A smart pointer template for iterating linked lists. This class allows * one to access a list of single or double linked objects and iterate * through each member of a list. * @author David Sugar */ template class linked_pointer { private: T *ptr; public: /** * Create a linked pointer and assign to start of a list. * @param pointer to first member of a linked list. */ inline linked_pointer(T *pointer) {ptr = pointer;}; /** * Create a copy of an existing linked pointer. * @param pointer to copy from. */ inline linked_pointer(const linked_pointer &pointer) {ptr = pointer.ptr;}; /** * Create a linked pointer assigned from a raw linked object pointer. * @param pointer to linked object. */ inline linked_pointer(LinkedObject *pointer) {ptr = static_cast(pointer);}; inline linked_pointer(const LinkedObject *pointer) {ptr = static_cast(pointer);}; /** * Create a linked pointer to examine an ordered index. * @param index of linked objects to iterate through. */ inline linked_pointer(OrderedIndex *index) {ptr = static_cast(index->begin());}; /** * Create a linked pointer not attached to a list. */ inline linked_pointer() {ptr = NULL;}; /** * Assign our typed iterative pointer from a matching typed object. * @param pointer to typed object. */ inline void operator=(T *pointer) {ptr = pointer;}; /** * Assign our pointer from another pointer. * @param pointer to assign from. */ inline void operator=(linked_pointer &pointer) {ptr = pointer.ptr;}; /** * Assign our pointer from the start of an ordered index. * @param index to assign pointer from. */ inline void operator=(OrderedIndex *index) {ptr = static_cast(index->begin());}; /** * Assign our pointer from a generic linked object pointer. * @param pointer of linked list. */ inline void operator=(LinkedObject *pointer) {ptr = static_cast(pointer);}; /** * Return member from typed object our pointer references. * @return evaluated member of object we point to. */ inline T* operator->() const {return ptr;}; /** * Return object we currently point to. * @return object linked pointer references. */ inline T* operator*() const {return ptr;}; /** * Return object we point to by casting. * @return object linked pointer references. */ inline operator T*() const {return ptr;}; /** * Move (iterate) pointer to previous member in double linked list. */ inline void prev(void) {ptr = static_cast(ptr->getPrev());}; /** * Move (iterate) pointer to next member in linked list. */ inline void next(void) {ptr = static_cast(ptr->getNext());}; /** * Get the next member in linked list. Do not change who we point to. * @return next member in list or NULL if end of list. */ inline T *getNext(void) const {return static_cast(ptr->getNext());}; /** * Get the previous member in double linked list. Do not change who we * point to. * @return previous member in list or NULL if start of list. */ inline T *getPrev(void) const {return static_cast(ptr->getPrev());}; /** * Move (iterate) pointer to next member in linked list. */ inline void operator++() {ptr = static_cast(ptr->getNext());}; /** * Move (iterate) pointer to previous member in double linked list. */ inline void operator--() {ptr = static_cast(ptr->getPrev());}; /** * Test for next member in linked list. * @return true if there is more members after current one. */ inline bool is_next(void) const {return (ptr->getNext() != NULL);}; /** * Test for previous member in double linked list. * @return true if there is more members before current one. */ inline bool is_prev(void) const {return (ptr->getPrev() != NULL);}; /** * Test if linked pointer is set/we are not at end of list. * @return true if we are not at end of list. */ inline operator bool() const {return (ptr != NULL);}; /** * Test if linked list is empty/we are at end of list. * @return true if we are at end of list. */ inline bool operator!() const {return (ptr == NULL);}; /** * Return pointer to our linked pointer to use as root node of a chain. * @return our object pointer as a root index. */ inline LinkedObject **root(void) const {T **r = &ptr; return (LinkedObject**)r;}; }; /** * Embed data objects into a multipap structured memory database. This * can be used to form multi-key hash nodes. Embedded values can either be * of direct types that are then stored as part of the template object, or * of class types that are data pointers. * @author David Sugar */ template class multimap : public MultiMap { protected: T value; public: /** * Construct a multimap node. */ inline multimap() : MultiMap(P) {}; /** * Destroy a multimap object. */ inline ~multimap() {}; /** * Return the typed value of this node. * @return reference to value of node. */ inline T &get(void) const {return value;}; /** * Return next multimap typed object. * @param path to follow. * @return multimap typed. */ inline multimap *next(unsigned path) {return static_cast(MultiMap::next(path));}; /** * Return typed value of this node by pointer reference. * @return value of node. */ inline T& operator*() const {return value;}; /** * Set the pointer of a pointer based value tree. * @param pointer to set. */ inline void setPointer(const T pointer) {value = pointer;}; /** * Set the value of a data based value tree. * @param reference to value to copy into node. */ inline void set(const T &reference) {value = reference;}; /** * Assign the value of our node. * @param data value to assign. */ inline void operator=(const T& data) {value = data;}; /** * Find multimap key entry. * @param path to search through. * @param index of associated keys. * @param key to search for, binary or NULL terminated string. * @param size of index used. * @param keysize or 0 if NULL terminated string. * @return multipath typed object. */ inline static multimap *find(unsigned path, MultiMap **index, caddr_t key, unsigned size, unsigned keysize = 0) {return static_cast(MultiMap::find(path, index, key, size, keysize));}; }; /** * Embed data objects into a tree structured memory database. This can * be used to form XML document trees or other data structures that * can be organized in trees. The NamedTree class is used to manage * the structure of the tree, and the type specified is embedded as a * data value object which can be manipulated. Name identifiers are * assumed to be dynamically allocated if tree node elements are deletable. * * Embedded values can either be of direct types that are then stored as * part of the template object, or of class types that are data pointers. * The latter might be used for trees that contain data which might be * parsed dynamically from a document and/or saved on a heap. Pointer trees * assume that NULL pointers are for nodes that are empty, and that NULL data * value nodes with children are trunk nodes. Generally data values are then * allocated with a pointer stored in pure leaf nodes. * @author David Sugar */ template class treemap : public NamedTree { protected: T value; public: /** * Construct a typed root node for the tree. The root node may be * named as a stand-alone node or unnamed. * @param name of the node we are creating. */ inline treemap(char *name = NULL) : NamedTree(name) {}; /** * Construct a copy of the treemap object. * @param source of copy for new object. */ inline treemap(const treemap& source) : NamedTree(source) {value = source.value;}; /** * Construct a child node on an existing tree. * @param parent of this node to attach. * @param name of this node. */ inline treemap(treemap *parent, char *name) : NamedTree(parent, name) {}; /** * Construct a child node on an existing tree and assign it's value. * @param parent of this node to attach. * @param name of this node. * @param reference to value to assign to this node. */ inline treemap(treemap *parent, char *name, T& reference) : NamedTree(parent, name) {value = reference;}; /** * Return the typed value of this node. * @return reference to value of node. */ inline const T& get(void) const {return value;}; /** * Return typed value of this node by pointer reference. * @return value of node. */ inline const T& operator*() const {return value;}; /** * Return value from tree element when value is a pointer. * @param node in our typed tree. * @return value of node. */ static inline T getPointer(treemap *node) {return (node == NULL) ? NULL : node->value;}; /** * Test if this node is a leaf node for a tree pointer table. * @return true if value pointer is not NULL and there are no children. */ inline bool is_attribute(void) const {return (!Child.begin() && value != NULL);}; /** * Get the pointer of a pointer based value tree. * @return value pointer of node. */ inline const T getPointer(void) const {return value;}; /** * Get the data value of a data based value tree. * @return data value of node. */ inline const T& getData(void) const {return value;}; /** * Set the pointer of a pointer based value tree. * @param pointer to set. */ inline void setPointer(const T pointer) {value = pointer;}; /** * Set the value of a data based value tree. * @param reference to value to copy into node. */ inline void set(const T& reference) {value = reference;}; /** * Assign the value of our node. * @param data value to assign. */ inline void operator=(const T& data) {value = data;}; /** * Get child member node by index. * @param index of child member. * @return node or NULL if past end. */ inline treemap *getIndexed(unsigned index) const {return static_cast(Child.getIndexed(index));}; /** * Get the typed parent node for our node. * @return parent node or NULL if root of tree. */ inline treemap *getParent(void) const {return static_cast(Parent);}; /** * Get direct typed child node of our node of specified name. This * does not perform a recursive search. * @param name of child node. * @return typed child node pointer or NULL if not found. */ inline treemap *getChild(const char *name) const {return static_cast(NamedTree::getChild(name));}; /** * Find a direct typed leaf node on our node. A leaf node is a node that * has no children of it's own. This does not perform a recursive search. * @param name of leaf child node to find. * @return typed leaf node object of leaf or NULL. */ inline treemap *getLeaf(const char *name) const {return static_cast(NamedTree::getLeaf(name));}; /** * Get the value pointer of a leaf node of a pointer tree. This allows * one to find a leaf node and return it's pointer value in a single * operation. * @param name of leaf node. * @return value of leaf pointer if found and contains value, or NULL. */ inline T getValue(const char *name) const {return getPointer(getLeaf(name));}; /** * Find a subnode from our node by name. This performs a recursive * search. * @param name to search for. * @return typed node that is found or NULL if none is found. */ inline treemap *find(const char *name) const {return static_cast(NamedTree::find(name));}; /** * Find a subnode by pathname. This is the same as the NamedTree * path member function. * @param path name to search for node. * @return typed node that is found at path or NULL. */ inline treemap *path(const char *path) const {return static_cast(NamedTree::path(path));}; /** * Search for a leaf node of our node. This performs a recursive * search. * @param name to search for. * @return typed not that is found or NULL if none is found. */ inline treemap *leaf(const char *name) const {return static_cast(NamedTree::leaf(name));}; /** * Get first child of our node. This is useful for iterating children. * @return first child or NULL. */ inline treemap *getFirst(void) const {return static_cast(NamedTree::getFirst());}; }; /** * A template class for a hash map. This provides a has map index object as * a chain of keyindex selected linked pointers of a specified size. This * is used for the index and size values for NamedObject's which are listed * on a hash map. * @author David Sugar */ template class keymap { private: NamedObject *idx[M]; public: /** * Destroy the hash map by puring the index chains. */ inline ~keymap() {NamedObject::purge(idx, M);}; /** * Retrieve root of index to use in NamedObject constructors. * @return root node of index. */ inline NamedObject **root(void) const {return idx;}; /** * Retrieve key size to use in NamedObject constructors. * @return key size of hash map. */ inline unsigned limit(void) const {return M;}; /** * Find a typed object derived from NamedObject in the hash map by name. * @param name to search for. * @return typed object if found through map or NULL. */ inline T *get(const char *name) const {return static_cast(NamedObject::map(idx, name, M));}; /** * Find a typed object derived from NamedObject in the hash map by name. * @param name to search for. * @return typed object if found through map or NULL. */ inline T& operator[](const char *name) const {return static_cast(NamedObject::map(idx, name, M));}; /** * Add a typed object derived from NamedObject to the hash map by name. * @param name to add. * @param object to add. */ inline void add(const char *name, T& object) {object.NamedObject::add(idx, name, M);}; /** * Add a typed object derived from NamedObject to the hash map by name. * @param name to add. * @param object to add. */ inline void add(const char *name, T *object) {object->NamedObject::add(idx, name, M);}; /** * Remove a typed object derived from NamedObject to the hash map by name. * @param name to remove. * @return object removed if found or NULL. */ inline T *remove(const char *name) {return static_cast(NamedObject::remove(idx, name, M));}; /** * Find first typed object in hash map to iterate. * @return first typed object or NULL if nothing in list. */ inline T *begin(void) const {return static_cast(NamedObject::skip(idx, NULL, M));}; /** * Find next typed object in hash map for iteration. * @param current typed object we are referencing. * @return next iterative object or NULL if past end of map. */ inline T *next(T *current) const {return static_cast(NamedObject::skip(idx, current, M));}; /** * Count the number of typed objects in our hash map. * @return count of typed objects. */ inline unsigned count(void) const {return NamedObject::count(idx, M);}; /** * Convert our hash map into a linear object pointer array. The * object pointer array is created from the heap and must be deleted * when no longer used. * @return array of typed named object pointers. */ inline T **index(void) const {return NamedObject::index(idx, M);}; /** * Convert our hash map into an alphabetically sorted linear object * pointer array. The object pointer array is created from the heap * and must be deleted when no longer used. * @return sorted array of typed named object pointers. */ inline T **sort(void) const {return NamedObject::sort(NamedObject::index(idx, M));}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; }; /** * A template for ordered index of typed name key mapped objects. * This is used to hold an iterable linked list of typed named objects * where we can find objects by their name as well as through iteration. * @author David Sugar */ template class keylist : public OrderedIndex { public: /** * Return a root node pointer to use in NamedObject constructors. * @return pointer to index root. */ inline NamedObject **root(void) {return static_cast(&head);}; /** * Return first item in ordered list. This is commonly used to * iterate the list. * @return first item in list or NULL if empty. */ inline T *begin(void) {return static_cast(head);}; /** * Return last item in ordered list. This is commonly used to determine * end of list iteration. * @return last item in list or NULL if empty. */ inline T *end(void) {return static_cast(tail);}; /** * Create a new typed named object with default constructor. * This creates a new object which can be deleted. * @param name of object to create. * @return typed named object. */ inline T *create(const char *name) {return new T(this, name);}; /** * Iterate next object in list. * @param current object we are referencing. * @return next logical object in linked list or NULL if end. */ inline T *next(LinkedObject *current) {return static_cast(current->getNext());}; /** * Find a specific object by name. * @param name to search for. * @return type named object that matches or NULL if not found. */ inline T *find(const char *name) {return static_cast(NamedObject::find(begin(), name));}; inline T *offset(unsigned offset) {return static_cast(OrderedIndex::find(offset));}; /** * Retrieve a specific object by position in list. * @param offset in list for object we want. * @return type named object or NULL if past end of list. */ inline T& operator[](unsigned offset) {return static_cast(OrderedIndex::find(offset));}; inline T& operator[](const char *name) {return static_cast(NamedObject::find(begin(), name));}; /** * Convert our linked list into a linear object pointer array. The * object pointer array is created from the heap and must be deleted * when no longer used. * @return array of typed named object pointers. */ inline T **index(void) {return static_cast(OrderedIndex::index());}; /** * Convert our linked list into an alphabetically sorted linear object * pointer array. The object pointer array is created from the heap * and must be deleted when no longer used. * @return array of typed named object pointers. */ inline T **sort(void) {return static_cast(NamedObject::sort(index()));}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; }; /** * Convenience typedef for root pointers of single linked lists. */ typedef LinkedObject *LinkedIndex; /** * Convenience type for a stack of linked objects. */ typedef ObjectStack objstack_t; /** * Convenience type for a fifo of linked objects. */ typedef OrderedIndex objfifo_t; /** * Convenience type for a queue of linked objects. */ typedef ObjectQueue objqueue_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/access.h0000644000175000017500000002214012163025062013756 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Locking protocol classes for member function automatic operations. * This header covers ucommon access related classes. These are used to * provide automatic management of locks and synchronization objects through * common virtual base classes which can be used with automatic objects. * These classes are related to "protocols" and are used in conjunction * with smart pointer/referencing classes. The access interface supports * member functions to acquire a lock when entered and automatically * release the lock when the member function returns that are used in * conjunction with special referencing smart pointers. * @file ucommon/access.h */ // we do this twice because of some bizarre issue in just this file that // otherwise breaks doxygen and lists all items outside the namespace... #include #ifndef _UCOMMON_ACCESS_H_ #define _UCOMMON_ACCESS_H_ #ifndef _UCOMMON_CPR_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif NAMESPACE_UCOMMON /** * Common unlock protocol for locking protocol interface classes. * This is to assure _unlock is a common base virtual method. * @author David Sugar */ class __EXPORT UnlockAccess { public: virtual ~UnlockAccess(); protected: virtual void _unlock(void) = 0; }; /** * An exclusive locking protocol interface base. * This is an abstract class to form objects that will operate under an * exclusive lock while being actively referenced by a smart pointer. * @author David Sugar */ class __EXPORT ExclusiveAccess : public UnlockAccess { protected: virtual ~ExclusiveAccess(); virtual void _lock(void) = 0; public: /** * Access interface to exclusive lock the object. */ inline void exclusive_lock(void) {return _lock();} /** * Access interface to release a lock. */ inline void release_exclusive(void) {return _unlock();} }; /** * An exclusive locking access interface base. * This is an abstract class to form objects that will operate under an * exclusive lock while being actively referenced by a smart pointer. * @author David Sugar */ class __EXPORT SharedAccess : protected UnlockAccess { protected: virtual ~SharedAccess(); protected: /** * Access interface to share lock the object. */ virtual void _share(void) = 0; public: /** * Share the lock with other referencers. Many of our shared locking * objects support the ability to switch between shared and exclusive * mode. This derived protocol member allows one to restore the lock * to shared mode after it has been made exclusive. */ virtual void share(void); /** * Convert object to an exclusive lock. Many of our shared locking * objects such as the "conditional lock" support the ability to switch * between shared and exclusive locking modes. This derived protocol * member allows one to temporarily assert exclusive locking when tied * to such methods. */ virtual void exclusive(void); inline void shared_lock(void) {return _share();} inline void release_share(void) {return _unlock();} }; /** * A kind of smart pointer object to support exclusive locking protocol. * This object initiates an exclusive lock for the object being referenced when * it is instantiated, and releases the exclusive lock when it is destroyed. * You would pass the pointer an object that has the Exclusive as a base class. * @author David Sugar */ class __EXPORT exclusive_access { private: ExclusiveAccess *lock; public: /** * Create an instance of an exclusive object reference. * @param object containing Exclusive base class protocol to lock. */ exclusive_access(ExclusiveAccess *object); /** * Destroy reference to exclusively locked object, release lock. */ ~exclusive_access(); /** * Test if the reference holds an active lock. * @return true if is not locking an object. */ inline bool operator!() const {return lock == NULL;}; /** * Test if the reference holds an active lock. * @return true if locking an object. */ inline operator bool() const {return lock != NULL;}; /** * Release a held lock programmatically. This can be used to de-reference * the object being exclusively locked without having to wait for the * destructor to be called when the exclusive_lock falls out of scope. */ void release(void); }; /** * A kind of smart pointer object to support shared locking protocol. * This object initiates a shared lock for the object being referenced when * it is instantiated, and releases the shared lock when it is destroyed. * You would pass the pointer an object that has the Shared as a base class. * @author David Sugar */ class __EXPORT shared_access { private: SharedAccess *lock; int state; bool modify; public: /** * Create an instance of an exclusive object reference. * @param object containing Exclusive base class protocol to lock. */ shared_access(SharedAccess *object); /** * Destroy reference to shared locked object, release lock. */ ~shared_access(); /** * Test if the reference holds an active lock. * @return true if is not locking an object. */ inline bool operator!() const {return lock == NULL;}; /** * Test if the reference holds an active lock. * @return true if locking an object. */ inline operator bool() const {return lock != NULL;}; /** * Release a held lock programmatically. This can be used to de-reference * the object being share locked without having to wait for the * destructor to be called when the shared_lock falls out of scope. */ void release(void); /** * Call exclusive access on referenced objects protocol. */ void exclusive(void); /** * Restore shared access on referenced objects protocol. */ void share(void); }; /** * Convenience function to exclusively lock an object through it's protocol. * @param object to lock. */ inline void lock(ExclusiveAccess& object) {object.exclusive_lock();} /** * Convenience function to unlock an exclusive object through it's protocol. * @param object to unlock. */ inline void unlock(ExclusiveAccess& object) {object.release_exclusive();} /** * Convenience function to access (lock) shared object through it's protocol. * @param object to share lock. */ inline void access(SharedAccess& object) {object.shared_lock();} /** * Convenience function to unlock shared object through it's protocol. * @param object to unlock. */ inline void release(SharedAccess& object) {object.release_share();} /** * Convenience function to exclusive lock shared object through it's protocol. * @param object to exclusive lock. */ inline void exclusive(SharedAccess& object) {object.exclusive();} /** * Convenience function to restore shared locking for object through it's protocol. * @param object to restore shared locking. */ inline void share(SharedAccess& object) {object.share();} /** * Convenience type to use for object referencing an exclusive object. */ typedef exclusive_access exlock_t; /** * Convenience type to use for object referencing a shared object. */ typedef shared_access shlock_t; /** * Convenience function to release a reference to an exclusive lock. * @param reference to object referencing exclusive locked object. */ inline void release(exlock_t &reference) {reference.release();} /** * Convenience function to release a reference to a shared lock. * @param reference to object referencing shared locked object. */ inline void release(shlock_t &reference) {reference.release();} // Special macros to allow member functions of an object with a protocol // to create self locking states while the member functions are called by // placing an exclusive_lock or shared_lock smart object on their stack // frame to reference their self. #define exclusive_object() exlock_t __autolock__ = this #define protected_object() shlock_t __autolock__ = this #define exclusive_locking(x) exlock_t __autolock__ = &x #define protected_locking(x) shlock_t __autolock__ = &x END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/shell.h0000644000175000017500000006226612163025062013641 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Generic shell parsing and application services. * @file ucommon/shell.h */ /** * Example of shell parsing. * @example shell.cpp */ #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _UCOMMON_MEMORY_H_ #include #endif #ifndef _UCOMMON_BUFFER_H_ #include #endif #ifndef _UCOMMON_SHELL_H_ #define _UCOMMON_SHELL_H_ #ifdef _MSWINDOWS_ #define INVALID_PID_VALUE INVALID_HANDLE_VALUE #else #define INVALID_PID_VALUE -1 #endif #ifdef ERR #undef ERR #endif NAMESPACE_UCOMMON /** * A utility class for generic shell operations. This includes utilities * to parse and expand arguments, and to call system shell services. This * also includes a common shell class to parse and process command line * arguments which are managed through a local heap. * @author David Sugar */ class __EXPORT shell : public mempager { private: char **_argv; unsigned _argc; char *_argv0; char *_exedir; LinkedObject *_syms; class __LOCAL args : public OrderedObject { public: char *item; }; class __LOCAL syms : public LinkedObject { public: const char *name; const char *value; }; /** * Collapse argument list. This is used internally to collapse args * that are created in a pool heap when they need to be turned into * an argv style array. */ void collapse(LinkedObject *first); /** * Set argv0. This gets the simple filename of argv[0]. */ void set0(char *argv0); public: /** * Error table index. */ typedef enum {NOARGS = 0, NOARGUMENT, INVARGUMENT, BADOPTION, OPTION_USED, BAD_VALUE, NUMERIC_SET} errmsg_t; /** * Type of error logging we are using. */ typedef enum {NONE = 0, CONSOLE_LOG, USER_LOG, SYSTEM_LOG, SECURITY_LOG} logmode_t; /** * Level of error logging. */ typedef enum {FAIL = 0, ERR, WARN, NOTIFY, INFO, DEBUG0} loglevel_t; /** * Numeric mode of parser. */ typedef enum {NO_NUMERIC, NUMERIC_PLUS, NUMERIC_DASH, NUMERIC_ALL} numeric_t; /** * Path types to retrieve. */ typedef enum { PROGRAM_CONFIG, SERVICE_CONFIG, USER_DEFAULTS, SERVICE_CONTROL, USER_HOME = USER_DEFAULTS + 3, SERVICE_DATA, SYSTEM_TEMP, USER_CACHE, SERVICE_CACHE, USER_DATA, USER_CONFIG, SYSTEM_CFG, SYSTEM_ETC, SYSTEM_VAR, SYSTEM_PREFIX, SYSTEM_SHARE, PROGRAM_PLUGINS, PROGRAM_TEMP} path_t; /** * Log process handler. */ typedef bool (*logproc_t)(loglevel_t level, const char *text); /** * Main handler. */ typedef cpr_service_t mainproc_t; /** * Exit handler. */ typedef void (*exitproc_t)(void); #ifdef _MSWINDOWS_ typedef HANDLE pid_t; #else /** * Standard type of process id for shell class. */ typedef int pid_t; #endif /** * This can be used to get internationalized error messages. The internal * text for shell parser errors are passed through here. * @param id of error message to use. * @return published text of error message. */ static const char *errmsg(errmsg_t id); /** * This is used to set internationalized error messages for the shell * parser. * @param id of message to set. * @param text for error message. */ static void errmsg(errmsg_t id, const char *text); /** * A class to redefine error messages. This can be used as a statically * initialized object to remap error messages for easier * internationalization. * @author David Sugar */ class __EXPORT errormap { public: inline errormap(errmsg_t id, const char *text) {shell::errmsg(id, text);}; }; /** * A base class used to create parsable shell options. The virtual * is invoked when the shell option is detected. Both short and long * forms of argument parsing are supported. An instance of a derived * class is created to perform the argument parsing. * @author David Sugar */ class __EXPORT Option : public LinkedObject { public: char short_option; const char *long_option; const char *uses_option; const char *help_string; bool trigger_option; /** * Construct a shell parser option. * @param short_option for single character code. * @param long_option for extended string. * @param value_type if -x value or -long=yyy. * @param help string, future use. */ Option(char short_option = 0, const char *long_option = NULL, const char *value_type = NULL, const char *help = NULL); virtual ~Option(); static LinkedObject *first(void); /** * Disable a option. Might happen if argv0 name suggests an * option is no longer actively needed. */ void disable(void); /** * Used to send option into derived receiver. * @param value option that was received. * @return NULL or error string to use. */ virtual const char *assign(const char *value) = 0; static void reset(void); }; /** * Flag option for shell parsing. This offers a quick-use class * to parse a shell flag, along with a counter for how many times * the flag was selected. The counter might be used for -vvvv style * verbose options, for example. * @author David Sugar */ class __EXPORT flagopt : public Option { private: unsigned counter; bool single; virtual const char *assign(const char *value); public: flagopt(char short_option, const char *long_option = NULL, const char *help = NULL, bool single_use = true); inline operator bool() {return counter > 0;}; inline bool operator!() {return counter == 0;}; inline operator unsigned() {return counter;}; inline unsigned operator*() {return counter;}; inline void set(unsigned value = 1) {counter = value;}; }; /** * Grouping option. This is used to create a grouping entry in * the shell::help() listing. * @author David Sugar */ class __EXPORT groupopt : public Option { private: virtual const char *assign(const char *value); public: groupopt(const char *help); }; /** * Text option for shell parsing. This offers a quick-use class * to parse a shell flag, along with a numeric text that may be * saved and a use counter, as multiple invocations is an error. * @author David Sugar */ class __EXPORT stringopt : public Option { private: bool used; protected: const char *text; virtual const char *assign(const char *value); public: stringopt(char short_option, const char *long_option = NULL, const char *help = NULL, const char *type = "text", const char *def_text = NULL); inline void set(const char *string) {text = string;}; inline operator bool() {return used;}; inline bool operator!() {return !used;}; inline operator const char *() {return text;}; inline const char *operator*() {return text;}; }; /** * Character option for shell parsing. This offers a quick-use class * to parse a shell flag, along with a character code that may be * saved. Multiple invocations is an error. * @author David Sugar */ class __EXPORT charopt : public Option { private: bool used; protected: char code; virtual const char *assign(const char *value); public: charopt(char short_option, const char *long_option = NULL, const char *help = NULL, const char *type = "char", char default_code = ' '); inline void set(char value) {code = value;}; inline operator bool() {return used;}; inline bool operator!() {return !used;}; inline operator char() {return code;}; inline char operator*() {return code;}; }; /** * Numeric option for shell parsing. This offers a quick-use class * to parse a shell flag, along with a numeric value that may be * saved and a use counter, as multiple invocations is an error. * @author David Sugar */ class __EXPORT numericopt : public Option { private: bool used; protected: long number; virtual const char *assign(const char *value); public: numericopt(char short_option, const char *long_option = NULL, const char *help = NULL, const char *type = "numeric", long def_value = 0); inline void set(long value) {number = value;}; inline operator bool() {return used;}; inline bool operator!() {return !used;}; inline operator long() {return number;}; inline long operator*() {return number;}; }; /** * Counter option for shell parsing. This offers a quick-use class * to parse a shell flag, along with a numeric value that may be * saved and a use counter, as multiple invocations is an error. Unlike * numeric options, the short mode flag is a trigger option, and each * use of the short flag is considered a counter increment. * @author David Sugar */ class __EXPORT counteropt : public Option { private: bool used; protected: long number; virtual const char *assign(const char *value); public: counteropt(char short_option, const char *long_option = NULL, const char *help = NULL, const char *type = "numeric", long def_value = 0); inline void set(long value) {number = value;}; inline operator bool() {return used;}; inline bool operator!() {return !used;}; inline operator long() {return number;}; inline long operator*() {return number;}; }; /** * Construct a shell argument list by parsing a simple command string. * This separates a string into a list of command line arguments which * can be used with exec functions. * @param string to parse. * @param pagesize for local heap. */ shell(const char *string, size_t pagesize = 0); /** * Construct a shell argument list from existing arguments. This * copies and on some platforms expands the argument list originally * passed to main. * @param argc from main. * @param argv from main. * @param pagesize for local heap. */ shell(int argc, char **argv, size_t pagesize = 0); /** * Construct an empty shell parser argument list. * @param pagesize for local heap. */ shell(size_t pagesize = 0); static void setNumeric(numeric_t); static long getNumeric(void); /** * Display shell options. */ static void help(void); /** * A shell system call. This uses the native system shell to invoke the * command. * @param command string.. * @param env array to optionally use. * @return error code of child process. */ static int system(const char *command, const char **env = NULL); /** * A shell system call that can be issued using a formatted string. This * uses the native system shell to invoke the command. * @param format of/command string. * @return error code of child process. */ static int systemf(const char *format, ...) __PRINTF(1,2); /** * Set relative prefix. Used for OS/X relocatable applications. * @param argv0 path of executable. */ static void relocate(const char *argv0); /** * Get a system path. This is used to get directories for application * specific data stores and default paths for config keys. * @param id of path to return. * @return path string or emptry string if not supported. */ static String path(path_t id); /** * Get the system login id. * @return login id. */ static String userid(void); /** * Get a merged path. If the path requested is a full path, then * the prefix is ignored. * @param id of prefix. * @param directory path to merge with prefix. */ static String path(path_t id, const char *directory); /** * Join a prefix with a path. * @param prefix to merge with. * @param directory or file path to merge. */ static String path(String& prefix, const char *directory); /** * Bind application to text domain for internationalization. This * is useful if the argv0 argument can vary because of a symlinked * executable. This is the name of the .po/.mo message files for * your application. If bind is not called before shell processing, * then the argv0 is used as the bind name. Bind can be called * multiple times to change the default message catalog name of the * application, and this usage may be needed for plugins, though it's * generally recommended to use only once, and at the start of main(). * @param name of text domain for the application. */ static void bind(const char *name); /** * Rebind is used to change the text domain. This may be needed in * applications which have separately built plugins that have thier * own message catalogs. Normally the plugin would call bind itself * at initialization, and then use rebind to select either the * application's domain, or the plugins. On systems without * internationalization, this has no effect. * @param name of text domain of plugin or NULL to restore application. */ static void rebind(const char *name = NULL); /** * Parse a string as a series of arguments for use in exec calls. * @param string to parse. * @return argument array. */ char **parse(const char *string); /** * Parse the command line arguments using the option table. File * arguments will be expanded for wildcards on some platforms. * The argv will be set to the first file argument after all options * are parsed. * @param argc from main. * @param argv from main. */ void parse(int argc, char **argv); /** * Get an environment variable. This creates a local copy of the * variable in pager memory. * @param name of symbol. * @param value of symbol if not found. * @return value of symbol. */ const char *env(const char *name, const char *value = NULL); inline const char *getenv(const char *name, const char *value = NULL) {return env(name, value);} /** * Get a local symbol. This uses getenv if no local symbol is found. * @param name of symbol. * @param value of symbol if not found. * @return value of symbol. */ const char *get(const char *name, const char *value = NULL); inline const char *getsym(const char *name, const char *value = NULL) {return get(name, value);} /** * Set a local symbol. * @param name of symbol to set. * @param value of symbol to set. */ void set(const char *name, const char *value); inline void setsym(const char *name, const char *value) {return set(name, value);} /** * Test if symbol exists. * @param name of symbol. * @return true if found. */ bool is_sym(const char *name); /** * Parse and extract the argv0 filename alone. * @param argv from main. * @return argv0 simple path name. */ char *getargv0(char **argv); /** * Get the argument list by parsing options, and return the remaining * file arguments. This is used by parse, and can be fed by main by * posting ++argv. * @param argv of first option. * @return argv of non-option file list. */ char **getargv(char **argv); /** * Execute front-end like gdb based on stripped first argument. * @param argv0 of our executable. * @param argv to pass to child. * @param list of arguments to execute in front of argv. */ void restart(char *argv0, char **argv, char **list); /** * Get program name (argv0). */ inline const char *argv0() const {return _argv0;} /** * Get the exec directory. */ inline const char *execdir() const {return _exedir;} /** * Print error message and continue. * @param format string to use. */ static void error(const char *format, ...) __PRINTF(1, 2); /** * Print error message and exit. Ignored if exitcode == 0. * @param exitcode to return to parent process. * @param format string to use. */ static void errexit(int exitcode, const char *format = NULL, ...) __PRINTF(2, 3); /** * Convert condition to exit code if true. * @param test condition. * @param exitcode to use if true. */ static inline int condition(bool test, int exitcode) { return (test) ? exitcode : 0;}; /** * Print a debug message by debug level. * @param level of debug message. * @param format string to use. */ static void debug(unsigned level, const char *format, ...) __PRINTF(2, 3); /** * Print generic error message at specific error level. * @param level of error condition. * @param format string to use. */ static void log(loglevel_t level, const char *format, ...) __PRINTF(2, 3); /** * Print security error message at specific error level. * @param level of error condition. * @param format string to use. */ static void security(loglevel_t level, const char *format, ...) __PRINTF(2, 3); /** * Set logging level and state. * @param name of logging entity. * @param level of error conditions to log. * @param mode of logging. * @param handler for log messages. */ static void log(const char *name, loglevel_t level = ERR, logmode_t mode = USER_LOG, logproc_t handler = (logproc_t)NULL); /** * Print to standard output. * @param format string to use. */ static size_t printf(const char *format, ...) __PRINTF(1, 2); static size_t readln(char *address, size_t size); static size_t writes(const char *string); static size_t read(String& string); inline static size_t write(String& string) {return writes(string.c_str());}; /** * Get saved internal argc count for items. This may be items that * remain after shell expansion and options have been parsed. * @return count of remaining arguments. */ inline unsigned argc(void) const {return _argc;}; /** * Get saved internal argv count for items in this shell object. This * may be filename items only that remain after shell expansion and * options that have been parsed. * @return list of remaining arguments. */ inline char **argv(void) const {return _argv;}; /** * Return parser argv element. * @param offset into array. * @return argument string. */ inline const char *operator[](unsigned offset) {return _argv[offset];}; static void exiting(exitproc_t); /** * Detach current process to daemon for service entry. */ void detach(mainproc_t mainentry = (mainproc_t)NULL); /** * Make current process restartable. */ void restart(void); /** * Spawn a child process. This creates a new child process. If * the executable path is a pure filename, then the $PATH will be * used to find it. The argv array may be created from a string * with the shell string parser. * @param path to executable. * @param argv list of command arguments for the child process. * @param env of child process can be explicitly set. * @param stdio handles for stdin, stdout, and stderr. * @return process id of child or INVALID_PID_VALUE if fails. */ static shell::pid_t spawn(const char *path, char **argv, char **env = NULL, fd_t *stdio = NULL); /** * Set priority level and enable priority scheduler. This activates the * realtime priority scheduler when a priority > 0 is requested for the * process, assuming scheduler support exists and the process is * sufficiently privileged. Negative priorities are essentially the * same as nice. * @param pri level for process. */ static void priority(int pri = 1); /** * Create a detached process. This creates a new child process that * is completely detached from the current process. * @param path to executable. * @param argv list of command arguments for the child process. * @param env of child process can be explicitly set. * @param stdio handles for stdin, stdout, and stderr. * @return 0 if success, -1 on error. */ static int detach(const char *path, char **argv, char **env = NULL, fd_t *stdio = NULL); /** * Detach and release from parent process with exit code. * @param exit_code to send to parent process. */ static void release(int exit_code = 0); /** * Wait for a child process to terminate. This operation blocks. * @param pid of process to wait for. * @return exit code of process, -1 if fails or pid is invalid. */ static int wait(shell::pid_t pid); /** * Cancel a child process. * @param pid of child process to cancel. * @return exit code of process, -1 if fails or pid is invalid. */ static int cancel(shell::pid_t pid); /** * Return argc count. * @return argc count. */ inline unsigned operator()(void) {return _argc;}; /** * Text translation and localization. This function does nothing but * return the original string if no internationalization support is * available. If internationalization support exists, then it may * return a substituted translation based on the current locale. This * offers a single function that can be safely used either when * internationalization support is present, or it is absent, eliminating * the need for the application to be coded differently based on * awareness of support. * @param string to translate. * @return translation if found or original text. */ static const char *text(const char *string); /** * Plural text translation and localization. This does nothing but * return single or plural forms if no internationalization is * enabled. Else it uses ngettext(). * @param singular string to translate. * @param plural string to translate. * @param count of objects. * @return string to use. */ static const char *texts(const char *singular, const char *plural, unsigned long count); /** * Get argc count for an existing array. * @param argv to count items in. * @return argc count of array. */ static unsigned count(char **argv); #ifdef _MSWINDOWS_ static inline fd_t input(void) {return GetStdHandle(STD_INPUT_HANDLE);}; static inline fd_t output(void) {return GetStdHandle(STD_OUTPUT_HANDLE);}; static inline fd_t error(void) {return GetStdHandle(STD_ERROR_HANDLE);}; #else static inline fd_t input(void) {return 0;}; static inline fd_t output(void) {return 1;}; static inline fd_t error(void) {return 2;}; #endif static int inkey(const char *prompt = NULL); static char *getpass(const char *prompt, char *buffer, size_t size); static char *getline(const char *prompt, char *buffer, size_t size); }; /** * Convenience type to manage and pass shell objects. */ typedef shell shell_t; /** * Abusive compilers... */ #undef _TEXT #undef _STR #define _STR(x) (const char *)(x) /** * Invoke translation lookup if available. This can also be used to * mark text constants that need to be translated. It should not be * used with pointer variables, which should instead call shell::text * directly. The primary purpose is to allow extraction of text to * be internationalized with xgettext "--keyword=_TEXT:1". */ inline const char *_TEXT(const char *s) {return shell::text(s);} END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/object.h0000644000175000017500000003376712163025062014004 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * A common object base class with auto-pointer support. * A common object class is used which may be referenced counted and * associated with a smart auto-pointer class. A lot of the things * found here were inspired by working with Objective-C. Many of the * classes are designed to offer automatic heap management through * smart pointers and temporary objects controlled through the scope of * the stack frame of method calls. * @file ucommon/object.h */ #ifndef _UCOMMON_OBJECT_H_ #define _UCOMMON_OBJECT_H_ #ifndef _UCOMMON_CPR_H_ #include #endif #ifndef _UCOMMON_GENERICS_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #include NAMESPACE_UCOMMON /** * A base class for reference counted objects. Reference counted objects * keep track of how many objects refer to them and fall out of scope when * they are no longer being referred to. This can be used to achieve * automatic heap management when used in conjunction with smart pointers. * @author David Sugar */ class __EXPORT CountedObject : public ObjectProtocol { private: volatile unsigned count; protected: /** * Construct a counted object, mark initially as unreferenced. */ CountedObject(); /** * Construct a copy of a counted object. Our instance is not a * reference to the original object but a duplicate, so we do not * retain the original and we do reset our count to mark as * initially unreferenced. */ CountedObject(const ObjectProtocol &ref); /** * Dealloc object no longer referenced. The dealloc routine would commonly * be used for a self delete to return the object back to a heap when * it is no longer referenced. */ virtual void dealloc(void); /** * Force reset of count. */ inline void reset(void) {count = 0;} public: /** * Test if the object has copied references. This means that more than * one object has a reference to our object. * @return true if referenced by more than one object. */ inline bool is_copied(void) {return count > 1;}; /** * Test if the object has been referenced (retained) by anyone yet. * @return true if retained. */ inline bool is_retained(void) {return count > 0;}; /** * Return the number of active references (retentions) to our object. * @return number of references to our object. */ inline unsigned copied(void) {return count;}; /** * Increase reference count when retained. */ void retain(void); /** * Decrease reference count when released. If no longer retained, then * the object is dealloc'd. */ void release(void); }; /** * A general purpose smart pointer helper class. This is particularly * useful in conjunction with reference counted objects which can be * managed and automatically removed from the heap when they are no longer * being referenced by a smart pointer. The smart pointer itself would * normally be constructed and initialized as an auto variable in a method * call, and will dereference the object when the pointer falls out of scope. * This is actually a helper class for the typed pointer template. * @author David Sugar */ class __EXPORT auto_object { protected: ObjectProtocol *object; auto_object(); public: /** * Construct an auto-pointer referencing an existing object. * @param object we point to. */ auto_object(ObjectProtocol *object); /** * Construct an auto-pointer as a copy of another pointer. The * retention of the object being pointed to will be increased. * @param pointer we are a copy of. */ auto_object(const auto_object &pointer); /** * Delete auto pointer. When it falls out of scope, the retention * of the object it references is reduced. If it falls to zero in * a reference counted object, then the object is auto-deleted. */ ~auto_object(); /** * Manually release the pointer. This reduces the retention level * of the object and resets the pointer to point to nobody. */ void release(void); /** * Test if the pointer is not set. * @return true if the pointer is not referencing anything. */ bool operator!() const; /** * Test if the pointer is referencing an object. * @return true if the pointer is currently referencing an object. */ operator bool() const; /** * test if the object being referenced is the same as the object we specify. * @param object we compare to. * @return true if this is the object our pointer references. */ bool operator==(ObjectProtocol *object) const; /** * test if the object being referenced is not the same as the object we specify. * @param object we compare to. * @return true if this is not the object our pointer references. */ bool operator!=(ObjectProtocol *object) const; /** * Set our pointer to a specific object. If the pointer currently * references another object, that object is released. The pointer * references our new object and that new object is retained. * @param object to assign to. */ void operator=(ObjectProtocol *object); }; /** * A sparse array of managed objects. This might be used as a simple * array class for reference counted objects. This class assumes that * objects in the array exist when assigned, and that gaps in the array * are positions that do not reference any object. Objects are automatically * created (create on access/modify when an array position is referenced * for the first time. This is an abstract class because it is a type * factory for objects who's derived class form constructor is not known * in advance and is a helper class for the sarray template. * @author David Sugar */ class __EXPORT SparseObjects { private: ObjectProtocol **vector; unsigned max; protected: /** * Object factory for creating members of the spare array when they * are initially requested. * @return new object. */ virtual ObjectProtocol *create(void) = 0; /** * Purge the array by deleting all created objects. */ void purge(void); virtual ObjectProtocol *invalid(void) const; /** * Get (reference) an object at a specified offset in the array. * @param offset in array. * @return new or existing object. */ ObjectProtocol *get(unsigned offset); /** * Create a sparse array of known size. No member objects are * created until they are referenced. * @param size of array. */ SparseObjects(unsigned size); /** * Destroy sparse array and delete all generated objects. */ virtual ~SparseObjects(); public: /** * Get count of array elements. * @return array elements. */ unsigned count(void); }; /** * Generate a typed sparse managed object array. Members in the array * are created when they are first referenced. The types for objects * that are generated by sarray must have Object as a base class. Managed * sparse arrays differ from standard arrays in that the member elements * are not allocated from the heap when the array is created, but rather * as they are needed. * @author David Sugar */ template class sarray : public SparseObjects { public: /** * Generate a sparse typed array of specified size. * @param size of array to create. */ inline sarray(unsigned size) : SparseObjects(size) {}; /** * Get typed member of array. If the object does not exist, it is * created. * @param offset in array for object. * @return pointer to typed object. */ inline T *get(unsigned offset) {return static_cast(SparseObjects::get(offset));} /** * Array operation to access member object. If the object does not * exist, it is created. * @param offset in array for object. * @return pointer to typed object. */ inline T& operator[](unsigned offset) {return get(offset);}; inline const T* at(unsigned offset) {return static_cast(SparseObjects::get(offset));} private: __LOCAL ObjectProtocol *create(void) {return new T;}; }; /** * Template for embedding a data structure into a reference counted object. * This is a convenient means to create reference counted heap managed data * structure. This template can be used for embedding data into other kinds * of managed object classes in addition to reference counting. For example, * it can be used to embed a data structure into a linked list, as shown in * the linked_value template. * @author David Sugar */ template class object_value : public O { protected: /** * Assign our value from a typed data object. This is a helper method. * @param object to assign our value from. */ inline void set(const T& object) {value = object;}; public: T value; /**< Embedded data value */ /** * Construct composite value object. */ inline object_value() : O() {}; /** * Construct composite value object and assign from existing data value. * @param existing typed value to assign. */ inline object_value(T& existing) : O() {value = existing;}; /** * Pointer reference to embedded data value. * @return embedded value. */ inline T& operator*() {return value;}; /** * Assign embedded data value. * @param data value to assign. */ inline void operator=(const T& data) {value = data;}; /** * Retrieve data value by casting reference. * @return embedded value. */ inline operator T&() {return value;}; inline T& operator()() {return value;}; /** * Set data value by expression reference. * @param data value to assign. */ inline void operator()(T& data) {value = data;}; }; /** * Typed smart pointer class. This is used to manage references to * a specific typed object on the heap that is derived from the base Object * class. This is most commonly used to manage references to reference * counted heap objects so their heap usage can be auto-managed while there * is active references to such objects. Pointers are usually created on * the stack frame and used to reference an object during the life of a * member function. They can be created in other objects that live on the * heap and can be used to maintain active references so long as the object * they are contained in remains in scope as well. * @author David Sugar */ template class object_pointer : public P { public: /** * Create a pointer with no reference. */ inline object_pointer() : P() {}; /** * Create a pointer with a reference to a heap object. * @param object we are referencing. */ inline object_pointer(T* object) : P(object) {}; /** * Reference object we are pointing to through pointer indirection. * @return pointer to object we are pointing to. */ inline T* operator*() const {return static_cast(P::object);}; /** * Reference object we are pointing to through function reference. * @return object we are pointing to. */ inline T& operator()() const {return *(static_cast(P::object));}; /** * Reference member of object we are pointing to. * @return reference to member of pointed object. */ inline T* operator->() const {return static_cast(P::object);}; /** * Get pointer to object. * @return pointer or NULL if we are not referencing an object. */ inline T* get(void) const {return static_cast(P::object);}; /** * Iterate our pointer if we reference an array on the heap. * @return next object in array. */ inline T* operator++() {P::operator++(); return get();}; /** * Iterate our pointer if we reference an array on the heap. * @return previous object in array. */ inline void operator--() {P::operator--(); return get();}; /** * Perform assignment operator to existing object. * @param typed object to assign. */ inline void operator=(T *typed) {P::operator=((ObjectProtocol *)typed);}; /** * See if pointer is set. */ inline operator bool() {return P::object != NULL;}; /** * See if pointer is not set. */ inline bool operator!() {return P::object == NULL;}; }; /** * Convenience function to access object retention. * @param object we are retaining. */ inline void retain(ObjectProtocol *object) {object->retain();} /** * Convenience function to access object release. * @param object we are releasing. */ inline void release(ObjectProtocol *object) {object->release();} /** * Convenience function to access object copy. * @param object we are copying. */ inline ObjectProtocol *copy(ObjectProtocol *object) {return object->copy();} END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/Makefile.am0000644000175000017500000000171212163025062014402 00000000000000# Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = $(LT_VERSION) -release $(LT_RELEASE) AM_CXXFLAGS = $(UCOMMON_FLAGS) pkgincludedir = $(includedir)/ucommon pkginclude_HEADERS = cpr.h object.h linked.h string.h counter.h vector.h \ bitmap.h timers.h socket.h access.h export.h thread.h mapped.h \ keydata.h memory.h platform.h fsys.h xml.h ucommon.h stream.h \ persist.h shell.h protocols.h atomic.h buffer.h numbers.h file.h \ datetime.h unicode.h secure.h generics.h containers.h stl.h ucommon-6.0.7/inc/ucommon/keydata.h0000644000175000017500000001566712163025062014157 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Parsing of config files that have keyword/value pairs. This includes * supporting classes to extract basic config data from files that are stored * as []'s, and uses several supporting classes. * @file ucommon/keydata.h */ /** * Some exercise of keydata routines. * @example keydata.cpp */ #ifndef _UCOMMON_KEYDATA_H_ #define _UCOMMON_KEYDATA_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_LINKED_H_ #include #endif #ifndef _UCOMMON_MEMORY_H_ #include #endif NAMESPACE_UCOMMON class keyfile; /** * Data keys parsed from a keyfile. This is a specific [] section from a * fully loaded keyfile, and offers common means to access data members. * This is related to the original GNU Common C++ keydata object, although * it is formed in a keyfile class which is loaded from a config file all * at once. * @author David Sugar */ class __EXPORT keydata : public OrderedObject { private: friend class keyfile; OrderedIndex index; keydata(keyfile *file); keydata(keyfile *file, const char *id); const char *name; keyfile *root; public: /** * A key value set is used for iterative access. Otherwise this class * is normally not used as we usually request the keys directly. * @author David Sugar */ class __LOCAL keyvalue : public OrderedObject { private: friend class keydata; friend class keyfile; keyvalue(keyfile *allocator, keydata *section, const char *key, const char *data); public: const char *id; const char *value; }; friend class keyvalue; /** * Lookup a key value by it's id. * @param id to look for. * @return value string or NULL if not found. */ const char *get(const char *id) const; /** * Lookup a key value by it's id. * @param id to look for. * @return value string or NULL if not found. */ inline const char *operator()(const char *id) const {return get(id);}; /** * Set a keyword and value in the keydata structure. If the keyword * already exists, it is replaced. Removed items still use pager * allocated memory. * @param id to set. * @param value for the id. */ void set(const char *id, const char *value); /** * Remove a keyword id from the keydata structure. Removed items * still use pager allocated memory. * @param id to remove. */ void clear(const char *id); /** * Get the name of this section. Useful in iterative examinations. * @return name of keydata section. */ inline const char *get(void) const {return name;}; /** * Get first value object, for iterative examinations. * @return first key value in chain. */ inline keyvalue *begin(void) const {return (keyvalue *)index.begin();}; /** * Get last value object, for iterative examinations. * @return first key value in chain. */ inline keyvalue *end(void) const {return (keyvalue*)index.end();}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; }; /** * Traditional keypair config file parsing class. This is used to get * generic config data either from a /etc/xxx.conf, a windows style * xxx.ini file, or a ~/.xxxrc file, and parses [] sections from the * entire file at once. */ class __EXPORT keyfile : public memalloc { private: friend class keydata; OrderedIndex index; keydata *defaults; int errcode; protected: keydata *create(const char *section); #ifdef _MSWINDOWS_ void load(HKEY root, keydata *section = NULL, const char *path = NULL); bool save(HKEY root, keydata *section = NULL, const char *path = NULL); #endif public: /** * Create an empty key file ready for loading. * @param pagesize for memory paging. */ keyfile(size_t pagesize = 0); /** * Create a key file object from an existing config file. * @param path to load from. * @param pagesize for memory paging. */ keyfile(const char *path, size_t pagesize = 0); keyfile(const keyfile ©, size_t pagesize = 0); /** * Load (overlay) another config file over the currently loaded one. * This is used to merge key data, such as getting default values from * a global config, and then overlaying a local home config file. * @param path to load keys from into current object. */ void load(const char *path); /** * Save (write) a set of config keys to dist. * @param path of file to save keys to. * @return true on success. */ bool save(const char *path); /** * Load from an existing keyfile object. * @param source to copy from. */ void load(const keyfile *source); /** * Load a single set of keys. * @param source of keys to copy. */ void load(const keydata *source); /** * Release and re-initialize keyfile. */ void release(void); /** * Get a keydata section name. * @param section name to look for. * @return keydata section object if found, NULL if not. */ keydata *get(const char *section) const; inline keydata *operator()(const char *section) const {return get(section);}; inline keydata *operator[](const char *section) const {return get(section);}; /** * Get the non-sectioned defaults if there are any. * @return default key section. */ inline keydata *get(void) const {return defaults;}; /** * Get first keydata object, for iterative examinations. * @return first key value in chain. */ inline keydata *begin(void) const {return (keydata *)index.begin();}; /** * Get last keydata object, for iterative examinations. * @return first key value in chain. */ inline keydata *end(void) const {return (keydata *)index.end();}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; inline int err(void) {return errcode;} }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/Makefile.in0000644000175000017500000004315112175171470014426 00000000000000# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = inc/ucommon DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(pkginclude_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ucommon-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgincludedir)" HEADERS = $(pkginclude_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/ucommon ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKFLAGS = @CHECKFLAGS@ COMPAT = @COMPAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_GENERIC = @LT_GENERIC@ LT_VERSION = @LT_VERSION@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SECURE = @SECURE@ SECURE_LIBS = @SECURE_LIBS@ SECURE_LOCAL = @SECURE_LOCAL@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UCOMMON_CFGPATH = @UCOMMON_CFGPATH@ UCOMMON_CLINK = @UCOMMON_CLINK@ UCOMMON_FLAGS = @UCOMMON_FLAGS@ UCOMMON_INCLUDES = @UCOMMON_INCLUDES@ UCOMMON_LIBC = @UCOMMON_LIBC@ UCOMMON_LIBS = @UCOMMON_LIBS@ UCOMMON_LINKED = @UCOMMON_LINKED@ UCOMMON_LOCALE = @UCOMMON_LOCALE@ UCOMMON_MODEL = @UCOMMON_MODEL@ UCOMMON_PREFIX = @UCOMMON_PREFIX@ UCOMMON_VARPATH = @UCOMMON_VARPATH@ UCOMMON_VISIBILITY = @UCOMMON_VISIBILITY@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ includes = @includes@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libs = @libs@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = $(LT_VERSION) -release $(LT_RELEASE) AM_CXXFLAGS = $(UCOMMON_FLAGS) pkginclude_HEADERS = cpr.h object.h linked.h string.h counter.h vector.h \ bitmap.h timers.h socket.h access.h export.h thread.h mapped.h \ keydata.h memory.h platform.h fsys.h xml.h ucommon.h stream.h \ persist.h shell.h protocols.h atomic.h buffer.h numbers.h file.h \ datetime.h unicode.h secure.h generics.h containers.h stl.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu inc/ucommon/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu inc/ucommon/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-pkgincludeHEADERS install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ucommon-6.0.7/inc/ucommon/vector.h0000644000175000017500000005530012163025062014023 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Basic array and reusable object factory heap support. * This offers ucommon support for vector arrays, and for forming * reusable object pools. Reusable object pools can be tied to local * heaps and offer a means to create type factories that do not require * global locking through malloc. * @file ucommon/vector.h */ #ifndef _UCOMMON_VECTOR_H_ #define _UCOMMON_VECTOR_H_ #ifndef _UCOMMON_THREAD_H_ #include #endif typedef unsigned short vectorsize_t; NAMESPACE_UCOMMON /** * An array of reusable objects. This class is used to support the * array_use template. A pool of objects are created which can be * allocated as needed. Deallocated objects are returned to the pool * so they can be reallocated later. This is a private fixed size heap. * @author David Sugar */ class __EXPORT ArrayReuse : public ReusableAllocator { private: size_t objsize; unsigned count, limit, used; caddr_t mem; protected: ArrayReuse(size_t objsize, unsigned c); ArrayReuse(size_t objsize, unsigned c, void *memory); public: /** * Destroy reusable private heap array. */ ~ArrayReuse(); protected: bool avail(void); ReusableObject *get(timeout_t timeout); ReusableObject *get(void); ReusableObject *request(void); }; /** * A mempager source of reusable objects. This is used by the reuse_pager * template to allocate new objects either from a memory pager used as * a private heap, or from previously allocated objects that have been * returned for reuse. * @author David Sugar */ class __EXPORT PagerReuse : protected MemoryRedirect, protected ReusableAllocator { private: unsigned limit, count; size_t osize; protected: PagerReuse(mempager *pager, size_t objsize, unsigned count); ~PagerReuse(); bool avail(void); ReusableObject *get(void); ReusableObject *get(timeout_t timeout); ReusableObject *request(void); }; /** * A managed vector for generic object pointers. This vector is memory * managed at runtime by basic cow (copy-on-write) operations of a reference * counted object list. This allows the size of the vector to be changed * at runtime and for the vector to be copied by managing reference counted * copies of the list of objects as needed. * * This class is somewhat analogous to the string class, but rather than * holding a string "array of chars" that may be re-sized and reallocated, * the Vector holds an array of Object pointers. Since the object pointers * we store in the vector are objects inherited from Object, a vector can * itself act as a vector of smart pointers to reference counted objects * (derived from CountedObject). * @author David Sugar . */ class __EXPORT Vector { public: class __EXPORT array : public CountedObject { public: #pragma pack(1) vectorsize_t max, len; ObjectProtocol *list[1]; #pragma pack() array(vectorsize_t size); void dealloc(void); void set(ObjectProtocol **items); void add(ObjectProtocol **list); void add(ObjectProtocol *obj); void purge(void); void inc(vectorsize_t adj); void dec(vectorsize_t adj); }; protected: array *data; array *create(vectorsize_t size) const; virtual void release(void); virtual void cow(vectorsize_t adj = 0); ObjectProtocol **list(void) const; friend class Vector::array; protected: /** * Object handler for index outside vector range. * @return default object, often NULL. */ virtual ObjectProtocol *invalid(void) const; public: /** * npos is a constant for an "invalid" position value. */ static const vectorsize_t npos; /** * Create an initially empty vector. */ Vector(); /** * Create a vector of size object pointers. * @param size of vector to create. */ Vector(vectorsize_t size); /** * Create a vector of size objects from existing object pointers. * This allocates the vector and initializes the object pointers from * an existing array of object pointers. Either a specific vector * size may be used, or the end of the vector will be found by a NULL * object pointer. * @param items to place into the vector. * @param size of the vector to create, or use NULL item for end. */ Vector(ObjectProtocol **items, vectorsize_t size = 0); /** * Destroy the current reference counted vector of object pointers. */ virtual ~Vector(); /** * Get the size of the vector (number of active members). * @return number of active pointers in vector. */ vectorsize_t len(void) const; /** * Get the effective allocation space used by the vector. This is the * number of pointers it can hold before it needs to be resized. * @return storage size of vector. */ vectorsize_t size(void) const; /** * Get an object pointer from a specified member of the vector. * @param index of member pointer to return. Negative values from end. * @return object pointer of member. */ ObjectProtocol *get(int index) const; /** * Copy the vector to an external pointer array. * @param mem array of external pointers to hold vector. * @param max size of the external array. * @return number of elements copied into external array. */ vectorsize_t get(void **mem, vectorsize_t max) const; /** * Get the first object pointer contained in the vector. Typically used * in iterations. * @return first object pointer. */ ObjectProtocol *begin(void) const; /** * Get the last object pointer contained in the vector. Typically used * in iterations. * @return last object pointer. */ ObjectProtocol *end(void) const; /** * Find the first instance of a specific pointer in the vector. * @param pointer to locate in the vector. * @param offset to start searching in vector. * @return position of pointer in vector or npos if not found. */ vectorsize_t find(ObjectProtocol *pointer, vectorsize_t offset = 0) const; /** * Split the vector at a specified offset. All members after the split * are de-referenced and dropped from the vector. * @param position to split vector at. */ void split(vectorsize_t position); /** * Split the vector after a specified offset. All members before the split * are de-referenced and dropped. The member starting at the split point * becomes the first member of the vector. * @param position to split vector at. */ void rsplit(vectorsize_t position); /** * Set a member of the vector to an object. If an existing member was * present and is being replaced, it is de-referenced. * @param position in vector to place object pointer. * @param pointer to place in vector. */ void set(vectorsize_t position, ObjectProtocol *pointer); /** * Set the vector to a list of objects terminated by a NULL pointer. * @param list of object pointers. */ void set(ObjectProtocol **list); /** * Add (append) a NULL terminated list of objects to the vector. * @param list of object pointers to add. */ void add(ObjectProtocol **list); /** * Add (append) a single object pointer to the vector. * @param pointer to add to vector. */ void add(ObjectProtocol *pointer); /** * De-reference and remove all pointers from the vector. */ void clear(void); /** * Re-size & re-allocate the total (allocated) size of the vector. * @param size to allocate for vector. */ virtual bool resize(vectorsize_t size); /** * Set (duplicate) an existing vector into our vector. * @param vector to duplicate. */ inline void set(Vector &vector) {set(vector.list());}; /** * Add (append) an existing vector to our vector. * @param vector to append. */ inline void add(Vector &vector) {add(vector.list());}; /** * Return a pointer from the vector by array reference. * @param index of vector member pointer to return. */ inline ObjectProtocol *operator[](int index) {return get(index);}; /** * Assign a member of the vector directly. * @param position to assign. * @param pointer to object to assign to vector. */ inline void operator()(vectorsize_t position, ObjectProtocol *pointer) {set(position, pointer);}; /** * Retrieve a member of the vector directly. * @param position to retrieve object from. * @return object pointer retrieved from vector. */ inline ObjectProtocol *operator()(vectorsize_t position) {return get(position);}; /** * Append a member to the vector directly. * @param pointer to object to add to vector. */ inline void operator()(ObjectProtocol *pointer) {add(pointer);}; /** * Assign (copy) into our existing vector from another vector. * @param vector to assign from. */ inline void operator=(Vector &vector) {set(vector.list());}; /** * Append into our existing vector from another vector. * @param vector to append from. */ inline void operator+=(Vector &vector) {add(vector.list());}; /** * Concatenate into our existing vector from assignment list. * @param vector to append from. */ inline Vector& operator+(Vector &vector) {add(vector.list()); return *this;}; /** * Release vector and concat vector from another vector. * @param vector to assign from. */ Vector &operator^(Vector &vector); /** * Release our existing vector and duplicate from another vector. This * differs from assign in that the allocated size of the vector is reset * to the new list. * @param vector to assign from. */ void operator^=(Vector &vector); /** * Drop first member of vector. */ void operator++(); /** * Drop last member of the vector. */ void operator--(); /** * Drop first specified members from the vector. * @param count of members to drop. */ void operator+=(vectorsize_t count); /** * Drop last specified members from the vector. * @param count of members to drop. */ void operator-=(vectorsize_t count); /** * Compute the effective vector size of a list of object pointers. * The size is found as the NULL pointer in the list. * @return size of list. */ static vectorsize_t size(void **list); }; /** * Vector with fixed size member list. This is analogous to the memstring * class and is used to tie a vector to a fixed list in memory. * @author David Sugar */ class __EXPORT MemVector : public Vector { private: bool resize(vectorsize_t size); void cow(vectorsize_t adj = 0); void release(void); friend class Vector::array; public: /** * Create and manage a vector stored in fixed memory. * @param pointer to where our vector list lives. * @param size of vector list in memory. */ MemVector(void *pointer, vectorsize_t size); /** * Destroy the vector. */ ~MemVector(); /** * Assign an existing vector into our fixed vector list. * @param vector to copy from. */ inline void operator=(Vector &vector) {set(vector);}; }; /** * A templated vector for a list of a specific Object subtype. The * templated type must be derived from Object. * @author David Sugar */ template class vectorof : public Vector { public: /** * Create an empty vector for specified type. */ inline vectorof() : Vector() {}; /** * Create an empty vector of allocated size for specified type. * @param size of vector to allocate. */ inline vectorof(vectorsize_t size) : Vector(size) {}; inline T& operator[](int index) {return static_cast(Vector::get(index));}; inline const T& at(int index) {return static_cast(Vector::get(index));}; /** * Retrieve a typed member of the vector directly. * @param position to retrieve object from. * @return typed object pointer retrieved from vector. */ inline T *operator()(vectorsize_t position) {return static_cast(Vector::get(position));}; /** * Get the first typed object pointer contained in the vector. * @return first typed object pointer. */ inline T *begin(void) {return static_cast(Vector::begin());}; /** * Get the last typed object pointer contained in the vector. * @return last typed object pointer. */ inline T *end(void) {return static_cast(Vector::end());}; /** * Concatenate typed vector in an expression. * @param vector to concatenate. * @return effective object to continue in expression. */ inline Vector &operator+(Vector &vector) {Vector::add(vector); return static_cast(*this);}; }; /** * An array of reusable types. A pool of typed objects is created which can * be allocated as needed. Deallocated typed objects are returned to the pool * so they can be reallocated later. This is a private fixed size heap. * @author David Sugar */ template class array_reuse : protected ArrayReuse { public: /** * Create private heap of reusable objects of specified type. * @param count of objects of specified type to allocate. */ inline array_reuse(unsigned count) : ArrayReuse(sizeof(T), count) {}; /** * Create reusable objects of specific type in preallocated memory. * @param count of objects of specified type in memory. * @param memory to use. */ inline array_reuse(unsigned count, void *memory) : ArrayReuse(sizeof(T), count, memory) {}; /** * Test if typed objects available in heap or re-use list. * @return true if objects still are available. */ inline operator bool() const {return avail();}; /** * Test if the entire heap has been allocated. * @return true if no objects are available. */ inline bool operator!() const {return !avail();}; /** * Request immediately next available typed object from the heap. * @return typed object pointer or NULL if heap is empty. */ inline T* request(void) {return static_cast(ArrayReuse::request());}; /** * Get a typed object from the heap. This function blocks when the * heap is empty until an object is returned to the heap. * @return typed object pointer from heap. */ inline T* get(void) {return static_cast(ArrayReuse::get());}; /** * Create a typed object from the heap. This function blocks when the * heap is empty until an object is returned to the heap. * @return typed object pointer from heap. */ inline T* create(void) {return init(static_cast(ArrayReuse::get()));}; /** * Get a typed object from the heap. This function blocks until the * the heap has an object to return or the timer has expired. * @param timeout to wait for heap in milliseconds. * @return typed object pointer from heap or NULL if timeout. */ inline T* get(timeout_t timeout) {return static_cast(ArrayReuse::get(timeout));}; /** * Create a typed object from the heap. This function blocks until the * the heap has an object to return or the timer has expired. * @param timeout to wait for heap in milliseconds. * @return typed object pointer from heap or NULL if timeout. */ inline T* create(timeout_t timeout) {return init(static_cast(ArrayReuse::get(timeout)));}; /** * Release (return) a typed object back to the heap for re-use. * @param object to return. */ inline void release(T *object) {ArrayReuse::release(object);}; /** * Get a typed object from the heap by type casting reference. This * function blocks while the heap is empty. * @return typed object pointer from heap. */ inline operator T*() {return array_reuse::get();}; /** * Get a typed object from the heap by pointer reference. This * function blocks while the heap is empty. * @return typed object pointer from heap. */ inline T *operator*() {return array_reuse::get();}; }; /** * A reusable private pool of reusable types. A pool of typed objects is * created which can be allocated from a memory pager. Deallocated typed * objects are also returned to this pool so they can be reallocated later. * @author David Sugar */ template class paged_reuse : protected PagerReuse { public: /** * Create a managed reusable typed object pool. This manages a heap of * typed objects that can either be reused from released objects or * allocate from an existing memory pager pool. * @param pager pool to allocate from. * @param count of objects of specified type to allocate. */ inline paged_reuse(mempager *pager, unsigned count) : PagerReuse(pager, sizeof(T), count) {}; /** * Test if typed objects available from the pager or re-use list. * @return true if objects still are available. */ inline operator bool() const {return PagerReuse::avail();}; /** * Test if no objects are available for reuse or the pager. * @return true if no objects are available. */ inline bool operator!() const {return !PagerReuse::avail();}; /** * Get a typed object from the pager heap. This function blocks when the * heap is empty until an object is returned to the heap. * @return typed object pointer from heap. */ inline T *get(void) {return static_cast(PagerReuse::get());}; /** * Get a typed object from the pager heap. This function blocks when the * heap is empty until an object is returned to the heap. The objects * default constructor is used. * @return typed object pointer from heap. */ inline T *create(void) {return init(static_cast(PagerReuse::get()));}; /** * Get a typed object from the heap. This function blocks until the * the heap has an object to return or the timer has expired. * @param timeout to wait for heap in milliseconds. * @return typed object pointer from heap or NULL if timeout. */ inline T *get(timeout_t timeout) {return static_cast(PagerReuse::get(timeout));}; /** * Create a typed object from the heap. This function blocks until the * the heap has an object to return or the timer has expired. The * objects default constructor is used. * @param timeout to wait for heap in milliseconds. * @return typed object pointer from heap or NULL if timeout. */ inline T *create(timeout_t timeout) {return init(static_cast(PagerReuse::get(timeout)));}; /** * Request immediately next available typed object from the pager heap. * @return typed object pointer or NULL if heap is empty. */ inline T *request(void) {return static_cast(PagerReuse::request());}; /** * Release (return) a typed object back to the pager heap for re-use. * @param object to return. */ inline void release(T *object) {PagerReuse::release(object);}; /** * Get a typed object from the pager heap by type casting reference. This * function blocks while the heap is empty. * @return typed object pointer from heap. */ inline T *operator*() {return paged_reuse::get();}; /** * Get a typed object from the pager heap by pointer reference. This * function blocks while the heap is empty. * @return typed object pointer from heap. */ inline operator T*() {return paged_reuse::get();}; }; /** * Allocated vector list of a specified type. This analogous to the stringbuf * class and allows one to create a vector with it's member list as a single * object that can live in the heap or that can be created at once and used as * a auto variable. * @author David Sugar */ template class vectorbuf : public MemVector { private: char buffer[sizeof(array) + (S * sizeof(void *))]; public: /** * Construct fixed sized vector object in heap or stack. */ inline vectorbuf() : MemVector(buffer, S) {}; /** * Get object pointer of specified type from fixed vector. * @param index of typed member to return, < 0 to use from end of list. * @return typed object pointer of member. */ inline const T& at(int index) {return static_cast(Vector::get(index));}; inline T& operator[](int index) {return static_cast(Vector::get(index));}; /** * Retrieve a typed member of the fixed vector directly. * @param position to retrieve object from. * @return typed object pointer retrieved from vector. */ inline T *operator()(vectorsize_t position) {return static_cast(Vector::get(position));}; /** * Get the first typed object pointer contained in the fixed vector. * @return first typed object pointer. */ inline T *begin(void) {return static_cast(Vector::begin());}; /** * Get the last typed object pointer contained in the fixed vector. * @return last typed object pointer. */ inline T *end(void) {return static_cast(Vector::end());}; /** * Concatenate fixed typed vector in an expression. * @param vector to concatenate. * @return effective object to continue in expression. */ inline Vector &operator+(Vector &vector) {Vector::add(vector); return static_cast(*this);}; }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/thread.h0000644000175000017500000016223312163025062013774 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Thread classes and sychronization objects. * The theory behind ucommon thread classes is that they would be used * to create derived classes where thread-specific data can be stored as * member data of the derived class. The run method is called when the * context is executed. Since we use a pthread foundation, we support * both detached threads and joinable threads. Objects based on detached * threads should be created with new, and will automatically delete when * the thread context exits. Joinable threads will be joined with deleted. * * The theory behind ucommon sychronization objects is that all upper level * sychronization objects can be formed directly from a mutex and conditional. * This includes semaphores, barriers, rwlock, our own specialized conditional * lock, resource-bound locking, and recurive exclusive locks. Using only * conditionals means we are not dependent on platform specific pthread * implimentations that may not impliment some of these, and hence improves * portability and consistency. Given that our rwlocks are recursive access * locks, one can safely create read/write threading pairs where the read * threads need not worry about deadlocks and the writers need not either if * they only write-lock one instance at a time to change state. * @file ucommon/thread.h */ /** * An example of the thread queue class. This may be relevant to producer- * consumer scenarios and realtime applications where queued messages are * stored on a re-usable object pool. * @example queue.cpp */ /** * A simple example of threading and join operation. * @example thread.cpp */ #ifndef _UCOMMON_THREAD_H_ #define _UCOMMON_THREAD_H_ #ifndef _UCOMMON_CPR_H_ #include #endif #ifndef _UCOMMON_ACCESS_H_ #include #endif #ifndef _UCOMMON_TIMERS_H_ #include #endif #ifndef _UCOMMON_MEMORY_H_ #include #endif NAMESPACE_UCOMMON class SharedPointer; /** * The conditional is a common base for other thread synchronizing classes. * Many of the complex sychronization objects, including barriers, semaphores, * and various forms of read/write locks are all built from the conditional. * This assures that the minimum functionality to build higher order thread * synchronizing objects is a pure conditional, and removes dependencies on * what may be optional features or functions that may have different * behaviors on different pthread implimentations and platforms. * @author David Sugar */ class __EXPORT Conditional { private: friend class ConditionalAccess; #if defined(_MSCONDITIONAL_) CRITICAL_SECTION mutex; CONDITION_VARIABLE cond; #elif defined(_MSWINDOWS_) enum {SIGNAL = 0, BROADCAST = 1}; HANDLE events[2]; unsigned waiting; CRITICAL_SECTION mlock; CRITICAL_SECTION mutex; #else #ifndef __PTH__ class __LOCAL attribute { public: pthread_condattr_t attr; attribute(); }; __LOCAL static attribute attr; #endif pthread_cond_t cond; pthread_mutex_t mutex; #endif protected: friend class TimedEvent; /** * Conditional wait for signal on millisecond timeout. * @param timeout in milliseconds. * @return true if signalled, false if timer expired. */ bool wait(timeout_t timeout); /** * Conditional wait for signal on timespec timeout. * @param timeout as a high resolution timespec. * @return true if signalled, false if timer expired. */ bool wait(struct timespec *timeout); #ifdef _MSWINDOWS_ inline void lock(void) {EnterCriticalSection(&mutex);}; inline void unlock(void) {LeaveCriticalSection(&mutex);}; void wait(void); void signal(void); void broadcast(void); #else /** * Lock the conditional's supporting mutex. */ inline void lock(void) {pthread_mutex_lock(&mutex);}; /** * Unlock the conditional's supporting mutex. */ inline void unlock(void) {pthread_mutex_unlock(&mutex);}; /** * Wait (block) until signalled. */ inline void wait(void) {pthread_cond_wait(&cond, &mutex);}; /** * Signal the conditional to release one waiting thread. */ inline void signal(void) {pthread_cond_signal(&cond);}; /** * Signal the conditional to release all waiting threads. */ inline void broadcast(void) {pthread_cond_broadcast(&cond);}; #endif /** * Initialize and construct conditional. */ Conditional(); /** * Destroy conditional, release any blocked threads. */ ~Conditional(); public: #if !defined(_MSWINDOWS_) && !defined(__PTH__) /** * Support function for getting conditional attributes for realtime * scheduling. * @return attributes to use for creating realtime conditionals. */ static inline pthread_condattr_t *initializer(void) {return &attr.attr;}; #endif /** * Convert a millisecond timeout into use for high resolution * conditional timers. * @param hires timespec representation to set. * @param timeout to convert. */ static void set(struct timespec *hires, timeout_t timeout); }; /** * The conditional rw seperates scheduling for optizming behavior or rw locks. * This varient of conditonal seperates scheduling read (broadcast wakeup) and * write (signal wakeup) based threads. This is used to form generic rwlock's * as well as the specialized condlock. * @author David Sugar */ class __EXPORT ConditionalAccess : private Conditional { protected: #if defined _MSCONDITIONAL_ CONDITION_VARIABLE bcast; #elif !defined(_MSWINDOWS_) pthread_cond_t bcast; #endif unsigned pending, waiting, sharing; /** * Conditional wait for signal on millisecond timeout. * @param timeout in milliseconds. * @return true if signalled, false if timer expired. */ bool waitSignal(timeout_t timeout); /** * Conditional wait for broadcast on millisecond timeout. * @param timeout in milliseconds. * @return true if signalled, false if timer expired. */ bool waitBroadcast(timeout_t timeout); /** * Conditional wait for signal on timespec timeout. * @param timeout as a high resolution timespec. * @return true if signalled, false if timer expired. */ bool waitSignal(struct timespec *timeout); /** * Conditional wait for broadcast on timespec timeout. * @param timeout as a high resolution timespec. * @return true if signalled, false if timer expired. */ bool waitBroadcast(struct timespec *timeout); /** * Convert a millisecond timeout into use for high resolution * conditional timers. * @param hires timespec representation to set. * @param timeout to convert. */ inline static void set(struct timespec *hires, timeout_t timeout) {Conditional::set(hires, timeout);}; #ifdef _MSWINDOWS_ inline void lock(void) {EnterCriticalSection(&mutex);}; inline void unlock(void) {LeaveCriticalSection(&mutex);}; void waitSignal(void); void waitBroadcast(void); inline void signal(void) {Conditional::signal();}; inline void broadcast(void) {Conditional::broadcast();}; #else /** * Lock the conditional's supporting mutex. */ inline void lock(void) {pthread_mutex_lock(&mutex);}; /** * Unlock the conditional's supporting mutex. */ inline void unlock(void) {pthread_mutex_unlock(&mutex);}; /** * Wait (block) until signalled. */ inline void waitSignal(void) {pthread_cond_wait(&cond, &mutex);}; /** * Wait (block) until broadcast. */ inline void waitBroadcast(void) {pthread_cond_wait(&bcast, &mutex);}; /** * Signal the conditional to release one signalled thread. */ inline void signal(void) {pthread_cond_signal(&cond);}; /** * Signal the conditional to release all broadcast threads. */ inline void broadcast(void) {pthread_cond_broadcast(&bcast);}; #endif public: /** * Initialize and construct conditional. */ ConditionalAccess(); /** * Destroy conditional, release any blocked threads. */ ~ConditionalAccess(); /** * Access mode shared thread scheduling. */ void access(void); /** * Exclusive mode write thread scheduling. */ void modify(void); /** * Release access mode read scheduling. */ void release(void); /** * Complete exclusive mode write scheduling. */ void commit(void); /** * Specify a maximum sharing (access) limit. This can be used * to detect locking errors, such as when aquiring locks that are * not released. * @param max sharing level. */ void limit_sharing(unsigned max); }; /** * Event notification to manage scheduled realtime threads. The timer * is advanced to sleep threads which then wakeup either when the timer * has expired or they are notified through the signal handler. This can * be used to schedule and signal one-time completion handlers or for time * synchronized events signaled by an asychrononous I/O or event source. * @author David Sugar */ class __EXPORT TimedEvent : public Timer { private: #ifdef _MSWINDOWS_ HANDLE event; #else pthread_cond_t cond; bool signalled; #endif pthread_mutex_t mutex; protected: /** * Lock the object for wait or to manipulate derived data. This is * relevant to manipulations in a derived class. */ void lock(void); /** * Release the object lock after waiting. This is relevent to * manipulations in a derived class. */ void release(void); /** * Wait while locked. This can be used in more complex derived * objects where we are concerned with synchronized access between * the signaling and event thread. This can be used in place of * wait, but lock and release methods must be used around it. * @return true if time expired. */ bool sync(void); public: /** * Create event handler and timer for timing of events. */ TimedEvent(void); /** * Create event handler and timer set to trigger a timeout. * @param timeout in milliseconds. */ TimedEvent(timeout_t timeout); /** * Create event handler and timer set to trigger a timeout. * @param timeout in seconds. */ TimedEvent(time_t timeout); /** * Destroy timer and release pending events. */ ~TimedEvent(); /** * Signal pending event. Object may be locked or unlocked. The * signalling thread may choose to lock and check a condition in * a derived class before signalling. */ void signal(void); /** * Wait to be signalled or until timer expires. This is a wrapper for * expire for simple completion events. * @param timeout to wait from last reset. * @return true if signaled, false if timeout. */ bool wait(timeout_t timeout); /** * A simple wait until triggered. */ void wait(void); /** * Reset triggered conditional. */ void reset(void); }; /** * Portable recursive exclusive lock. This class is built from the * conditional and hence does not require support for non-standard and * platform specific extensions to pthread mutex to support recrusive * style mutex locking. The exclusive protocol is implimented to support * exclusive_lock referencing. */ class __EXPORT RecursiveMutex : private Conditional, public ExclusiveAccess { protected: unsigned waiting; unsigned lockers; pthread_t locker; virtual void _lock(void); virtual void _unlock(void); public: /** * Create rexlock. */ RecursiveMutex(); /** * Acquire or increase locking. */ void lock(void); /** * Timed lock request. */ bool lock(timeout_t timeout); /** * Release or decrease locking. */ void release(void); }; /** * A generic and portable implimentation of Read/Write locking. This * class impliments classical read/write locking, including "timed" locks. * Support for scheduling threads to avoid writer starvation is also provided * for. By building read/write locks from a conditional, we make them * available on pthread implimetations and other platforms which do not * normally include optional pthread rwlock's. We also do not restrict * the number of threads that may use the lock. Finally, both the exclusive * and shared protocols are implimented to support exclusive_lock and * shared_lock referencing. * @author David Sugar */ class __EXPORT ThreadLock : private ConditionalAccess, public ExclusiveAccess, public SharedAccess { protected: unsigned writers; pthread_t writeid; virtual void _lock(void); virtual void _share(void); virtual void _unlock(void); public: /** * Guard class to apply scope based access locking to objects. The rwlock * is located from the rwlock pool rather than contained in the target * object, and the read lock is released when the guard object falls out of * scope. This is essentially an automation mechanism for mutex::reader. * @author David Sugar */ class __EXPORT guard_reader { private: const void *object; public: /** * Create an unitialized instance of guard. Usually used with a * guard = operator. */ guard_reader(); /** * Construct a guard for a specific object. * @param object to guard. */ guard_reader(const void *object); /** * Release mutex when guard falls out of scope. */ ~guard_reader(); /** * Set guard to mutex lock a new object. If a lock is currently * held, it is released. * @param object to guard. */ void set(const void *object); /** * Prematurely release a guard. */ void release(void); /** * Set guard to read lock a new object. If a lock is currently * held, it is released. * @param pointer to object to guard. */ inline void operator=(const void *pointer) {set(pointer);}; }; /** * Guard class to apply scope based exclusive locking to objects. The rwlock * is located from the rwlock pool rather than contained in the target * object, and the write lock is released when the guard object falls out of * scope. This is essentially an automation mechanism for mutex::writer. * @author David Sugar */ class __EXPORT guard_writer { private: const void *object; public: /** * Create an unitialized instance of guard. Usually used with a * guard = operator. */ guard_writer(); /** * Construct a guard for a specific object. * @param object to guard. */ guard_writer(const void *object); /** * Release mutex when guard falls out of scope. */ ~guard_writer(); /** * Set guard to mutex lock a new object. If a lock is currently * held, it is released. * @param object to guard. */ void set(const void *object); /** * Prematurely release a guard. */ void release(void); /** * Set guard to read lock a new object. If a lock is currently * held, it is released. * @param pointer to object to guard. */ inline void operator=(const void *pointer) {set(pointer);}; }; /** * Create an instance of a rwlock. */ ThreadLock(); /** * Request modify (write) access through the lock. * @param timeout in milliseconds to wait for lock. * @return true if locked, false if timeout. */ bool modify(timeout_t timeout = Timer::inf); /** * Request shared (read) access through the lock. * @param timeout in milliseconds to wait for lock. * @return true if locked, false if timeout. */ bool access(timeout_t timeout = Timer::inf); /** * Specify hash table size for guard protection. The default is 1. * This should be called at initialization time from the main thread * of the application before any other threads are created. * @param size of hash table used for guarding. */ static void indexing(unsigned size); /** * Write protect access to an arbitrary object. This is like the * protect function of mutex. * @param object to protect. * @param timeout in milliseconds to wait for lock. * @return true if locked, false if timeout. */ static bool writer(const void *object, timeout_t timeout = Timer::inf); /** * Shared access to an arbitrary object. This is based on the protect * function of mutex. * @param object to share. * @param timeout in milliseconds to wait for lock. * @return true if shared, false if timeout. */ static bool reader(const void *object, timeout_t timeout = Timer::inf); /** * Release an arbitrary object that has been protected by a rwlock. * @param object to release. */ static void release(const void *object); /** * Release the lock. */ void release(void); }; /** * Class for resource bound memory pools between threads. This is used to * support a memory pool allocation scheme where a pool of reusable objects * may be allocated, and the pool renewed by releasing objects or back. * When the pool is used up, a pool consuming thread then must wait for * a resource to be freed by another consumer (or timeout). This class is * not meant to be used directly, but rather to build the synchronizing * control between consumers which might be forced to wait for a resource. * @author David Sugar */ class __EXPORT ReusableAllocator : protected Conditional { protected: ReusableObject *freelist; unsigned waiting; /** * Initialize reusable allocator through a conditional. Zero free list. */ ReusableAllocator(); /** * Get next reusable object in the pool. * @param object from list. * @return next object. */ inline ReusableObject *next(ReusableObject *object) {return object->getNext();}; /** * Release resuable object * @param object being released. */ void release(ReusableObject *object); }; /** * An optimized and convertable shared lock. This is a form of read/write * lock that has been optimized, particularly for shared access. Support * for scheduling access around writer starvation is also included. The * other benefits over traditional read/write locks is that the code is * a little lighter, and read (shared) locks can be converted to exclusive * (write) locks to perform brief modify operations and then returned to read * locks, rather than having to release and re-aquire locks to change mode. * @author David Sugar */ class __EXPORT ConditionalLock : protected ConditionalAccess, public SharedAccess { protected: class Context : public LinkedObject { public: inline Context(LinkedObject **root) : LinkedObject(root) {}; pthread_t thread; unsigned count; }; LinkedObject *contexts; virtual void _share(void); virtual void _unlock(void); Context *getContext(void); public: /** * Construct conditional lock for default concurrency. */ ConditionalLock(); /** * Destroy conditional lock. */ ~ConditionalLock(); /** * Acquire write (exclusive modify) lock. */ void modify(void); /** * Commit changes / release a modify lock. */ void commit(void); /** * Acquire access (shared read) lock. */ void access(void); /** * Release a shared lock. */ void release(void); /** * Convert read lock into exclusive (write/modify) access. Schedule * when other readers sharing. */ virtual void exclusive(void); /** * Return an exclusive access lock back to share mode. */ virtual void share(void); }; /** * A portable implimentation of "barrier" thread sychronization. A barrier * waits until a specified number of threads have all reached the barrier, * and then releases all the threads together. This implimentation works * regardless of whether the thread library supports barriers since it is * built from conditional. It also differs in that the number of threads * required can be changed dynamically at runtime, unlike pthread barriers * which, when supported, have a fixed limit defined at creation time. Since * we use conditionals, another feature we can add is optional support for a * wait with timeout. * @author David Sugar */ class __EXPORT barrier : private Conditional { private: unsigned count; unsigned waits; public: /** * Construct a barrier with an initial size. * @param count of threads required. */ barrier(unsigned count); /** * Destroy barrier and release pending threads. */ ~barrier(); /** * Dynamically alter the number of threads required. If the size is * set below the currently waiting threads, then the barrier releases. * @param count of threads required. */ void set(unsigned count); /** * Dynamically increment the number of threads required. */ void inc(void); /** * Reduce the number of threads required. */ void dec(void); /** * Alternative prefix form of the same increment operation. * @return the current amount of threads. */ unsigned operator++(void); unsigned operator--(void); /** * Wait at the barrier until the count of threads waiting is reached. */ void wait(void); /** * Wait at the barrier until either the count of threads waiting is * reached or a timeout has occurred. * @param timeout to wait in milliseconds. * @return true if barrier reached, false if timer expired. */ bool wait(timeout_t timeout); }; /** * A portable counting semaphore class. A semaphore will allow threads * to pass through it until the count is reached, and blocks further threads. * Unlike pthread semaphore, our semaphore class supports it's count limit * to be altered during runtime and the use of timed waits. This class also * implements the shared_lock protocol. * @author David Sugar */ class __EXPORT Semaphore : public SharedAccess, protected Conditional { protected: unsigned count, waits, used; virtual void _share(void); virtual void _unlock(void); public: /** * Construct a semaphore with an initial count of threads to permit. */ Semaphore(unsigned count = 0); /** * Wait until the semphore usage count is less than the thread limit. * Increase used count for our thread when unblocked. */ void wait(void); /** * Wait until the semphore usage count is less than the thread limit. * Increase used count for our thread when unblocked, or return without * changing if timed out. * @param timeout to wait in millseconds. * @return true if success, false if timeout. */ bool wait(timeout_t timeout); /** * Alter semaphore limit at runtime * @param count of threads to allow. */ void set(unsigned count); /** * Release the semaphore after waiting for it. */ void release(void); /** * Convenience operator to wait on a counting semaphore. */ inline void operator++(void) {wait();}; /** * Convenience operator to release a counting semaphore. */ inline void operator--(void) {release();}; }; /** * Generic non-recursive exclusive lock class. This class also impliments * the exclusive_lock protocol. In addition, an interface is offered to * support dynamically managed mutexes which are internally pooled. These * can be used to protect and serialize arbitrary access to memory and * objects on demand. This offers an advantage over embedding mutexes to * serialize access to individual objects since the maximum number of * mutexes will never be greater than the number of actually running threads * rather than the number of objects being potentially protected. The * ability to hash the pointer address into an indexed table further optimizes * access by reducing the chance for collisions on the primary index mutex. * @author David Sugar */ class __EXPORT Mutex : public ExclusiveAccess { protected: pthread_mutex_t mlock; virtual void _lock(void); virtual void _unlock(void); public: /** * Guard class to apply scope based mutex locking to objects. The mutex * is located from the mutex pool rather than contained in the target * object, and the lock is released when the guard object falls out of * scope. This is essentially an automation mechanism for mutex::protect. * @author David Sugar */ class __EXPORT guard { private: const void *object; public: /** * Create an unitialized instance of guard. Usually used with a * guard = operator. */ guard(); /** * Construct a guard for a specific object. * @param object to guard. */ guard(const void *object); /** * Release mutex when guard falls out of scope. */ ~guard(); /** * Set guard to mutex lock a new object. If a lock is currently * held, it is released. * @param object to guard. */ void set(const void *object); /** * Prematurely release a guard. */ void release(void); /** * Set guard to mutex lock a new object. If a lock is currently * held, it is released. * @param pointer to object to guard. */ inline void operator=(void *pointer) {set(pointer);}; }; /** * Create a mutex lock. */ Mutex(); /** * Destroy mutex lock, release waiting threads. */ ~Mutex(); /** * Acquire mutex lock. This is a blocking operation. */ inline void acquire(void) {pthread_mutex_lock(&mlock);}; /** * Acquire mutex lock. This is a blocking operation. */ inline void lock(void) {pthread_mutex_lock(&mlock);}; /** * Release acquired lock. */ inline void unlock(void) {pthread_mutex_unlock(&mlock);}; /** * Release acquired lock. */ inline void release(void) {pthread_mutex_unlock(&mlock);}; /** * Convenience function to acquire os native mutex lock directly. * @param lock to acquire. */ inline static void acquire(pthread_mutex_t *lock) {pthread_mutex_lock(lock);}; /** * Convenience function to release os native mutex lock directly. * @param lock to release. */ inline static void release(pthread_mutex_t *lock) {pthread_mutex_unlock(lock);}; /** * Specify hash table size for guard protection. The default is 1. * This should be called at initialization time from the main thread * of the application before any other threads are created. * @param size of hash table used for guarding. */ static void indexing(unsigned size); /** * Specify pointer/object/resource to guard protect. This uses a * dynamically managed mutex. * @param pointer to protect. */ static void protect(const void *pointer); /** * Specify a pointer/object/resource to release. * @param pointer to release. */ static void release(const void *pointer); }; /** * A mutex locked object smart pointer helper class. This is particularly * useful in referencing objects which will be protected by the mutex * protect function. When the pointer falls out of scope, the protecting * mutex is also released. This is meant to be used by the typed * mutex_pointer template. * @author David Sugar */ class __EXPORT auto_protect { private: // cannot copy... inline auto_protect(const auto_object &pointer) {}; protected: const void *object; auto_protect(); public: /** * Construct a protected pointer referencing an existing object. * @param object we point to. */ auto_protect(const void *object); /** * Delete protected pointer. When it falls out of scope the associated * mutex is released. */ ~auto_protect(); /** * Manually release the pointer. This releases the mutex. */ void release(void); /** * Test if the pointer is not set. * @return true if the pointer is not referencing anything. */ inline bool operator!() const {return object == NULL;}; /** * Test if the pointer is referencing an object. * @return true if the pointer is currently referencing an object. */ inline operator bool() const {return object != NULL;}; /** * Set our pointer to a specific object. If the pointer currently * references another object, the associated mutex is released. The * pointer references our new object and that new object is locked. * @param object to assign to. */ void operator=(const void *object); }; /** * An object pointer that uses mutex to assure thread-safe singleton use. * This class is used to support a threadsafe replacable pointer to a object. * This class is used to form and support the templated locked_pointer class * and used with the locked_release class. An example of where this might be * used is in config file parsers, where a seperate thread may process and * generate a new config object for new threads to refernce, while the old * configuration continues to be used by a reference counted instance that * goes away when it falls out of scope. * @author David Sugar */ class __EXPORT LockedPointer { private: friend class locked_release; pthread_mutex_t mutex; ObjectProtocol *pointer; protected: /** * Create an instance of a locked pointer. */ LockedPointer(); /** * Replace existing object with a new one for next request. * @param object to register with pointer. */ void replace(ObjectProtocol *object); /** * Create a duplicate reference counted instance of the current object. * @return duplicate reference counted object. */ ObjectProtocol *dup(void); /** * Replace existing object through assignment. * @param object to assign. */ inline void operator=(ObjectProtocol *object) {replace(object);}; }; /** * Shared singleton object. A shared singleton object is a special kind of * object that may be shared by multiple threads but which only one active * instance is allowed to exist. The shared object is managed by the * templated shared pointer class, and is meant to be inherited as a base * class for the derived shared singleton type. * @author David Sugar */ class __EXPORT SharedObject { protected: friend class SharedPointer; /** * Commit is called when a shared singleton is accepted and replaces * a prior instance managed by a shared pointer. Commit occurs * when replace is called on the shared pointer, and is assured to * happen only when no threads are accessing either the current * or the prior instance that was previously protected by the pointer. * @param pointer that now holds the object. */ virtual void commit(SharedPointer *pointer); public: /** * Allows inherited virtual. */ virtual ~SharedObject(); }; /** * The shared pointer is used to manage a singleton instance of shared object. * This class is used to support the templated shared_pointer class and the * shared_release class, and is not meant to be used directly or as a base * for anything else. One or more threads may aquire a shared lock to the * singleton object through this pointer, and it can only be replaced with a * new singleton instance when no threads reference it. The conditional lock * is used to manage shared access for use and exclusive access when modified. * @author David Sugar */ class __EXPORT SharedPointer : protected ConditionalAccess { private: friend class shared_release; SharedObject *pointer; protected: /** * Created shared locking for pointer. Must be assigned by replace. */ SharedPointer(); /** * Destroy lock and release any blocked threads. */ ~SharedPointer(); /** * Replace existing singleton instance with new one. This happens * during exclusive locking, and the commit method of the object * will be called. * @param object being set. */ void replace(SharedObject *object); /** * Acquire a shared reference to the singleton object. This is a * form of shared access lock. Derived classes and templates access * "release" when the shared pointer is no longer needed. * @return shared object. */ SharedObject *share(void); }; /** * An abstract class for defining classes that operate as a thread. A derived * thread class has a run method that is invoked with the newly created * thread context, and can use the derived object to store all member data * that needs to be associated with that context. This means the derived * object can safely hold thread-specific data that is managed with the life * of the object, rather than having to use the clumsy thread-specific data * management and access functions found in thread support libraries. * @author David Sugar */ class __EXPORT Thread { protected: // may be used in future if we need cancelable threads... #ifdef _MSWINDOWS_ HANDLE cancellor; #else void *cancellor; #endif enum {} reserved; // cancel mode? pthread_t tid; size_t stack; int priority; /** * Create a thread object that will have a preset stack size. If 0 * is used, then the stack size is os defined/default. * @param stack size to use or 0 for default. */ Thread(size_t stack = 0); /** * Map thread for get method. This should be called from start of the * run() method of a derived class. */ void map(void); /** * Check if running. */ virtual bool is_active(void); public: /** * Set thread priority without disrupting scheduling if possible. * Based on scheduling policy. It is recommended that the process * is set for realtime scheduling, and this method is actually for * internal use. */ void setPriority(void); /** * Yield execution context of the current thread. This is a static * and may be used anywhere. */ static void yield(void); /** * Sleep current thread for a specified time period. * @param timeout to sleep for in milliseconds. */ static void sleep(timeout_t timeout); /** * Get mapped thread object. This returns the mapped base class of the * thread object of the current executing context. You will need to * cast to the correct derived class to access derived thread-specific * storage. If the current thread context is not mapped NULL is returned. */ static Thread *get(void); /** * Abstract interface for thread context run method. */ virtual void run(void) = 0; /** * Destroy thread object, thread-specific data, and execution context. */ virtual ~Thread(); /** * Exit the thread context. This function should NO LONGER be called * directly to exit a running thread. Instead this method will only be * used to modify the behavior of the thread context at thread exit, * including detached threads which by default delete themselves. This * documented usage was changed to support Mozilla NSPR exit behavior * in case we support NSPR as an alternate thread runtime in the future. */ virtual void exit(void); /** * Used to initialize threading library. May be needed for some platforms. */ static void init(void); /** * Used to specify scheduling policy for threads above priority "0". * Normally we apply static realtime policy SCHED_FIFO (default) or * SCHED_RR. However, we could apply SCHED_OTHER, etc. */ static void policy(int polid); /** * Set concurrency level of process. This is essentially a portable * wrapper for pthread_setconcurrency. */ static void concurrency(int level); /** * Determine if two thread identifiers refer to the same thread. * @param thread1 to test. * @param thread2 to test. * @return true if both are the same context. */ static bool equal(pthread_t thread1, pthread_t thread2); /** * Get current thread id. * @return thread id. */ static pthread_t self(void); inline operator bool() {return is_active();} inline bool operator!() {return !is_active();} inline bool isRunning(void) {return is_active();} }; /** * A child thread object that may be joined by parent. A child thread is * a type of thread in which the parent thread (or process main thread) can * then wait for the child thread to complete and then delete the child object. * The parent thread can wait for the child thread to complete either by * calling join, or performing a "delete" of the derived child object. In * either case the parent thread will suspend execution until the child thread * exits. * @author David Sugar */ class __EXPORT JoinableThread : public Thread { protected: #ifdef _MSWINDOWS_ HANDLE running; #else volatile bool running; #endif volatile bool joining; /** * Create a joinable thread with a known context stack size. * @param size of stack for thread context or 0 for default. */ JoinableThread(size_t size = 0); /** * Delete child thread. Parent thread suspends until child thread * run method completes or child thread calls it's exit method. */ virtual ~JoinableThread(); /** * Join thread with parent. Calling from a child thread to exit is * now depreciated behavior and in the future will not be supported. * Threads should always return through their run() method. */ void join(void); bool is_active(void); virtual void run(void) = 0; public: /** * Start execution of child context. This must be called after the * child object is created (perhaps with "new") and before it can be * joined. This method actually begins the new thread context, which * then calls the object's run method. Optionally raise the priority * of the thread when it starts under realtime priority. * @param priority of child thread. */ void start(int priority = 0); /** * Start execution of child context as background thread. This is * assumed to be off main thread, with a priority lowered by one. */ inline void background(void) {start(-1);}; }; /** * A detached thread object that is stand-alone. This object has no * relationship with any other running thread instance will be automatically * deleted when the running thread instance exits, either by it's run method * exiting, or explicity calling the exit member function. * @author David Sugar */ class __EXPORT DetachedThread : public Thread { protected: bool active; /** * Create a detached thread with a known context stack size. * @param size of stack for thread context or 0 for default. */ DetachedThread(size_t size = 0); /** * Destroys object when thread context exits. Never externally * deleted. Derived object may also have destructor to clean up * thread-specific member data. */ ~DetachedThread(); /** * Exit context of detached thread. Thread object will be deleted. * This function should NO LONGER be called directly to exit a running * thread. Instead, the thread should only "return" through the run() * method to exit. The documented usage was changed so that exit() can * still be used to modify the "delete this" behavior of detached threads * while merging thread exit behavior with Mozilla NSPR. */ void exit(void); bool is_active(void); virtual void run(void) = 0; public: /** * Start execution of detached context. This must be called after the * object is created (perhaps with "new"). This method actually begins * the new thread context, which then calls the object's run method. * @param priority to start thread with. */ void start(int priority = 0); }; /** * Auto-pointer support class for locked objects. This is used as a base * class for the templated locked_instance class that uses the managed * LockedPointer to assign a reference to an object. When the locked * instance falls out of scope, the object is derefenced. Ideally the * pointer typed object should be based on the reference counted object class. * @author David Sugar */ class __EXPORT locked_release { protected: ObjectProtocol *object; /**< locked object protected by locked_release */ /** * Create an unassigned locked object pointer base. */ locked_release(); /** * Construct a locked object instance base from an existing instance. This * will create a duplicate (retained) reference. * @param object to copy from. */ locked_release(const locked_release &object); public: /** * Construct a locked object instance base from a LockedPointer. References * a retained instance of the underlying object from the LockedPointer. * @param pointer of locked pointer to assign from. */ locked_release(LockedPointer &pointer); /** * Auto-release pointer to locked object instance. This is used to release * a reference when the pointer template falls out of scope. */ ~locked_release(); /** * Manually release the object reference. */ void release(void); /** * Assign a locked object pointer. If an existing object is already * assigned, the existing pointer is released. * @param pointer reference through locked object. */ locked_release &operator=(LockedPointer &pointer); }; /** * Auto-pointer support class for shared singleton objects. This is used as * a base class for the templated shared_instance class that uses shared * access locking through the SharedPointer class. When the shared instance * falls out of scope, the SharedPointer lock is released. The pointer * typed object must be based on the SharedObject class. * @author David Sugar */ class __EXPORT shared_release { protected: SharedPointer *ptr; /**< Shared lock for protected singleton */ /** * Create an unassigned shared singleton object pointer base. */ shared_release(); /** * Construct a shared object instance base from an existing instance. This * will assign an additional shared lock. * @param object to copy from. */ shared_release(const shared_release &object); public: /** * Access lock a shared singleton instance from a SharedPointer. * @param pointer of shared pointer to assign from. */ shared_release(SharedPointer &pointer); /** * Auto-unlock shared lock for singleton instance protected by shared * pointer. This is used to unlock when the instance template falls out * of scope. */ ~shared_release(); /** * Manually release access to shared singleton object. */ void release(void); /** * Get pointer to singleton object that we have shared lock for. * @return shared object singleton. */ SharedObject *get(void); /** * Assign shared lock access to shared singleton. If an existing * shared lock is held for another pointer, it is released. * @param pointer access for shared object. */ shared_release &operator=(SharedPointer &pointer); }; /** * Templated shared pointer for singleton shared objects of specific type. * This is used as typed template for the SharedPointer object reference * management class. This is used to supply a typed singleton shared * instance to the typed shared_instance template class. * @author David Sugar */ template class shared_pointer : public SharedPointer { public: /** * Created shared locking for typed singleton pointer. */ inline shared_pointer() : SharedPointer() {}; /** * Acquire a shared (duplocate) reference to the typed singleton object. * This is a form of shared access lock. Derived classes and templates * access conditionallock "release" when the shared pointer is no longer * needed. * @return typed shared object. */ inline const T *dup(void) {return static_cast(SharedPointer::share());}; /** * Replace existing typed singleton instance with new one. This happens * during exclusive locking, and the commit method of the typed object * will be called. * @param object being set. */ inline void replace(T *object) {SharedPointer::replace(object);}; /** * Replace existing typed singleton object through assignment. * @param object to assign. */ inline void operator=(T *object) {replace(object);}; /** * Access shared lock typed singleton object by pointer reference. * @return typed shared object. */ inline T *operator*() {return dup();}; }; /** * Templated locked pointer for referencing locked objects of specific type. * This is used as typed template for the LockedPointer object reference * management class. This is used to supply a typed locked instances * to the typed locked_instance template class. * @author David Sugar */ template class locked_pointer : public LockedPointer { public: /** * Create an instance of a typed locked pointer. */ inline locked_pointer() : LockedPointer() {}; /** * Create a duplicate reference counted instance of the current typed * object. * @return duplicate reference counted typed object. */ inline T* dup(void) {return static_cast(LockedPointer::dup());}; /** * Replace existing typed object with a new one for next request. * @param object to register with pointer. */ inline void replace(T *object) {LockedPointer::replace(object);}; /** * Replace existing object through assignment. * @param object to assign. */ inline void operator=(T *object) {replace(object);}; /** * Create a duplicate reference counted instance of the current typed * object by pointer reference. * @return duplicate reference counted typed object. */ inline T *operator*() {return dup();}; }; /** * A templated smart pointer instance for lock protected objects. * This is used to reference an instance of a typed locked_pointer. * @author David Sugar */ template class locked_instance : public locked_release { public: /** * Construct empty locked instance of typed object. */ inline locked_instance() : locked_release() {}; /** * Construct locked instance of typed object from matching locked_pointer. * @param pointer to get instance from. */ inline locked_instance(locked_pointer &pointer) : locked_release(pointer) {}; /** * Extract instance of locked typed object by pointer reference. * @return instance of typed object. */ inline T& operator*() const {return *(static_cast(object));}; /** * Access member of instance of locked typed object by member reference. * @return instance of typed object. */ inline T* operator->() const {return static_cast(object);}; /** * Get pointer to instance of locked typed object. * @return instance of typed object. */ inline T* get(void) const {return static_cast(object);}; }; /** * A templated smart pointer instance for shared singleton typed objects. * This is used to access the shared lock instance of the singleton. * @author David Sugar */ template class shared_instance : public shared_release { public: /** * Construct empty instance to reference shared typed singleton. */ inline shared_instance() : shared_release() {}; /** * Construct shared access instance of shared typed singleton from matching * shared_pointer. * @param pointer to get instance from. */ inline shared_instance(shared_pointer &pointer) : shared_release(pointer) {}; /** * Access shared typed singleton object this instance locks and references. */ inline const T& operator*() const {return *(static_cast(ptr->pointer));}; /** * Access member of shared typed singleton object this instance locks and * references. */ inline const T* operator->() const {return static_cast(ptr->pointer);}; /** * Access pointer to typed singleton object this instance locks and * references. */ inline const T* get(void) const {return static_cast(ptr->pointer);}; }; /** * Typed smart locked pointer class. This is used to manage references to * objects which are protected by an auto-generated mutex. The mutex is * released when the pointer falls out of scope. * @author David Sugar */ template class mutex_pointer : public auto_protect { public: /** * Create a pointer with no reference. */ inline mutex_pointer() : auto_protect() {}; /** * Create a pointer with a reference to a heap object. * @param object we are referencing. */ inline mutex_pointer(T* object) : auto_protect(object) {}; /** * Reference object we are pointing to through pointer indirection. * @return object we are pointing to. */ inline T& operator*() const {return *(static_cast(auto_protect::object));}; /** * Reference member of object we are pointing to. * @return reference to member of pointed object. */ inline T* operator->() const {return static_cast(auto_protect::object);}; /** * Get pointer to object. * @return pointer or NULL if we are not referencing an object. */ inline T* get(void) const {return static_cast(auto_protect::object);}; }; /** * Convenience function to start a joinable thread. * @param thread to start. * @param priority of thread. */ inline void start(JoinableThread *thread, int priority = 0) {thread->start(priority);} /** * Convenience function to start a detached thread. * @param thread to start. * @param priority of thread. */ inline void start(DetachedThread *thread, int priority = 0) {thread->start(priority);} /** * Convenience type for using conditional locks. */ typedef ConditionalLock condlock_t; /** * Convenience type for scheduling access. */ typedef ConditionalAccess accesslock_t; /** * Convenience type for using timed events. */ typedef TimedEvent timedevent_t; /** * Convenience type for using exclusive mutex locks. */ typedef Mutex mutex_t; /** * Convenience type for using read/write locks. */ typedef ThreadLock rwlock_t; /** * Convenience type for using recursive exclusive locks. */ typedef RecursiveMutex rexlock_t; /** * Convenience type for using counting semaphores. */ typedef Semaphore semaphore_t; /** * Convenience type for using thread barriers. */ typedef barrier barrier_t; /** * Convenience function to wait on a barrier. * @param barrier to wait. */ inline void wait(barrier_t &barrier) {barrier.wait();} /** * Convenience function to wait on a semaphore. * @param semaphore to wait on. * @param timeout to wait for. */ inline void wait(semaphore_t &semaphore, timeout_t timeout = Timer::inf) {semaphore.wait(timeout);} /** * Convenience function to release a semaphore. * @param semaphore to release. */ inline void release(semaphore_t &semaphore) {semaphore.release();} /** * Convenience function to acquire a mutex. * @param mutex to acquire. */ inline void acquire(mutex_t &mutex) {mutex.lock();} /** * Convenience function to release a mutex. * @param mutex to release. */ inline void release(mutex_t &mutex) {mutex.release();} /** * Convenience function to exclusively schedule conditional access. * @param lock to make exclusive. */ inline void modify(accesslock_t &lock) {lock.modify();} /** * Convenience function to shared read schedule conditional access. * @param lock to access shared. */ inline void access(accesslock_t &lock) {lock.access();} /** * Convenience function to release an access lock. * @param lock to release. */ inline void release(accesslock_t &lock) {lock.release();} /** * Convenience function to commit an exclusive access lock. * lock. * @param lock to commit. */ inline void commit(accesslock_t &lock) {lock.commit();} /** * Convenience function to exclusively lock shared conditional lock. * @param lock to make exclusive. */ inline void exclusive(condlock_t &lock) {lock.exclusive();} /** * Convenience function to restore shared access on a conditional lock. * @param lock to make shared. */ inline void share(condlock_t &lock) {lock.share();} /** * Convenience function to exclusively aquire a conditional lock. * @param lock to acquire for modify. */ inline void modify(condlock_t &lock) {lock.modify();} /** * Convenience function to commit and release an exclusively locked conditional * lock. * @param lock to commit. */ inline void commit(condlock_t &lock) {lock.commit();} /** * Convenience function for shared access to a conditional lock. * @param lock to access. */ inline void access(condlock_t &lock) {lock.access();} /** * Convenience function to release shared access to a conditional lock. * @param lock to release. */ inline void release(condlock_t &lock) {lock.release();} /** * Convenience function for exclusive write access to a read/write lock. * @param lock to write lock. * @param timeout to wait for exclusive locking. */ inline bool exclusive(rwlock_t &lock, timeout_t timeout = Timer::inf) {return lock.modify(timeout);} /** * Convenience function for shared read access to a read/write lock. * @param lock to share read lock. * @param timeout to wait for shared access. */ inline bool share(rwlock_t &lock, timeout_t timeout = Timer::inf) {return lock.access(timeout);} /** * Convenience function to release a shared lock. * @param lock to release. */ inline void release(rwlock_t &lock) {lock.release();} /** * Convenience function to lock a shared recursive mutex lock. * @param lock to acquire. */ inline void lock(rexlock_t &lock) {lock.lock();} /** * Convenience function to release a shared recursive mutex lock. * @param lock to release. */ inline void release(rexlock_t &lock) {lock.release();} inline bool _sync_protect_(const void *obj) { Mutex::protect(obj); return true; } inline bool _sync_release_(const void *obj) { Mutex::release(obj); return false; } inline bool _rw_reader_(const void *obj) { ThreadLock::reader(obj); return true; } inline bool _rw_writer_(const void *obj) { ThreadLock::writer(obj); return true; } inline bool _rw_release_(const void *obj) { ThreadLock::release(obj); return false; } #define ENTER_EXCLUSIVE \ do { static pthread_mutex_t __sync__ = PTHREAD_MUTEX_INITIALIZER; \ pthread_mutex_lock(&__sync__); #define LEAVE_EXCLUSIVE \ pthread_mutex_unlock(&__sync__);} while(0); #define SYNC(obj) for(bool _sync_flag_ = _sync_protect_(obj); _sync_flag_; _sync_flag_ = _sync_release_(obj)) #define SHARED(obj) for(bool _sync_flag_ = _rw_reader_(obj); _sync_flag_; _sync_flag_ = _rw_release_(obj)) #define EXCLUSIVE(obj) for(bool _sync_flag_ = _rw_writer_(obj); _sync_flag_; _sync_flag_ = _rw_release_(obj)) END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/stream.h0000644000175000017500000003070112163025062014012 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Any ucommon streaming classes that are built from std::streamio facilities * and that support ANSI C++ stream operators. * @file ucommon/stream.h */ #if defined(OLD_STDCPP) || defined(NEW_STDCPP) #ifndef _UCOMMON_STREAM_H_ #define _UCOMMON_STREAM_H_ #ifndef _UCOMMON_CONFIG_H #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_THREAD_H_ #include #endif #ifndef _UCOMMON_SOCKET_H_ #include #endif #ifndef _UCOMMON_FSYS_H_ #include #endif #ifndef _UCOMMON_SHELL_H_ #include #endif #include NAMESPACE_UCOMMON /** * Common stream buffer for std C++ i/o classes. This both binds the * character protocol to iostream and offers a common base class for all * other c++ stdlib based streaming classes. * @author David Sugar */ class __EXPORT StreamBuffer : protected std::streambuf, public std::iostream { protected: size_t bufsize; char *gbuf, *pbuf; StreamBuffer(); /** * This streambuf method is used for doing unbuffered reads * through the establish tcp socket connection when in interactive mode. * Also this method will handle proper use of buffers if not in * interactive mode. * * @return char from tcp socket connection, EOF if not connected. */ int uflow(); void release(void); void allocate(size_t size); public: /** * Flush the stream input and output buffers, writes pending output. * @return 0 on success, or error code. */ int sync(void); inline bool is_open(void) {return bufsize > 0;} inline operator bool() {return bufsize > 0;} inline bool operator!() {return bufsize == 0;} }; /** * Streamable tcp connection between client and server. The tcp stream * class can represent a client connection to a server or an instance of * a service generated by a tcp listener. As a stream class, data can * be manipulated using the << and >> operators. * * @author David Sugar */ class __EXPORT tcpstream : public StreamBuffer { private: __LOCAL void allocate(unsigned size); __LOCAL void reset(void); protected: socket_t so; timeout_t timeout; virtual ssize_t _read(char *buffer, size_t size); virtual ssize_t _write(const char *buffer, size_t size); virtual bool _wait(void); /** * Release the tcp stream and destroy the underlying socket. */ void release(void); /** * This streambuf method is used to load the input buffer * through the established tcp socket connection. * * @return char from get buffer, EOF if not connected. */ int underflow(void); /** * This streambuf method is used to write the output * buffer through the established tcp connection. * @param ch char to push through. * @return char pushed through. */ int overflow(int ch); inline socket_t getsocket(void) const {return so;} public: /** * Copy constructor... * @param copy for object. */ tcpstream(const tcpstream& copy); /** * Create a stream from an existing tcp listener. * @param server to accept connection from. * @param segsize for tcp segments and buffering. * @param timeout for socket i/o operations. */ tcpstream(const TCPServer *server, unsigned segsize = 536, timeout_t timeout = 0); /** * Create an unconnected tcp stream object that is idle until opened. * @param family of protocol to create. * @param timeout for socket i/o operations. */ tcpstream(int family = PF_INET, timeout_t timeout = 0); /** * A convenience constructor that creates a connected tcp stream directly * from an address. The socket is constructed to match the type of the * the address family in the socket address that is passed. * @param address of service to connect to. * @param segsize for tcp segments and buffering. * @param timeout for socket i/o operations. */ tcpstream(Socket::address& address, unsigned segsize = 536, timeout_t timeout = 0); /** * Destroy a tcp stream. */ virtual ~tcpstream(); /** * See if stream connection is active. * @return true if stream is active. */ inline operator bool() const {return so != INVALID_SOCKET && bufsize > 0;}; /** * See if stream is disconnected. * @return true if stream disconnected. */ inline bool operator!() const {return so == INVALID_SOCKET || bufsize == 0;}; /** * Open a stream connection to a tcp service. * @param address of service to access. * @param segment buffering size to use. */ void open(Socket::address& address, unsigned segment = 536); /** * Open a stream connectoion to a host and service. * @param host to connect to. * @param service to connect to by name or number as string. * @param segment buffering size to use. */ void open(const char *host, const char *service, unsigned segment = 536); /** * Close an active stream connection. This does not release the * socket but is a disconnect. */ void close(void); }; /** * Streamable tcp connection between client and server. The tcp stream * class can represent a client connection to a server or an instance of * a service generated by a tcp listener. As a stream class, data can * be manipulated using the << and >> operators. * * @author David Sugar */ class __EXPORT pipestream : public StreamBuffer { public: typedef enum { RDONLY, WRONLY, RDWR } access_t; private: __LOCAL void allocate(size_t size, access_t mode); protected: fsys_t rd, wr; shell::pid_t pid; /** * Release the stream, detach/do not wait for the process. */ void release(void); /** * This streambuf method is used to load the input buffer * through the established pipe connection. * * @return char from get buffer, EOF if not connected. */ int underflow(void); /** * This streambuf method is used to write the output * buffer through the established pipe connection. * * @param ch char to push through. * @return char pushed through. */ int overflow(int ch); public: /** * Create an unopened pipe stream. */ pipestream(); /** * Create child process and start pipe. * @param path to execute. * @param access mode of pipe stream. * @param args to pass to command. * @param env to create in child. * @param size of buffer. */ pipestream(const char *command, access_t access, char **args, char **env = NULL, size_t size = 512); /** * Destroy a pipe stream. */ virtual ~pipestream(); /** * See if stream connection is active. * @return true if stream is active. */ inline operator bool() const {return (bufsize > 0);}; /** * See if stream is disconnected. * @return true if stream disconnected. */ inline bool operator!() const {return bufsize == 0;}; /** * Open a stream connection to a pipe service. * @param path to execute. * @param access mode of stream. * @param args to pass to command. * @param env to create in child process. * @param buffering size to use. */ void open(const char *path, access_t access, char **args, char **env = NULL, size_t buffering = 512); /** * Close an active stream connection. This waits for the child to * terminate. */ int close(void); /** * Force terminate child and close. */ void terminate(void); inline void cancel(void) {terminate();} }; /** * Streamable tcp connection between client and server. The tcp stream * class can represent a client connection to a server or an instance of * a service generated by a tcp listener. As a stream class, data can * be manipulated using the << and >> operators. * * @author David Sugar */ class __EXPORT filestream : public StreamBuffer { public: typedef enum { RDONLY, WRONLY, RDWR } access_t; private: __LOCAL void allocate(size_t size, fsys::access_t mode); protected: fsys_t fd; fsys::access_t ac; /** * This streambuf method is used to load the input buffer * through the established pipe connection. * * @return char from get buffer, EOF if not connected. */ int underflow(void); /** * This streambuf method is used to write the output * buffer through the established pipe connection. * * @param ch char to push through. * @return char pushed through. */ int overflow(int ch); public: /** * Create an unopened pipe stream. */ filestream(); /** * Create duplicate stream. */ filestream(const filestream& copy); /** * Create and open a file stream. */ filestream(const char *path, unsigned mode, fsys::access_t access, size_t bufsize = 512); /** * Open file stream. */ filestream(const char *path, fsys::access_t access, size_t bufsize = 512); /** * Destroy a file stream. */ virtual ~filestream(); /** * See if stream connection is active. * @return true if stream is active. */ inline operator bool() const {return (bufsize > 0);}; /** * See if stream is disconnected. * @return true if stream disconnected. */ inline bool operator!() const {return bufsize == 0;}; /** * Open a stream connection to a tcp service. */ void open(const char *filename, fsys::access_t access, size_t buffering = 512); /** * Create a stream connection to a tcp service. */ void open(const char *filename, unsigned mode, fsys::access_t access, size_t buffering = 512); /** * Close an active stream connection. */ void close(void); /** * Seek position. */ void seek(fsys::offset_t offset); /** * Get error flag from last i/o operation. * @return last error. */ inline int err(void) const {return fd.err();}; }; /** * At least with gcc, linking of stream operators was broken. This provides * an auxillory class to solve the issue. */ class __EXPORT _stream_operators { private: inline _stream_operators() {}; public: static std::ostream& print(std::ostream& out, const PrintProtocol& format); static std::istream& input(std::istream& inp, InputProtocol& format); static std::ostream& print(std::ostream& out, const string_t& str); static std::istream& input(std::istream& inp, string_t& str); static std::ostream& print(std::ostream& out, const stringlist_t& list); static std::istream& input(std::istream& in, stringlist_t& list); }; inline std::ostream& operator<< (std::ostream& out, const PrintProtocol& format) {return _stream_operators::print(out, format);} inline std::istream& operator>> (std::istream& inp, InputProtocol& format) {return _stream_operators::input(inp, format);} inline std::ostream& operator<< (std::ostream& out, const string_t& str) {return _stream_operators::print(out, str);} inline std::istream& operator>> (std::istream& inp, string_t& str) {return _stream_operators::input(inp, str);} inline std::ostream& operator<< (std::ostream& out, const stringlist_t& list) {return _stream_operators::print(out, list);} inline std::istream& operator>> (std::istream& in, stringlist_t& list) {return _stream_operators::input(in, list);} END_NAMESPACE #endif #endif ucommon-6.0.7/inc/ucommon/timers.h0000644000175000017500000002612512163025062014027 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Realtime timers and timer queues. * This offers ucommon support for realtime high-resolution threadsafe * timers and timer queues. Threads may be scheduled by timers and timer * queues may be used to inject timer events into callback objects or through * virtuals. * @file ucommon/timers.h */ #ifndef _UCOMMON_TIMERS_H_ #define _UCOMMON_TIMERS_H_ #ifndef _UCOMMON_LINKED_H_ #include #endif #ifndef _MSWINDOWS_ #include #include #endif #include NAMESPACE_UCOMMON /** * Timer class to use when scheduling realtime events. The timer generally * uses millisecond values but has a microsecond accuracy. On platforms that * support it, the timer uses posix realtime monotonic clock extensions, * otherwise lower accuracy timer systems might be used. */ class __EXPORT Timer { private: friend class Conditional; friend class Semaphore; friend class Event; #if _POSIX_TIMERS > 0 && defined(POSIX_TIMERS) timespec timer; #else #undef POSIX_TIMERS // make sure not used if no support timeval timer; #endif bool updated; protected: /** * Check if timer has been updated since last check. * @return true if updated. */ bool update(void); /** * Check if timer active. * @return true if active. */ bool is_active(void); public: #if _MSC_VER > 1400 // windows broken dll linkage issue... static const timeout_t inf = ((timeout_t)(-1)); static const time_t reset = ((time_t)(0)); #else static const timeout_t inf; /**< A value to use for infinite time */ static const time_t reset; /**< A value to use when resetting */ #endif #ifdef _MSWINDOWS_ typedef unsigned __int64 tick_t; #else typedef uint64_t tick_t; #endif /** * Construct an untriggered timer set to the time of creation. */ Timer(); /** * Construct a triggered timer that expires at specified offset. * @param offset to expire in milliseconds. */ Timer(timeout_t offset); /** * Construct a triggered timer that expires at specified offset. * @param offset to expire in seconds. */ Timer(time_t offset); /** * Construct a timer from a copy of another timer. * @param copy of timer to construct from. */ Timer(const Timer& copy); /** * Set the timer to expire. * @param expire time in milliseconds. */ void set(timeout_t expire); /** * Set the timer to expire. * @param expire time in seconds. */ void set(time_t expire); /** * Set (update) the timer with current time. */ void set(void); /** * Clear pending timer, has no value. */ void clear(void); /** * Get remaining time until the timer expires. * @return 0 if expired or milliseconds still waiting. */ timeout_t get(void) const; /** * Get remaining time until timer expires by reference. * @return 0 if expired or milliseconds still waiting. */ inline timeout_t operator*() const {return get();}; /** * Check if timer has expired. * @return true if timer still pending. */ bool operator!() const; /** * Check if timer expired for is() expression. * @return true if timer expired. */ operator bool() const; /** * Set timer expiration. * @param expire timer in specified seconds. */ Timer& operator=(time_t expire); /** * Set timer expiration. * @param expire timer in milliseconds. */ Timer& operator=(timeout_t expire); /** * Adjust timer expiration. * @param expire time to add in seconds. */ Timer& operator+=(time_t expire); /** * Adjust timer expiration. * @param expire time to add in milliseconds. */ Timer& operator+=(timeout_t expire); /** * Adjust timer expiration. * @param expire time to subtract in seconds. */ Timer& operator-=(time_t expire); /** * Adjust timer expiration. * @param expire time to subtract in milliseconds. */ Timer& operator-=(timeout_t expire); /** * Compute difference between two timers. * @param timer to use for difference. * @return difference in milliseconds. */ timeout_t operator-(const Timer& timer); /** * Compare timers if same timeout. * @param timer to compare with. * @return true if same. */ bool operator==(const Timer& timer) const; /** * Compare timers if not same timeout. * @param timer to compare with. * @return true if not same. */ bool operator!=(const Timer& timer) const; /** * Compare timers if earlier timeout than another timer. * @param timer to compare with. * @return true if earlier. */ bool operator<(const Timer& timer) const; /** * Compare timers if earlier than or equal to another timer. * @param timer to compare with. * @return true if earlier or same. */ bool operator<=(const Timer& timer) const; /** * Compare timers if later timeout than another timer. * @param timer to compare with. * @return true if later. */ bool operator>(const Timer& timer) const; /** * Compare timers if later than or equal to another timer. * @param timer to compare with. * @return true if later or same. */ bool operator>=(const Timer& timer) const; /** * Sleep current thread until the specified timer expires. * @param timer to reference for sleep. */ static void sync(Timer &timer); /** * Get timer ticks since uuid epoch. * @return timer ticks in 100ns resolution. */ static tick_t ticks(void); }; /** * A timer queue for timer events. The timer queue is used to hold a * linked list of timers that must be processed together. The timer * queue processes the timer event list and calls an expired function * on events that have expired. The timer queue also determines the * wait time until the next timer will expire. When timer events are * modified, they can retrigger the queue to re-examine the list to * find when the next timer will now expire. * @author David Sugar */ class __EXPORT TimerQueue : public OrderedIndex { public: /** * A timer event object that lives on a timer queue. Timer events are * triggered through the timer queue's expire method. Timer events * also modify the queue when they are changed, particularly to force * re-evaluation of the expiration period. This class is not used by * itself but rather as a base class for a timer event object. * @author David Sugar */ class __EXPORT event : protected Timer, public LinkedList { protected: friend class TimerQueue; /** * Construct a timer event object and initially arm. * @param expire timer in specified milliseconds. */ event(timeout_t expire); /** * Construct an armed timer event object and attach to queue. * @param queue to add event to. * @param expire timer in specified milliseconds. */ event(TimerQueue *queue, timeout_t expire); /** * Event method to call in derived class when timer expires. */ virtual void expired(void) = 0; /** * Expected next timeout for the timer. This may be overriden * for strategy purposes when evaluted by timer queue's expire. * @return milliseconds until timer next triggers. */ virtual timeout_t timeout(void); public: /** * Detaches from queue when destroyed. */ virtual ~event(); /** * Attach event to a timer queue. Detaches from previous list if * already attached elsewhere. * @param queue to attach to. */ void attach(TimerQueue *queue); /** * Detach event from a timer queue. */ void detach(void); /** * Arm event to trigger at specified timeout. * @param timeout to expire and trigger. */ void arm(timeout_t timeout); /** * Disarm event. */ void disarm(void); /** * Time remaining until expired. * @return milliseconds until timer expires. */ inline timeout_t get(void) const {return Timer::get();}; /** * Notify timer queue that the timer has been updated. */ void update(void); /** * Get the timer queue we are attached to. * @return timer queue or NULL if not attached. */ inline TimerQueue *list(void) {return static_cast(Root);}; }; protected: friend class event; /** * Called in derived class when the queue is being modified. * This is often used to lock the list. */ virtual void modify(void) = 0; /** * Called in derived class after the queue has been modified. This often * releases a lock that modify set and to wakeup a timer thread to * evaluate when the next timer will now expire. */ virtual void update(void) = 0; public: /** * Create an empty timer queue. */ TimerQueue(); /** * Destroy queue, does not remove event objects. */ virtual ~TimerQueue(); /** * Add a timer event to the timer queue. * @param timer event to add. */ void operator+=(event &timer); /** * Remove a timer event from the timer queue. * @param timer event to remove. */ void operator-=(event &timer); /** * Process timer queue and find when next event triggers. This function * will call the expired methods on expired timers. Normally this function * will be called in the context of a timer thread which sleeps for the * timeout returned unless it is awoken on an update event. * @return timeout until next timer expires in milliseconds. */ timeout_t expire(); }; /** * A convenience type for timer queue timer events. */ typedef TimerQueue::event TQEvent; /** * A convenience type for timers. */ typedef Timer timer_t; END_NAMESPACE extern "C" { #if defined(WIN32) __EXPORT int gettimeofday(struct timeval *tv, void *tz); #endif } #endif ucommon-6.0.7/inc/ucommon/datetime.h0000644000175000017500000006255312163025062014325 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Basic classes for manipulating time and date based data, particularly * that may be in strings. * @file ucommon/datetime.h */ /** * Example of date & time manipulation. * @example datetime.cpp */ #ifndef _UCOMMON_DATETIME_H_ #define _UCOMMON_DATETIME_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_NUMBERS_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _MSWINDOWS_ #include #include #endif #include #define DATE_STRING_SIZE 10 #define DATE_BUFFER_SIZE 11 #define TIME_STRING_SIZE 8 #define TIME_BUFFER_SIZE 9 #define DATETIME_STRING_SIZE 19 #define DATETIME_BUFFER_SIZE 20 /** * Convenience type for struct tm. */ typedef struct tm tm_t; NAMESPACE_UCOMMON #ifdef __BORLANDC__ using std::tm; using std::time_t; #endif /** * The Date class uses a julian date representation of the current * year, month, and day. This is then manipulated in several forms * and may be exported as needed. * * @author David Sugar * @short julian number based date class. */ class __EXPORT Date { protected: long julian; void set(long year, long month, long day); /** * A method to use to "post" any changed values when shadowing * a mixed object class. This is used by DateNumber and string classes. */ virtual void update(void); public: /** * Size of date string field. */ static const size_t sz_string; /** * Create a julian date from a time_t type. * @param value from time() */ Date(time_t value); /** * Create a julian date from a local or gmt date and time. * @param object from DateTime::glt() or gmt(). */ Date(struct tm *object); /** * Create a julian date from a ISO date string of a specified size. * @param pointer to ISO date string. * @param size of date field if not null terminated. */ Date(const char *pointer, size_t size = 0); /** * Create a julian date from an arbitrary year, month, and day. * @param year of date. * @param month of date (1-12). * @param day of month (1-31). */ Date(int year, unsigned month, unsigned day); /** * Create a julian date object from another object. * @param object to copy. */ Date(const Date& object); /** * Construct a new julian date with today's date. */ Date(); /** * Destroy julian date object. */ virtual ~Date(); /** * Get the year of the date. * @return year of the date */ int year(void) const; /** * Get the month of the date (1-12). * @return month of year */ unsigned month(void) const; /** * Get the day of the month of the date. * @return day of month */ unsigned day(void) const; /** * Get the day of the week (0-7). * @return day of week */ unsigned dow(void) const; /** * Get a ISO string representation of the date (yyyy-mm-dd). * @param buffer to store string. * @return string representation. */ const char *put(char *buffer) const; /** * Get a time_t for the julian date if in time_t epoch. * @return time_t or -1 if out of range. */ time_t timeref(void) const; /** * Get the date as a number for the object or 0 if invalid. * @return date as number. */ long get(void) const; /** * Set (update) the date with current date. */ void set(void); /** * Set the julian date based on an ISO date string of specified size. * @param pointer to date string field. * @param size of field if not null terminated. */ void set(const char *pointer, size_t size = 0); /** * Check if date is valid. * @return true if julian date is valid. */ bool is_valid(void) const; /** * Casting operator to return date as number. * @return julian number. */ inline operator long() const {return get();}; /** * Access julian value. * @return julian number of object. */ inline long operator*() const {return get();}; /** * Expression operator to return an ISO date string for the current * julian date. * @return ISO date string. */ String operator()() const; /** * Increment date by one day. * @return instance of current date object. */ Date& operator++(); /** * Decrement date by one day. * @return instance of current date object. */ Date& operator--(); /** * Increment date by offset. * @param offset to add to julian date. * @return instance of current date object. */ Date& operator+=(long offset); /** * Decrement date by offset. * @param offset to subtract from julian date. * @return instance of current date object. */ Date& operator-=(long offset); /** * Add days to julian date in an expression. * @param days to add. * @return new date object with modified days. */ Date operator+(long days); /** * Subtract days from a julian date in an expression. * @param days to subtract. * @return new date object with modified days. */ Date operator-(long days); /** * Operator to compute number of days between two dates. * @param date offset for computation. * @return number of days difference. */ inline long operator-(const Date &date) {return (julian - date.julian);}; /** * Assign date from another date object. * @param date object to assign from. * @return current modified date object. */ Date& operator=(const Date& date); /** * Compare julian dates if same date. * @param date to compare with. * @return true if same. */ bool operator==(const Date& date) const; /** * Compare julian dates if not same date. * @param date to compare with. * @return true if not same. */ bool operator!=(const Date& date) const; /** * Compare julian date if earlier than another date. * @param date to compare with. * @return true if earlier. */ bool operator<(const Date& date) const; /** * Compare julian date if earlier than or equal to another date. * @param date to compare with. * @return true if earlier or same. */ bool operator<=(const Date& date) const; /** * Compare julian date if later than another date. * @param date to compare with. * @return true if later. */ bool operator>(const Date& date) const; /** * Compare julian date if later than or equal to another date. * @param date to compare with. * @return true if later or same. */ bool operator>=(const Date& date) const; /** * Check if julian date is not valid. * @return true if date is invalid. */ inline bool operator!() const {return !is_valid();}; /** * Check if julian date is valid for is() expression. * @return true if date is valid. */ inline operator bool() const {return is_valid();}; }; /** * The Time class uses a integer representation of the current * time. This is then manipulated in several forms and may be * exported as needed. The time object can represent an instance in * time (hours, minutes, and seconds) in a 24 hour period or can * represent a duration. Millisecond accuracy can be offered. * * @author Marcelo Dalmas and David Sugar * @short Integer based time class. */ class __EXPORT Time { protected: long seconds; protected: virtual void update(void); public: void set(int hour, int minute = 0, int second = 0); /** * Constant for number of seconds in a day. */ static const long c_day; /** * Constant for number of seconds in a hour. */ static const long c_hour; /** * Constant for number of seconds in a week. */ static const long c_week; /** * Size of time string field. */ static const size_t sz_string; /** * Create a time from the time portion of a time_t. * @param value of time_t to use. */ Time(time_t value); /** * Create a time from the time portion of a date and time object. * @param object from DateTime::glt() or gmt(). */ Time(tm_t *object); /** * Create a time from a hh:mm:ss formatted time string. * @param pointer to formatted time field. * @param size of field if not null terminated. */ Time(const char *pointer, size_t size = 0); /** * Create a time from hours (0-23), minutes (0-59), and seconds (0-59). * @param hour of time. * @param minute of time. * @param second of time. */ Time(int hour, int minute, int second); /** * Create a time object from another object. * @param object to copy. */ Time(const Time& object); /** * Create a time from current time. */ Time(); /** * Destroy time object. */ virtual ~Time(); /** * Get current time in seconds from midnight. * @return seconds from midnight. */ long get(void) const; /** * Get hours from midnight. * @return hours from midnight. */ int hour(void) const; /** * Get minutes from current hour. * @return minutes from current hour. */ int minute(void) const; /** * Get seconds from current minute. * @return seconds from current minute. */ int second(void) const; /** * Get a hh:mm:ss formatted string for current time. * @param buffer to store time string in. * @return time string buffer or NULL if invalid. */ const char *put(char *buffer) const; /** * Set (update) the time with current time. */ void set(void); /** * Set time from a hh:mm:ss formatted string. * @param pointer to time field. * @param size of field if not null terminated. */ void set(const char *pointer, size_t size = 0); /** * Check if time object had valid value. * @return true if object is valid. */ bool is_valid(void) const; /** * Check if time object has valid value for is() operator. * @return true if object is valid. */ inline operator bool() const {return is_valid();}; /** * Check if time object has valid value for ! operator. * @return true if object is not valid. */ inline bool operator!() const {return !is_valid();}; /** * Get difference (in seconds) between two times. * @param reference time to get difference from. * @return difference in seconds. */ long operator-(const Time &reference); /** * Add seconds to the current time, wrap if 24 hours. * @param seconds to add. * @return new time object with modified value. */ Time operator+(long seconds); /** * Subtract seconds to the current time, wrap if 24 hours. * @param seconds to subtract. * @return new time object with modified value. */ Time operator-(long seconds); /** * Get time in seconds. * @return seconds. */ inline operator long() {return get();}; /** * Get object time in seconds. * @return time in seconds. */ inline long operator*() const {return get();}; /** * Convert to standard 24 hour time string. * @return time string. */ String operator()() const; /** * Incrememnt time by 1 second, wrap on 24 hour period. * @return modified instance of current time object. */ Time& operator++(); /** * Decrement time by 1 second, wrap on 24 hour period. * @return modified instance of current time object. */ Time& operator--(); /** * Assign a time as a copy of another time. * @param time to assign from. * @return time object that was assigned. */ Time& operator=(const Time& time); /** * Increment time by specified seconds. Wraps on 24 hour period. * @param seconds to add to current time. * @return modified instance of current time object. */ Time& operator+=(long seconds); /** * Decrement time by specified seconds. Wraps on 24 hour period. * @param seconds to subtract from current time. * @return modified instance of current time object. */ Time& operator-=(long seconds); /** * Compare time with another time to see if same time. * @param time to compare with. * @return true if same time. */ bool operator==(const Time &time) const; /** * Compare time with another time to see if not same time. * @param time to compare with. * @return true if not same time. */ bool operator!=(const Time &time) const; /** * Compare time if earlier than another time. * @param time object to compare with. * @return true if earlier than object. */ bool operator<(const Time &time) const; /** * Compare time if earlier than or equal to another time. * @param time object to compare with. * @return true if earlier or same as object. */ bool operator<=(const Time &time) const; /** * Compare time if later than another time. * @param time object to compare with. * @return true if later than object. */ bool operator>(const Time &time) const; /** * Compare time if later than or equal to another time. * @param time object to compare with. * @return true if later than or same as object. */ bool operator>=(const Time &time) const; }; /** * The Datetime class uses a julian date representation of the current * year, month, and day and a integer representation of the current * time. This is then manipulated in several forms * and may be exported as needed. * * @author Marcelo Dalmas * @short Integer based time class. */ class __EXPORT DateTime : public Date, public Time { protected: void update(void); public: /** * Size of datetime string field. */ static const size_t sz_string; /** * Construct a date and time from C library time_t type. * @param time type to make date and time from. */ DateTime(time_t time); /** * Construct a date and time from C library time structure. * @param tm structure from C library (from glt or gmt). */ DateTime(tm_t *tm); /** * Construct a date and time from ISO string buffer. * @param pointer to string field holding date and time. * @param size of field if not null terminated string. */ DateTime(const char *pointer, size_t size = 0); /** * Construct a date and time object from explicit date and time values. * @param year of object. * @param month of object (1-12). * @param day of month of object (1-31). * @param hour of object (0-23). * @param minute of object (0-59). * @param second of object (0-59). */ DateTime(int year, unsigned month, unsigned day, int hour = 0, int minute = 0, int second = 0); /** * Create a datetime object from another object. * @param object to copy. */ DateTime(const DateTime& object); /** * Construct a new date and time object with current date and time. */ DateTime(); /** * Destroy date and time object. */ virtual ~DateTime(); /** * Get a ISO formatted date and time string for current object. * @param buffer to store date and time in (yyyy-mm-dd hh:mm:ss). * @return string buffer if object is valid. */ const char *put(char *buffer) const; /** * Get C library time_t type if object in C library epoch range. * @return time in seconds from epoch or ~0l if out of range. */ time_t get(void) const; /** * Test if object is valid. * @return true if object is valid. */ bool is_valid(void) const; /** * Operator to compute number of days between two dates. * @param datetime to offset from for computation. * @return number of days difference. */ long operator-(const DateTime &datetime); /** * Assign date and time from another datetime object. * @param datetime object to assign from. * @return assigned datetime object. */ DateTime& operator=(const DateTime& datetime); /** * Add seconds to the current datetime object. Day overflows update * julian date. * @param seconds to add to object. * @return modified datetime object. */ DateTime& operator+=(long seconds); /** * Subtract seconds from current datetime object. Day underflows * update julian date. * @param seconds to subtract from object. * @return modified datetime object. */ DateTime& operator-=(long seconds); /** * Add seconds to datetime in an expression. Day overflows update * julian date. * @param seconds to add to datetime. * @return new modified datetime object. */ DateTime operator+(long seconds); /** * Subtract seconds from datetime in an expression. Day underflows * update julian date. * @param seconds to subtract from datetime. * @return new modified datetime object. */ DateTime operator-(long seconds); /** * Add a day from the current date and time. * @return datetime object reference that was modified. */ DateTime& operator++(); /** * Subtract a day from the current date and time. * @return datetime object reference that was modified. */ DateTime& operator--(); /** * Compare date and time with another date and time to see if the same. * @param datetime to compare with. * @return true if equal. */ bool operator==(const DateTime& datetime) const; /** * Compare date and time with another date and time to see if not same. * @param datetime to compare with. * @return true if not equal. */ bool operator!=(const DateTime& datetime) const; /** * Compare date and time with another date and time to see if earlier. * @param datetime to compare with. * @return true if earlier. */ bool operator<(const DateTime& datetime) const; /** * Compare date and time with another date and time to see if earlier or * the same. * @param datetime to compare with. * @return true if earlier or equal. */ bool operator<=(const DateTime& datetime) const; /** * Compare date and time with another date and time to see if later. * @param datetime to compare with. * @return true if later. */ bool operator>(const DateTime& datetime) const; /** * Compare date and time with another date and time to see if later or * the same. * @param datetime to compare with. * @return true if later or equal. */ bool operator>=(const DateTime& datetime) const; /** * Check if date and time is not valid. * @return true if not valid. */ bool operator!() const; /** * Test is date and time is valid for is() operator. * @return true if object is valid. */ operator bool() const; /** * Casting operator to return date as number. * @return date as a number. */ inline operator long() const {return Date::get();}; /** * Set (update) the date and time with current date and time. */ void set(void); /** * Convert date and time to julian day number. * @return julian day number as a double. */ operator double() const; /** * Return date and time formatted using strftime format values. * @param strftime format to use. * @return String object with formatted time. */ String format(const char *strftime) const; /** * Fetch an instance of time converted to local time. If the localtime * abi is not re-entrant, than a lock is held, otherwise a unique * object is returned. In either case, when you are done, you must * release the object. * @param time object or NULL if using current time. * @return locked instance of struct tm object. */ static tm_t *local(time_t *time = NULL); /** * Fetch an instance of time converted to gmt. If the gmtime abi * is not re-entrant, than a lock is held, otherwise a unique * object is returned. In either case, when you are done, you must * release the object. * @param time object or NULL if using current time. * @return locked instance of struct tm object. */ static tm_t *gmt(time_t *time = NULL); /** * Release a struct tm object from glt or gmt. * @param object to release. */ static void release(tm_t *object); }; /** * A DateTime string class. This can be used to access the date and time * as a standard string without requiring an external buffer. * * @author David Sugar * @short a datetime class that returns strings. */ class __EXPORT DateTimeString : public DateTime { public: /** * Specify string buffer mode. By default we form a string with date * and time. */ typedef enum { DATE, TIME, BOTH} mode_t; private: char buffer[DATETIME_BUFFER_SIZE]; mode_t mode; protected: void update(void); public: /** * Construct a date and time from C libraray time_t type. * @param time type to make date and time from. */ DateTimeString(time_t time); /** * Construct a date and time from C library time structure. * @param tm structure from C library (from glt or gmt). */ DateTimeString(tm_t *tm); /** * Construct a date and time from ISO string buffer. * @param pointer to string field holding date and time. * @param size of field if not null terminated string. */ DateTimeString(const char *pointer, size_t size = 0); /** * Construct a date and time object from explicit date and time values. * @param year of object. * @param month of object (1-12). * @param day of month of object (1-31). * @param hour of object (0-23). * @param minute of object (0-59). * @param second of object (0-59). */ DateTimeString(int year, unsigned month, unsigned day, int hour = 0, int minute = 0, int second = 0); /** * Create a datetime object from another object. * @param object to copy. */ DateTimeString(const DateTimeString& object); /** * Construct a new date and time object with current date and time. */ DateTimeString(mode_t string = DateTimeString::BOTH); /** * Destroy date time string. */ virtual ~DateTimeString(); /** * Extract char from string. * * @return string of datetime. */ inline const char *c_str(void) {return buffer;}; /** * Cast to string. * * @return string of datetime. */ inline operator const char *(void) {return buffer;}; /** * Set (update) the date and time with current date and time. */ void set(void); /** * Set the string mode. * @param string mode to use. */ void set(mode_t string); }; /** * A number class that manipulates a string buffer that is also a date. * * @author David Sugar * @short a number that is also a date string. */ class __EXPORT DateNumber : public Number, public Date { protected: void update(void); public: /** * Create a date number tied to a refreshed string buffer. * @param pointer to string buffer to rewrite. */ DateNumber(char *pointer); /** * Release a datenumber object. */ virtual ~DateNumber(); /** * Set date number to current date. */ void set(void); }; class __EXPORT isotime : public PrintProtocol, public InputProtocol { private: Date *d; Time *t; enum {DATE, TIME, DATETIME} mode; char buf[32]; unsigned pos; protected: const char *_print(void) const; int _input(int code); public: isotime(Date& date, Time& time); isotime(Date& date); isotime(Time& time); }; /** * Convenience type for using DateTime object. */ typedef DateTime datetime_t; /** * Convenience type for using DateTimeString object. */ typedef DateTimeString datetimestring_t; /** * Convenience type for using Date object. */ typedef Date date_t; /** * Convenience type for using Time object. */ typedef Time tod_t; extern "C" { __EXPORT long tzoffset(struct timezone *tz = NULL); } END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/xml.h0000644000175000017500000001101112163025062013310 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * XML "SAX" (stream) parsing support from GNU Common C++. * @file ucommon/xml.h */ #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_XML_H_ #define _UCOMMON_XML_H_ NAMESPACE_UCOMMON /** * XML streaming parser. This class implements a basic XML stream parser * that can be used to examine an XML resource thru virtual I/O methods. * This class must be derived into one that can implement the physical I/O * required to parse actual data. A mixer class using XMLParser and * tcpstream would be one example of this. This can also be used to * parse xml content in memory buffers easily. This parser is only concerned * with well-formedness, and does not perform validation. * * @author David Sugar */ class __EXPORT XMLParser { private: int ecount, dcount; enum {TAG, CDATA, COMMENT, DTD, AMP, NONE, END} state; char *buffer; unsigned bufpos, bufsize; __LOCAL bool parseTag(void); __LOCAL void putBuffer(char c); __LOCAL void clearBuffer(void); protected: /** * Create xml parser. * @param size of XML data buffer. */ XMLParser(unsigned size = 8192); /** * Destroy xml parser. */ virtual ~XMLParser(); /** * Virtual to receive embedded comments in XML document being parsed. * @param text received. * @param size of text received. */ virtual void comment(caddr_t text, size_t size); /** * Virtual to receive character text extracted from the document. * @param text received. * @param size of text received. */ virtual void characters(caddr_t text, size_t size); /** * Notify start of document event. */ virtual void startDocument(void); /** * Notify end of document event. */ virtual void endDocument(void); /** * Notify start of an element in the document. * @param name of element found. * @param attr list of attributes extracted. */ virtual void startElement(caddr_t name, caddr_t *attr) = 0; /** * Notify end of an element in the document. * @param name of element ending. */ virtual void endElement(caddr_t name) = 0; /** * Parse a chunk of data and return parser completion flag. This is * used to externally drive data into the XML parser. The return * status can be used to determine when a document has been fully * parsed. This can be called multiple times to push stream data * into the parser. * @param address of data to parse. * @param size of data to parse. */ bool partial(const char *address, size_t size); /** * Parse a stream buffer and return parser document completion flag. * This is used to scan a stream buffer for a complete XML document. * The stream is scanned until the document is complete or EOF. * Multiple XML document instances can be scanned from a continues * XML streaming source. * @param stream buffer to parse. * @return true if parse complete, false if invalid or EOF. */ bool parse(CharacterProtocol& stream); /** * Parse a file buffer and return parser document completion flag. * This is used to scan a file buffer for a complete XML document. * The file is scanned until the document is complete or EOF. * Multiple XML document instances can be scanned from a continues * XML streaming source. * @param file buffer to parse. * @return true if parse complete, false if invalid or EOF. */ bool parse(FILE *file); /** * End of document check. * @return true if end of document. */ bool end(void) {return state == END;}; }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/file.h0000644000175000017500000001366412163025062013447 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Adaption of C runtime FILE processing. * @file ucommon/file.h */ #ifndef _UCOMMON_FILE_H_ #define _UCOMMON_FILE_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_THREAD_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif #ifndef _UCOMMON_MEMORY_H_ #include #endif #ifndef _UCOMMON_FSYS_H_ #include #endif #include NAMESPACE_UCOMMON /** * Access standard files through character protocol. This can also be * used as an alternative means to access files that manages file pointers. * @author David Sugar */ class __EXPORT file : public CharacterProtocol { private: FILE *fp; #ifdef _MSWINDOWS_ HANDLE pid; #else pid_t pid; #endif char *tmp; int _putch(int code); int _getch(void); public: typedef ::fpos_t bookmark_t; static file cin, cout, cerr; /** * Construct a file from an existing FILE pointer. * @param file to use. */ file(FILE *file); /** * Construct an open file based on a path and mode. * @param path of file to open. * @param mode of file. * @param size of buffer, 0 = none, 1 = line mode, 2 = default */ file(const char *path, const char *mode, size_t size = 2); /** * Construct an open file based on a pipe. * @param path of file to pipe. * @param argv of executable. * @param mode of file. * @param envp to give executable. */ file(const char *path, char **argv, const char *mode, char **envp = NULL); /** * Construct an unopened file. */ file(); /** * Destroy object and close associated file. */ ~file(); /** * Test if file is opened. * @return true if opened. */ inline operator bool() {return fp != NULL;} /** * Test if file is not opened. * @return true if not opened. */ inline bool operator !() {return fp == NULL;} inline operator FILE *() {return fp;} /** * Open file path. If a file is already opened, it is closed. * @param path of file to open. * @param mode of file to open. * @param size of buffering, 0 = none, 1 = line mode. */ void open(const char *path, const char *mode, size_t size = 2); /** * Open an executable path. * @param path of executable. * @param argv to pass to executable. * @param mode of pipe (only "r" and "w" are valid). */ void open(const char *path, char **argv, const char *mode, char **envp = NULL); /** * Close an open file. * @return process exit code if pipe. */ int close(void); /** * Clear error state. */ inline void clear(void) {if(fp) clearerr(fp);} /** * Check if file is good, no error or eof... * @return bool if file stream is good. */ bool good(void); /** * Cancel pipe and close file. * @return process exit code if pipe. */ int cancel(void); inline size_t put(const void *data, size_t size) { return fp == NULL ? 0 : fwrite(data, 1, size, fp);} inline size_t get(void *data, size_t size) { return fp == NULL ? 0 : fread(data, 1, size, fp);} inline int put(char value) { return fp == NULL ? EOF : fputc(value, fp);} inline int get(void) { return fp == NULL ? EOF : fgetc(fp);} inline int push(char value) { return fp == NULL ? EOF : ungetc(value, fp);} inline int puts(const char *data) { return fp == NULL ? 0 : fputs(data, fp);} inline char *gets(char *data, size_t size) { return fp == NULL ? NULL : fgets(data, size, fp);} template inline size_t read(T* data, size_t count) { return fp == NULL ? 0 : fread(data, sizeof(T), count, fp);} template inline size_t write(const T* data, size_t count) { return fp == NULL ? 0 : fwrite(data, sizeof(T), count, fp);} template inline size_t read(T& data) { return fp == NULL ? 0 : fread(data, sizeof(T), 1, fp);} template inline size_t write(const T& data) { return fp == NULL ? 0 : fwrite(data, sizeof(T), 1, fp);} inline void get(bookmark_t& pos) { if(fp) fsetpos(fp, &pos);} inline void set(bookmark_t& pos) { if(fp) fgetpos(fp, &pos);} int err(void) const; bool eof(void) const; template inline void offset(long pos) {if(fp) fseek(fp, sizeof(const T) * pos, SEEK_CUR);} inline void seek(long offset) {if(fp) fseek(fp, offset, SEEK_SET);} inline void move(long offset) {if(fp) fseek(fp, offset, SEEK_CUR);} inline void append(void) {if (fp) fseek(fp, 0l, SEEK_END);} inline void rewind(void) {if(fp) ::rewind(fp);} inline void flush(void) {if(fp) ::fflush(fp);} size_t printf(const char *format, ...) __PRINTF(2, 3); size_t scanf(const char *format, ...) __SCANF(2, 3); bool is_tty(void) const; }; /** * Convience type for file. */ typedef file file_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/export.h0000644000175000017500000000342212163025062014040 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Export interfaces for library interfaces. * This is a special header used when we have to build DLL's for dumb * platforms which require explicit declaration of imports and exports. * The real purpose is to include our local headers in a new library * module with external headers referenced as imports, and then to define * our own interfaces in our new library as exports. This allows native * construction of new DLL's based on/that use ucommon on Microsoft Windows * and perhaps for other similarly defective legacy platforms. Otherwise * this header is not used at all, and not when building applications. * @file ucommon/export.h */ #if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) #ifdef __EXPORT #undef __EXPORT #endif #ifdef __SHARED #undef __SHARED #endif #ifdef UCOMMON_STATIC #define __EXPORT #else #define __EXPORT __declspec(dllexport) #endif #if defined(UCOMMON_STATIC) || defined(UCOMMON_RUNTIME) #define __SHARED #else #define __SHARED __declspec(dllexport) #endif #endif ucommon-6.0.7/inc/ucommon/bitmap.h0000644000175000017500000001000612163025062013767 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * A simple class to perform bitmap manipulation. * Bitmaps are used to manage bit-aligned objects, such as network cidr * addresses. This header introduces a common bitmap management class * for the ucommon library. * @file ucommon/bitmap.h */ #ifndef _UCOMMON_BITMAP_H_ #define _UCOMMON_BITMAP_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif NAMESPACE_UCOMMON /** * A class to access bit fields in external bitmaps. The actual bitmap this * object manipulates may not be stored in the object. Bitmaps may be * referenced on special memory mapped or i/o bus based devices or other * structures that have varying data word sizes which may differ from the * default cpu bus size. The bitmap class can be set to the preferred memory * bus size of the specific external bitmap being used. Bitmap size may also * be relevant when accessing individual bits in memory mapped device registers * where performing reference and manipulations may change the state of the * device and hence must be aligned with the device register being effected. * * This class offers only the most basic bit manipulations, getting and * setting individual bits in the bitmap. More advanced bit manipulations * and other operations can be created in derived classes. * @author David Sugar */ class __EXPORT bitmap { protected: size_t size; typedef union { void *a; uint8_t *b; uint16_t *w; uint32_t *l; uint64_t *d; } addr_t; addr_t addr; public: /** * Specify data word size to use in accessing a bitmap. */ typedef enum { BMALLOC, /**< Use default cpu size */ B8, /**< Accessing a bitmap on 8 bit bus device */ B16, /**< Accessing a bitmap on a 16 bit device */ B32, /**< Accessing a bitmap on a 32 bit device */ B64, /**< Accessing a bitmap on a 64 bit device */ BMIN = BMALLOC, BMAX = B64 } bus_t; protected: bus_t bus; unsigned memsize(void) const; public: /** * Create an object to reference the specified bitmap. * @param addr of the bitmap in mapped memory. * @param length of the bitmap being accessed in bits. * @param size of the memory bus or manipulation to use. */ bitmap(void *addr, size_t length, bus_t size = B8); /** * Create a bitmap to manipulate locally. This bitmap is created * as part of the object itself, and uses the BMALLOC bus mode. * @param length of bitmap to create in bits. */ bitmap(size_t length); /** * Destroy bitmap manipulation object. If a bitmap was locally * created with the alternate constructor, that bitmap will also be * removed from memory. */ ~bitmap(); /** * Clear (zero) all the bits in the bitmap. */ void clear(void); /** * Get the value of a "bit" in the bitmap. * @param offset to bit in map to get. * @return true if bit is set. */ bool get(size_t offset) const; /** * Set an individual bit in the bitmask. * @param offset to bit in map to change. * @param value to change specified bit to. */ void set(size_t offset, bool value); }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/unicode.h0000644000175000017500000004012512163025062014146 00000000000000// Copyright (C) 2009-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Basic UCommon Unicode support. * This includes computing unicode transcoding and supporting a * UTF8-aware string class (UString). We may add support for a wchar_t * aware string class as well, as some external api libraries may require * ucs-2 or 4 encoded strings. * @file ucommon/unicode.h */ /** * An example of some unicode-utf8 transcoding. * @example unicode.cpp */ #ifndef _UCOMMON_UNICODE_H_ #define _UCOMMON_UNICODE_H_ #ifndef _UCOMMON_STRING_H_ #include #endif NAMESPACE_UCOMMON /** * 32 bit unicode character code. We may extract this from a ucs2 or utf8 * string. */ typedef int32_t ucs4_t; /** * 16 bit unicode character code. Java and some api's like these. */ typedef int16_t ucs2_t; /** * Resolves issues where wchar_t is not defined. */ typedef void *unicode_t; /** * A core class of ut8 encoded string functions. This is a foundation for * all utf8 string processing. * @author David Sugar */ class __EXPORT utf8 { public: /** * Size of "unicode_t" character codes, may not be ucs4_t size. */ static const unsigned ucsize; /** * A convenient NULL pointer value. */ static const char *nil; /** * Compute character size of utf8 string codepoint. * @param codepoint in string. * @return size of codepoint as utf8 encoded data, 0 if invalid. */ static unsigned size(const char *codepoint); /** * Count ut8 encoded ucs4 codepoints in string. * @param string of utf8 data. * @return codepount count, 0 if empty or invalid. */ static size_t count(const char *string); /** * Get codepoint offset in a string. * @param string of utf8 data. * @param position of codepoint in string, negative offsets are from tail. * @return offset of codepoint or NULL if invalid. */ static char *offset(char *string, ssize_t position); /** * Convert a utf8 encoded codepoint to a ucs4 character value. * @param encoded utf8 codepoint. * @return ucs4 string or 0 if invalid. */ static ucs4_t codepoint(const char *encoded); /** * How many chars requires to encode a given wchar string. * @param string of ucs4 data. * @return number of chars required to encode given string. */ static size_t chars(const unicode_t string); /** * How many chars requires to encode a given unicode character. * @param character to encode. * @return number of chars required to encode given character. */ static size_t chars(ucs4_t character); /** * Convert a unicode string into utf8. * @param string of unicode data to pack * @param buffer of character protocol to put data into. * @return number of code points converted. */ static size_t unpack(const unicode_t string, CharacterProtocol& buffer); /** * Convert a utf8 string into a unicode data buffer. * @param unicode data buffer. * @param buffer of character protocol to pack from. * @param size of unicode data buffer in codepoints. * @return number of code points converted. */ static size_t pack(unicode_t unicode, CharacterProtocol& buffer, size_t size); /** * Dup a utf8 string into a ucs4_t string. */ static ucs4_t *udup(const char *string); /** * Dup a utf8 string into a ucs2_t representation. */ static ucs2_t *wdup(const char *string); /** * Find first occurance of character in string. * @param string to search in. * @param character code to search for. * @param start offset in string in codepoints. * @return pointer to first instance or NULL if not found. */ static const char *find(const char *string, ucs4_t character, size_t start = 0); /** * Find last occurrence of character in string. * @param string to search in. * @param character code to search for. * @param end offset to start from in codepoints. * @return pointer to last instance or NULL if not found. */ static const char *rfind(const char *string, ucs4_t character, size_t end = (size_t)-1l); /** * Count occurrences of a unicode character in string. * @param string to search in. * @param character code to search for. * @return count of occurrences. */ static unsigned ccount(const char *string, ucs4_t character); /** * Get a unicode character from a character protocol. * @param buffer of character protocol to read from. * @return unicode character or EOF error. */ static ucs4_t get(CharacterProtocol& buffer); /** * Push a unicode character to a character protocol. * @param character to push to file. * @param buffer of character protocol to push character to. * @return unicode character or EOF on error. */ static ucs4_t put(ucs4_t character, CharacterProtocol& buffer); }; /** * A copy-on-write utf8 string class that operates by reference count. This * is derived from the classic uCommon String class by adding operations that * are utf8 encoding aware. * @author David Sugar */ class __EXPORT UString : public String, public utf8 { protected: /** * Create a new empty utf8 aware string object. */ UString(); /** * Create an empty string with a buffer pre-allocated to a specified size. * @param size of buffer to allocate. */ UString(strsize_t size); /** * Create a utf8 aware string for a null terminated unicode string. * @param text of ucs4 encoded data. */ UString(const unicode_t text); /** * Create a string from null terminated text up to a maximum specified * size. * @param text to use for string. * @param size limit of new string. */ UString(const char *text, strsize_t size); /** * Create a string for a substring. The end of the substring is a * pointer within the substring itself. * @param text to use for string. * @param end of text in substring. */ UString(const unicode_t *text, const unicode_t *end); /** * Construct a copy of a string object. Our copy inherits the same * reference counted instance of cstring as in the original. * @param existing string to copy from. */ UString(const UString& existing); /** * Destroy string. De-reference cstring. If last reference to cstring, * then also remove cstring from heap. */ virtual ~UString(); /** * Get a new string object as a substring of the current object. * @param codepoint offset of substring. * @param size of substring in codepoints or 0 if to end. * @return string object holding substring. */ UString get(strsize_t codepoint, strsize_t size = 0) const; /** * Extract a unicode byte sequence from utf8 object. * @param unicode data buffer. * @param size of data buffer. * @return codepoints copied. */ size_t get(unicode_t unicode, size_t size) const; /** * Set a utf8 encoded string based on unicode data. * @param unicode text to set. */ void set(const unicode_t unicode); /** * Add (append) unicode to a utf8 encoded string. * @param unicode text to add. */ void add(const unicode_t unicode); /** * Return unicode character found at a specific codepoint in the string. * @param position of codepoint in string, negative values computed from end. * @return character code at specified position in string. */ ucs4_t at(int position) const; /** * Extract a unicode byte sequence from utf8 object. * @param unicode data buffer. * @param size of data buffer. * @return codepoints copied. */ inline size_t operator()(unicode_t unicode, size_t size) const {return get(unicode, size);}; /** * Get a new substring through object expression. * @param codepoint offset of substring. * @param size of substring or 0 if to end. * @return string object holding substring. */ UString operator()(int codepoint, strsize_t size) const; /** * Convenience method for left of string. * @param size of substring to gather in codepoints. * @return string object holding substring. */ inline UString left(strsize_t size) const {return operator()(0, size);} /** * Convenience method for right of string. * @param offset of substring from right in codepoints. * @return string object holding substring. */ inline UString right(strsize_t offset) const {return operator()(-((int)offset), 0);} /** * Convenience method for substring extraction. * @param offset into string. * @param size of string to return. * @return string object holding substring. */ inline UString copy(strsize_t offset, strsize_t size) const {return operator()((int)offset, size);} /** * Cut (remove) text from string using codepoint offsets. * @param offset to start of text field to remove. * @param size of text field to remove or 0 to remove to end of string. */ void cut(strsize_t offset, strsize_t size = 0); /** * Insert (paste) text into string using codepoint offsets. * @param offset to start paste. * @param text to paste. * @param size of text to paste. */ void paste(strsize_t offset, const char *text, strsize_t size = 0); /** * Reference a string in the object by codepoint offset. Positive * offsets are from the start of the string, negative from the * end. * @param offset to string position. * @return pointer to string data or NULL if invalid offset. */ const char *operator()(int offset) const; /** * Reference a unicode character in string object by array offset. * @param position of codepoint offset to character. * @return character value at offset. */ inline ucs4_t operator[](int position) const {return UString::at(position);}; /** * Count codepoints in current string. * @return count of codepoints. */ inline strsize_t count(void) const {return utf8::count(str->text);} /** * Count occurrences of a unicode character in string. * @param character code to search for. * @return count of occurrences. */ unsigned ccount(ucs4_t character) const; /** * Find first occurrence of character in string. * @param character code to search for. * @param start offset in string in codepoints. * @return pointer to first instance or NULL if not found. */ const char *find(ucs4_t character, strsize_t start = 0) const; /** * Find last occurrence of character in string. * @param character code to search for. * @param end offset to start from in codepoints. * @return pointer to last instance or NULL if not found. */ const char *rfind(ucs4_t character, strsize_t end = npos) const; }; /** * Pointer to utf8 encoded character data. This is a kind of "char *" for * utf8 text. * @author David Sugar */ class __EXPORT utf8_pointer { protected: uint8_t *text; public: /** * Create a utf8 pointer set to NULL. */ utf8_pointer(); /** * Create a utf8 pointer for an existing char pointer. * @param string pointer to use. */ utf8_pointer(const char *string); /** * Create a utf8 pointer as a copy of existing utf8 pointer. * @param copy of object to use. */ utf8_pointer(const utf8_pointer& copy); /** * Iterative increment of a utf8 pointer to prior codepoint. * @return object incremented. */ utf8_pointer& operator ++(); /** * Iterative decrement of a utf8 pointer to next codepoint. * @return object decremented. */ utf8_pointer& operator --(); /** * Adjust utf8 pointer by specified codepoints forward. * @param offset to increment by. * @return object incremented. */ utf8_pointer& operator +=(long offset); /** * Adjust utf8 pointer by specified codepoints backward. * @param offset to decrement by. * @return object decremented. */ utf8_pointer& operator -=(long offset); /** * Get new utf8 string after adding a codepoint offset. * @param offset to add. * @return new utf8 pointer pointing to specified offset. */ utf8_pointer operator+(long offset) const; /** * Get new utf8 string after subtracting a codepoint offset. * @param offset to subtract. * @return new utf8 pointer pointing to specified offset. */ utf8_pointer operator-(long offset) const; /** * Check if text is valid pointer. * @return true if not NULL. */ inline operator bool() const {return text != NULL;}; /** * Check if text is an invalid pointer. * @return false if not NULL. */ inline bool operator!() const {return text == NULL;}; /** * Extract a unicode character from a specified codepoint. * @param codepoint offset to extract character from. * @return unicode character or 0. */ ucs4_t operator[](long codepoint) const; /** * Assign a utf8 string to point to. * @param string to point to. * @return current object after set to string. */ utf8_pointer& operator=(const char *string); /** * Iterative increment of a utf8 pointer to next codepoint. */ void inc(void); /** * Iterative decrement of a utf8 pointer to prior codepoint. */ void dec(void); /** * check if pointer equals another string. * @param string to check. * @return true if same memory address. */ inline bool operator==(const char *string) const {return (const char *)text == string;}; /** * check if pointer does not equal another string. * @param string to check. * @return false if same memory address. */ inline bool operator!=(const char *string) const {return (const char *)text != string;}; /** * Get unicode character pointed to by pointer. * @return unicode character we are pointing to. */ inline ucs4_t operator*() const {return utf8::codepoint((const char *)text);}; /** * Get c string we point to. * @return string we point to. */ inline char *c_str(void) const {return (char *)text;}; /** * Convert utf8 pointer to a generic string pointer. * @return generic string pointer. */ inline operator char*() const {return (char *)text;}; /** * Get length of null terminated utf8 string in codepoints. * @return codepoint length of string. */ inline size_t len(void) const {return utf8::count((const char *)text);}; }; inline ucs4_t *strudup(const char *string) {return utf8::udup(string);} inline ucs2_t *strwdup(const char *string) {return utf8::wdup(string);} __EXPORT unicode_t unidup(const char *string); template<> inline void dupfree(ucs2_t *string) {::free(string);} template<> inline void dupfree(ucs4_t *string) {::free(string);} template<> inline void dupfree(unicode_t string) {::free(string);} /** * Convenience type for utf8 encoded strings. */ typedef UString ustring_t; /** * Convenience type for utf8_pointer strings. */ typedef utf8_pointer utf8_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/atomic.h0000644000175000017500000000557112163025062014002 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Atomic pointers and locks. These are meant to use atomic CPU operations * and hence offer maximum performance. * @file ucommon/atomic.h * @author David Sugar */ #ifndef _UCOMMON_ATOMIC_H_ #define _UCOMMON_ATOMIC_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif NAMESPACE_UCOMMON /** * Generic atomic class for referencing atomic objects and static functions. * We have an atomic counter and spinlock, and in the future we may add * other atomic classes and atomic manipulations needed to create lockfree * data structures. The atomic classes use mutexes if no suitable atomic * code is available. * @author David Sugar */ class __EXPORT atomic { public: /** * Set to true if atomics have to be simulated with mutexes. */ static const bool simulated; /** * Atomic counter class. Can be used to manipulate value of an * atomic counter without requiring explicit thread locking. * @author David Sugar */ class __EXPORT counter { private: volatile long value; public: counter(long initial = 0); long operator++(); long operator--(); long operator+=(long offset); long operator-=(long offset); inline operator long() {return (long)(value);}; inline long operator*() {return value;}; }; /** * Atomic spinlock class. Used as high-performance sync lock between * threads. * @author David Sugar */ class __EXPORT spinlock { private: volatile long value; public: /** * Construct and initialize spinlock. */ spinlock(); /** * Acquire the lock. If the lock is not acquired, one "spins" * by doing something else. One suggestion is using thread::yield. * @return true if acquired. */ bool acquire(void); /** * Release an acquired spinlock. */ void release(void); }; }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/secure.h0000644000175000017500000006160612163025062014015 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * This library holds basic cryptographic functions and secure socket support * for use with GNU uCommon C++. This library might be used in conjunction * with openssl, gnutls, etc. If no secure socket library is available, then * a stub library may be used with very basic cryptographic support. * @file ucommon/secure.h */ /** * Example of SSL socket code. * @example ssl.cpp */ /** * Example of cryptographic digest code. * @example digest.cpp */ /** * Example of cipher code. * @example cipher.cpp */ #ifndef _UCOMMON_SECURE_H_ #define _UCOMMON_SECURE_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_UCOMMON_H_ #include #endif #define MAX_CIPHER_KEYSIZE 512 #define MAX_DIGEST_HASHSIZE 512 NAMESPACE_UCOMMON /** * Common secure socket support. This offers common routines needed for * secure/ssl socket support code. * @author David Sugar */ class __SHARED secure { public: /** * Different error states of the security context. */ typedef enum {OK=0, INVALID, MISSING_CERTIFICATE, MISSING_PRIVATEKEY, INVALID_CERTIFICATE, INVALID_AUTHORITY, INVALID_PEERNAME, INVALID_CIPHER} error_t; protected: /** * Last error flagged for this context. */ error_t error; inline secure() {error = OK;}; public: /** * This is derived in different back-end libraries, and will be used to * clear certificate credentials. */ virtual ~secure(); /** * Convenience type to represent a security context. */ typedef secure *client_t; typedef secure *server_t; /** * Convenience type to represent a secure socket session. */ typedef void *session_t; /** * Convenience type to represent a secure socket buf i/o stream. */ typedef void *bufio_t; /** * Initialize secure stack for first use, and report if SSL support is * compiled in. * @return true if ssl support is available, false if not. */ static bool init(void); /** * Initialize secure stack with fips support. If fips support is not * successfully enabled, the secure stack is also not initialized. Hence * init() can be used for non-fips certified operation if fips fails. * @return true if fips support enabled and stack initialized. */ static bool fips(void); /** * Copy system certificates to a local path. * @param path to copy to. * @return 0 or error number on failure. */ static int oscerts(const char *path); /** * Get path to system certificates. * @return path to system certificates. */ static const char *oscerts(void); /** * Verify a certificate chain through your certificate authority. * This uses the ca loaded as an optional argument for client and * server. Optionally the hostname of the connection can also be * verified by pulling the peer certificate. * @param session that is connected. * @param peername that we expect. * @return secure error level or secure::OK if none. */ static error_t verify(session_t session, const char *peername = NULL); /** * Create a sever context. The certificate file used will be based on * the init() method name. This may often be /etc/ssl/certs/initname.pem. * Similarly, a matching private key certificate will also be loaded. An * optional certificate authority document can be used when we are * establishing a service which ssl clients have their own certificates. * @param authority path to use or NULL if none. * @return a security context that is cast from derived library. */ static server_t server(const char *keyfile = NULL, const char *authority = NULL); /** * Create an anonymous client context with an optional authority to * validate. * @param authority path to use or NULL if none. * @return a basic client security context. */ static client_t client(const char *authority = NULL); /** * Create a peer user client context. This assumes a user certificate * in ~/.ssl/certs and the user private key in ~/.ssl/private. The * path to an authority is also sent. * @param authority path to use. */ static client_t user(const char *authority); /** * Assign a non-default cipher to the context. * @param context to set cipher for. * @param ciphers to set. */ static void cipher(secure *context, const char *ciphers); /** * Determine if the current security context is valid. * @return true if valid, -1 if not. */ inline bool is_valid(void) const {return error == OK;}; /** * Get last error code associated with the security context. * @return last error code or 0/OK if none. */ inline error_t err(void) {return error;}; /** * Create 36 character traditional version 1 uuid. * @param string to write uuid into, must be 37 bytes or more. */ static void uuid(char *string); static String uuid(void); template inline static void erase(T *object) {memset(object, 0, sizeof(object)); delete object;} inline operator bool() {return is_valid();} inline bool operator!() {return !is_valid();} }; /** * Secure socket buffer. This is used to create ssl socket connections * for both clients and servers. The use depends in part on the type of * context created and passed at construction time. If no context is * passed (NULL), then this reverts to TCPBuffer behavior. * @author David Sugar */ class __SHARED SSLBuffer : public TCPBuffer { protected: secure::session_t ssl; secure::bufio_t bio; bool server; bool verify; public: SSLBuffer(secure::client_t context); SSLBuffer(const TCPServer *server, secure::server_t context, size_t size = 536); ~SSLBuffer(); /** * Connect a ssl client session to a specific host uri. If the socket * was already connected, it is automatically closed first. * @param host we are connecting to. * @param service to connect to. * @param size of buffer and tcp fragments. */ void open(const char *host, const char *service, size_t size = 536); void close(void); void release(void); size_t _push(const char *address, size_t size); size_t _pull(char *address, size_t size); bool _flush(void); bool _pending(void); inline bool is_secure(void) {return bio != NULL;}; }; /** * A generic data ciphering class. This is used to construct cryptographic * ciphers to encode and decode data as needed. The cipher type is specified * by the key object. This class can be used to send output streaming to * memory or in a fixed size buffer. If the latter is used, a push() method * is called through a virtual when the buffer is full. Since block ciphers * are used, buffers should be aligned to the block size. * @author David Sugar */ class __SHARED Cipher { public: typedef enum {ENCRYPT = 1, DECRYPT = 0} mode_t; /** * Cipher key formed by hash algorithm. This can generate both a * key and iv table based on the algorithms used and required. Normally * it is used from a pass-phrase, though any block of data may be * supplied. * @author David Sugar */ class __SHARED Key { protected: friend class Cipher; union { const void *algotype; int algoid; }; union { const void *hashtype; int hashid; }; int modeid; // assume 512 bit cipher keys possible... unsigned char keybuf[MAX_CIPHER_KEYSIZE / 8], ivbuf[MAX_CIPHER_KEYSIZE / 8]; // generated keysize size_t keysize, blksize; Key(const char *cipher); Key(); void set(const char *cipher); void set(const char *cipher, const char *digest); void assign(const char *key, size_t size, const unsigned char *salt, unsigned rounds); public: Key(const char *cipher, const char *digest, const char *text, size_t size = 0, const unsigned char *salt = NULL, unsigned rounds = 1); Key(const char *cipher, const char *digest); ~Key(); void assign(const char *key, size_t size = 0); void clear(void); inline size_t size(void) {return keysize;}; inline size_t iosize(void) {return blksize;}; inline operator bool() {return keysize > 0;}; inline bool operator!() {return keysize == 0;}; inline Key& operator=(const char *pass) {assign(pass); return *this;}; static void options(const unsigned char *salt = NULL, unsigned rounds = 1); }; typedef Key *key_t; private: Key keys; size_t bufsize, bufpos; mode_t bufmode; unsigned char *bufaddr; void *context; protected: virtual void push(unsigned char *address, size_t size); void release(void); public: Cipher(); Cipher(key_t key, mode_t mode, unsigned char *address = NULL, size_t size = 0); virtual ~Cipher(); void set(unsigned char *address, size_t size = 0); void set(key_t key, mode_t mode, unsigned char *address, size_t size = 0); /** * Push a final cipher block. This is used to push the final buffer into * the push method for any remaining data. */ size_t flush(void); /** * Process cipher data. This requires the size to be a multiple of the * cipher block size. If an unaligned sized block of data is used, it * will be ignored and the size returned will be 0. * @param data to process. * @param size of data to process. * @return size of processed output, should be same as size or 0 if error. */ size_t put(const unsigned char *data, size_t size); /** * This essentially encrypts a single string and pads with NULL bytes * as needed. * @param string to encrypt. * @return total encrypted size. */ size_t puts(const char *string); /** * This is used to process any data unaligned to the blocksize at the end * of a cipher session. On an encryption, it will add padding or an * entire padding block with the number of bytes to strip. On decryption * it will remove padding at the end. The pkcs5 method of padding with * removal count is used. This also sets the address buffer to NULL * to prevent further puts until reset. * @param address of data to add before final pad. * @param size of data to add before final pad. * @return actual bytes encrypted or decrypted. */ size_t pad(const unsigned char *address, size_t size); /** * Process encrypted data in-place. This assumes no need to set the * address buffer. * @param address of data to process. * @param size of data to process. * @param flag if to pad data. * @return bytes processed and written back to buffer. */ size_t process(unsigned char *address, size_t size, bool flag = false); inline size_t size(void) {return bufsize;}; inline size_t pos(void) {return bufpos;}; inline size_t align(void) {return keys.iosize();}; /** * Check if a specific cipher is supported. * @param name of cipher to check. * @return true if supported, false if not. */ static bool has(const char *name); }; /** * A cryptographic digest class. This class can support md5 digests, sha1, * sha256, etc, depending on what the underlying library supports. The * hash class accumulates the hash in the object. * @author David Sugar */ class __SHARED Digest { private: void *context; union { const void *hashtype; int hashid; }; unsigned bufsize; unsigned char buffer[MAX_DIGEST_HASHSIZE / 8]; char textbuf[MAX_DIGEST_HASHSIZE / 8 + 1]; protected: void release(void); public: Digest(const char *type); Digest(); ~Digest(); inline bool puts(const char *str) {return put(str, strlen(str));}; inline Digest &operator<<(const char *str) {puts(str); return *this;} inline Digest &operator<<(int16_t value) {int16_t v = htons(value); put(&v, 2); return *this;} inline Digest &operator<<(int32_t value) {int32_t v = htonl(value); put(&v, 4); return *this;} inline Digest &operator<<(const PrintProtocol& p) {const char *cp = p._print(); if(cp) puts(cp); return *this;} bool put(const void *memory, size_t size); inline unsigned size() const {return bufsize;}; const unsigned char *get(void); const char *c_str(void); inline String str(void) {return String(c_str());}; inline operator String() {return String(c_str());}; void set(const char *id); inline void operator=(const char *id) {set(id);}; inline bool operator *=(const char *text) {return puts(text);}; inline bool operator +=(const char *text) {return puts(text);}; inline const char *operator*() {return c_str();}; inline bool operator!() const {return !bufsize && context == NULL;}; inline operator bool() const {return bufsize > 0 || context != NULL;}; /** * Finalize and recycle current digest to start a new * digest. * @param binary digest used rather than text if true. */ void recycle(bool binary = false); /** * Reset and restart digest object. */ void reset(void); /** * Test to see if a specific digest type is supported. * @param name of digest we want to check. * @return true if supported, false if not. */ static bool has(const char *name); static void uuid(char *string, const char *name, const unsigned char *ns = NULL); static String uuid(const char *name, const unsigned char *ns = NULL); }; /** * A cryptographic message authentication code class. This class can support * md5 digests, sha1, sha256, etc, depending on what the underlying library * supports. * @author David Sugar */ class __SHARED HMAC { private: void *context; union { const void *hmactype; int hmacid; }; unsigned bufsize; unsigned char buffer[MAX_DIGEST_HASHSIZE / 8]; char textbuf[MAX_DIGEST_HASHSIZE / 8 + 1]; protected: void release(void); public: HMAC(const char *digest, const char *key, size_t keylen = 0); HMAC(); ~HMAC(); inline bool puts(const char *str) {return put(str, strlen(str));}; inline HMAC &operator<<(const char *str) {puts(str); return *this;} inline HMAC &operator<<(int16_t value) {int16_t v = htons(value); put(&v, 2); return *this;} inline HMAC &operator<<(int32_t value) {int32_t v = htonl(value); put(&v, 4); return *this;} inline HMAC &operator<<(const PrintProtocol& p) {const char *cp = p._print(); if(cp) puts(cp); return *this;} bool put(const void *memory, size_t size); inline unsigned size() const {return bufsize;}; const unsigned char *get(void); const char *c_str(void); inline String str(void) {return String(c_str());}; inline operator String() {return String(c_str());}; void set(const char *digest, const char *key, size_t len); inline bool operator *=(const char *text) {return puts(text);}; inline bool operator +=(const char *text) {return puts(text);}; inline const char *operator*() {return c_str();}; inline bool operator!() const {return !bufsize && context == NULL;}; inline operator bool() const {return bufsize > 0 || context != NULL;}; /** * Test to see if a specific digest type is supported. * @param name of digest we want to check. * @return true if supported, false if not. */ static bool has(const char *name); }; /** * Cryptographically relevant random numbers. This is used both to gather * entropy pools and pseudo-random values. * @author David Sugar */ class __SHARED Random { public: /** * Push entropic seed. * @param buffer of random data to push. * @param size of buffer. * @return true if successful. */ static bool seed(const unsigned char *buffer, size_t size); /** * Re-seed pseudo-random generation and entropy pools. */ static void seed(void); /** * Get high-entropy random data. This is often used to * initialize keys. This operation may block if there is * insufficient entropy immediately available. * @param memory buffer to fill. * @param size of buffer. * @return number of bytes filled. */ static size_t key(unsigned char *memory, size_t size); /** * Fill memory with pseudo-random values. This is used * as the basis for all get and real operations and does * not depend on seed entropy. * @param memory buffer to fill. * @param size of buffer to fill. * @return number of bytes set. */ static size_t fill(unsigned char *memory, size_t size); /** * Get a pseudo-random integer, range 0 - 32767. * @return random integer. */ static int get(void); /** * Get a pseudo-random integer in a preset range. * @param min value of random integer. * @param max value of random integer. * @return random value from min to max. */ static int get(int min, int max); /** * Get a pseudo-random floating point value. * @return psudo-random value 0 to 1. */ static double real(void); /** * Get a pseudo-random floating point value in a preset range. * @param min value of random floating point number. * @param max value of random floating point number. * @return random value from min to max. */ static double real(double min, double max); /** * Determine if we have sufficient entropy to return random * values. * @return true if sufficient entropy. */ static bool status(void); /** * Create 36 character random uuid string. * @param string to write uuid into, must be 37 bytes or more. */ static void uuid(char *string); static String uuid(void); }; /** * Convenience type for secure socket. */ typedef SSLBuffer ssl_t; /** * Convenience type for generic digests. */ typedef Digest digest_t; /** * Convenience type for generic digests. */ typedef HMAC hmac_t; /** * Convenience type for generic ciphers. */ typedef Cipher cipher_t; /** * Convenience type for generic cipher key. */ typedef Cipher::Key skey_t; inline void zerofill(void *addr, size_t size) { ::memset(addr, 0, size); } #if defined(OLD_STDCPP) || defined(NEW_STDCPP) /** * Secure socket using std::iostream. This class is similar to SSLBuffer * but uses the libstdc++ library to stream i/o. Being based on tcpstream, * it also inherits the character protocol. Like SSLBuffer, if no context * is given or the handshake fails, then the stream defaults to insecure TCP * connection behavior. * @author David Sugar */ class __SHARED sstream : public tcpstream { protected: secure::session_t ssl; secure::bufio_t bio; bool server; bool verify; private: // kill copy constructor sstream(const sstream&); public: sstream(secure::client_t context); sstream(const TCPServer *server, secure::server_t context, size_t size = 536); ~sstream(); void open(const char *host, const char *service, size_t size = 536); void close(void); int sync(); void release(void); ssize_t _write(const char *address, size_t size); ssize_t _read(char *address, size_t size); bool _wait(void); inline void flush(void) {sync();} inline bool is_secure(void) {return bio != NULL;} }; /** * A template to create a string array that automatically erases. * This is a mini string/stringbuf class that supports a subset of * functionality but does not require a complex supporting object. Like * stringbuf, this can be used to create local string variables. When * the object falls out of scope it's memory is reset. * @author David Sugar */ template class keystring { private: char buffer[S]; /** * Disable copy constructor. */ inline keystring(const keystring& copy) {}; public: /** * Create a new character buffer with an empty string. */ inline keystring() {buffer[0] = 0;} /** * Create a character buffer with assigned text. If the text is * larger than the size of the object, it is truncated. * @param text to assign. */ inline keystring(const char *text) {String::set(buffer, S, text);} /** * Clear memory when destroyed. */ inline ~keystring() {memset(buffer, 0, S);} /** * Clear current key memory. */ inline void clear(void) {memset(buffer, 0, S);} /** * Assign null terminated text to the object. * @param text to assign. */ inline void operator=(const char *text) {String::set(buffer, S, text);} /** * Concatenate text into the object. If the text is larger than the * size of the object, then it is truncated. * @param text to append. */ inline void operator+=(const char *text) {String::add(buffer, S, text);} /** * Test if data is contained in the object. * @return true if there is text. */ inline operator bool() const {return buffer[0];} /** * Test if the object is empty. * @return true if the object is empty. */ inline bool operator!() const {return buffer[0] == 0;} /** * Get text by casting reference. * @return pointer to text in object. */ inline operator char *() {return buffer;} /** * Get text by object pointer reference. * @return pointer to text in object. */ inline char *operator*() {return buffer;} /** * Array operator to get a character from the object. * @param offset of character in string buffer. * @return character at offset. */ inline char& operator[](size_t offset) const {return buffer[offset];} /** * Get a pointer to an offset in the object by expression operator. * @param offset of character in string buffer. * @return pointer to offset in object. */ inline char *operator()(size_t offset) {return buffer + offset;} /** * Get allocated size of the object. * @return allocated size. */ inline size_t size(void) const {return S;} /** * Get current length of string. * @return length of string. */ inline size_t len(void) const {return strlen(buffer);} }; /** * A template to create a random generated key of specified size. The * key memory is cleared when the object is destroyed. * @author David Sugar */ template class keyrandom { private: unsigned char buffer[S]; /** * Disable copy constructor. */ inline keyrandom(const keyrandom& copy) {}; public: /** * Create a new character buffer with an empty string. */ inline keyrandom() {Random::key(buffer, S);} /** * Clear memory when destroyed. */ inline ~keyrandom() {memset(buffer, 0, S);} /** * Update with new random key. */ inline void update(void) {Random::key(buffer, S);} /** * Clear current key memory. */ inline void clear(void) {memset(buffer, 0, S);} /** * Get text by casting reference. * @return pointer to text in object. */ inline operator unsigned char *() {return buffer;} /** * Get text by object pointer reference. * @return pointer to text in object. */ inline unsigned char *operator*() {return buffer;} /** * Get allocated size of the object. * @return allocated size. */ inline size_t size(void) const {return S;} }; #endif END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/memory.h0000644000175000017500000011542412163025062014035 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Private heaps, pools, and associations. * Private heaps often can reduce locking contention in threaded applications * since they do not require using the global "malloc" function. Private * heaps also can be used as auto-release heaps, where all memory allocated * and handled out for small objects can be automatically released all at once. * Pager pools are used to optimize system allocation around page boundaries. * Associations allow private memory to be tagged and found by string * identifiers. * @file ucommon/memory.h */ #ifndef _UCOMMON_MEMORY_H_ #define _UCOMMON_MEMORY_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_LINKED_H_ #include #endif #ifndef _UCOMMON_STRING_H_ #include #endif NAMESPACE_UCOMMON class PagerPool; /** * A memory protocol pager for private heap manager. This is used to allocate * in an optimized manner, as it assumes no mutex locks are held or used as * part of it's own internal processing. It also is designed for optimized * performance. * @author David Sugar */ class __EXPORT memalloc : public MemoryProtocol { private: friend class bufpager; size_t pagesize, align; unsigned count; typedef struct mempage { struct mempage *next; union { void *memalign; unsigned used; }; } page_t; page_t *page; protected: unsigned limit; /** * Acquire a new page from the heap. This is mostly used internally. * @return page structure of the newly acquired memory page. */ page_t *pager(void); /** * Report runtime memory exhaustion. */ virtual void fault(void) const; public: /** * Construct a memory pager. * @param page size to use or 0 for OS allocation size. */ memalloc(size_t page = 0); /** * Destroy a memory pager. Release all pages back to the heap at once. */ virtual ~memalloc(); /** * Get the number of pages that have been allocated from the real heap. * @return pages allocated from heap. */ inline unsigned pages(void) const {return count;} /** * Get the maximum number of pages that are permitted. One can use a * derived class to set and enforce a maximum limit to the number of * pages that will be allocated from the real heap. This is often used * to detect and bring down apps that are leaking. * @return page allocation limit. */ inline unsigned max(void) const {return limit;} /** * Get the size of a memory page. * @return size of each pager heap allocation. */ inline unsigned size(void) const {return pagesize;} /** * Determine fragmentation level of acquired heap pages. This is * represented as an average % utilization (0-100) and represents the * used portion of each allocated heap page verse the page size. Since * requests that cannot fit on an already allocated page are moved into * a new page, there is some unusable space left over at the end of the * page. When utilization approaches 100, this is good. A low utilization * may suggest a larger page size should be used. * @return pager utilization. */ unsigned utilization(void) const; /** * Purge all allocated memory and heap pages immediately. */ void purge(void); /** * Allocate memory from the pager heap. The size of the request must be * less than the size of the memory page used. This implements the * memory protocol allocation method. * @param size of memory request. * @return allocated memory or NULL if not possible. */ virtual void *_alloc(size_t size); }; /** * A managed private heap for small allocations. This is used to allocate * a large number of small objects from a paged heap as needed and to then * release them together all at once. This pattern has significantly less * overhead than using malloc and offers less locking contention since the * memory pager can also have it's own mutex. Pager pool allocated memory * is always aligned to the optimal data size for the cpu bus and pages are * themselves created from memory aligned allocations. A page size for a * memory pager should be some multiple of the OS paging size. * * The mempager uses a strategy of allocating fixed size pages as needed * from the real heap and allocating objects from these pages as needed. * A new page is allocated from the real heap when there is insufficient * space in the existing page to complete a request. The largest single * memory allocation one can make is restricted by the page size used, and * it is best to allocate objects a significant fraction smaller than the * page size, as fragmentation occurs at the end of pages when there is * insufficient space in the current page to complete a request. * @author David Sugar */ class __EXPORT mempager : public memalloc, public LockingProtocol { private: pthread_mutex_t mutex; protected: /** * Lock the memory pager mutex. It will be more efficient to lock * the pager and then call the locked allocator than using alloc which * separately locks and unlocks for each request when a large number of * allocation requests are being batched together. */ virtual void _lock(void); /** * Unlock the memory pager mutex. */ virtual void _unlock(void); public: /** * Construct a memory pager. * @param page size to use or 0 for OS allocation size. */ mempager(size_t page = 0); /** * Destroy a memory pager. Release all pages back to the heap at once. */ virtual ~mempager(); /** * Determine fragmentation level of acquired heap pages. This is * represented as an average % utilization (0-100) and represents the * used portion of each allocated heap page verse the page size. Since * requests that cannot fit on an already allocated page are moved into * a new page, there is some unusable space left over at the end of the * page. When utilization approaches 100, this is good. A low utilization * may suggest a larger page size should be used. * @return pager utilization. */ unsigned utilization(void); /** * Purge all allocated memory and heap pages immediately. */ void purge(void); /** * Return memory back to pager heap. This actually does nothing, but * might be used in a derived class to create a memory heap that can * also receive (free) memory allocated from our heap and reuse it, * for example in a full private malloc implementation in a derived class. * @param memory to free back to private heap. */ virtual void dealloc(void *memory); /** * Allocate memory from the pager heap. The size of the request must be * less than the size of the memory page used. This impliments the * memory protocol with mutex locking for thread safety. * is locked during this operation and then released. * @param size of memory request. * @return allocated memory or NULL if not possible. */ virtual void *_alloc(size_t size); }; class __EXPORT ObjectPager : protected memalloc { public: class __EXPORT member : public LinkedObject { private: void *mem; protected: friend class ObjectPager; inline void set(member *node) {Next = node;}; inline void *get(void) const {return mem;}; member(LinkedObject **root); member(); public: inline void *operator*() const {return mem;}; }; private: unsigned members; LinkedObject *root; size_t typesize; member *last; void **index; protected: ObjectPager(size_t objsize, size_t pagesize = 256); /** * Get object from list. This is useful when objectpager is * passed as a pointer and hence inconvenient for the [] operator. * @param item to access. * @return pointer to text for item, or NULL if out of range. */ void *get(unsigned item) const; /** * Add object to list. * @param object to add. */ void *add(void); void *push(void); /** * Remove element from front of list. Does not release memory. * @return object removed. */ void *pull(void); /** * Remove element from back of list. Does not release memory. * @return object removed. */ void *pop(void); /** * Invalid object... * @return typically NULL. */ void *invalid(void) const; public: /** * Purge all members and release pager member. The list can then * be added to again. */ void clear(void); /** * Get root of pager list. This is useful for externally enumerating * the list of strings. * @return first member of list or NULL if empty. */ inline ObjectPager::member *begin(void) {return static_cast(root);}; inline operator bool() const {return members > 0;} inline bool operator!() const {return !members;} /** * Get the number of items in the pager string list. * @return number of items stored. */ inline unsigned count(void) const {return members;}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; inline size_t size(void) {return memalloc::size();} inline unsigned pages(void) {return memalloc::pages();} protected: /** * Gather index list. * @return index. */ void **list(void); }; /** * String pager for storing lists of NULL terminated strings. This is * used for accumulating lists which can be destroyed all at once. * @author David Sugar */ class __EXPORT StringPager : protected memalloc { private: unsigned members; LinkedObject *root; protected: virtual const char *invalid(void) const; public: /** * Filter text in a derived class. The base class filter removes * newlines at end of text and filters out empty strings. * @param text to filter. * @param size of text buffer for transforms. * @return false if end of data. */ virtual bool filter(char *text, size_t size); /** * Member of string list. This is exposed so that the list of strings * can be externally enumerated with linked_pointer * if so desired, through the begin() method. * @author David Sugar */ class __EXPORT member : public LinkedObject { private: const char *text; protected: friend class StringPager; inline void set(member *node) {Next = node;}; member(LinkedObject **root, const char *data); member(const char *data); public: inline const char *operator*() const {return text;}; inline const char *get(void) const {return text;}; }; /** * Create a pager with a maximum page size. * @param size of pager allocation pages. */ StringPager(size_t pagesize = 256); StringPager(char **list, size_t pagesize = 256); /** * Get the number of items in the pager string list. * @return number of items stored. */ inline unsigned count(void) const {return members;}; /** * Get string item from list. This is useful when StringPager is * passed as a pointer and hence inconvenient for the [] operator. * @param item to access. * @return pointer to text for item, or NULL if out of range. */ const char *get(unsigned item) const; /** * Replace string item in list. * @param item to replace. * @param string to replace with. */ void set(unsigned item, const char *string); /** * Add text to list. * @param text to add. */ void add(const char *text); /** * Add text to front of list. * @param text to add. */ void push(const char *text); /** * Add text list to front of list. * @param text to add. */ void push(char **text); /** * Remove element from front of list. Does not release memory. * @return text removed. */ const char *pull(void); /** * Remove element from back of list. Does not release memory. * @return text removed. */ const char *pop(void); /** * Add list to list. This is a list of string pointers terminated with * NULL. * @param list of text to add. */ void add(char **list); /** * Set list to list. This is a list of string pointers terminated with * NULL. * @param list of text to set. */ void set(char **list); /** * Purge all members and release pager member. The list can then * be added to again. */ void clear(void); /** * Return specified member from pager list. This is a convenience * operator. * @param item to access. * @return text of item or NULL if invalid. */ inline const char *operator[](unsigned item) const {return get(item);}; inline const char *at(unsigned item) const {return get(item);}; /** * Get root of pager list. This is useful for externally enumerating * the list of strings. * @return first member of list or NULL if empty. */ inline StringPager::member *begin(void) const {return static_cast(root);}; /** * Convenience operator to add to pager and auto-sort. * @param text to add to list. */ inline void operator+=(const char *text) {add(text);}; /** * Convenience operator to add to pager. * @param text to add to list. */ inline StringPager& operator<<(const char *text) {add(text); return *this;} inline StringPager& operator>>(const char *text) {push(text); return *this;} /** * Sort members. */ void sort(void); /** * Gather index list. * @return index. */ char **list(void); /** * Tokenize a string and add each token to the StringPager. * @param text to tokenize. * @param list of characters to use as token separators. * @param quote pairs of characters for quoted text or NULL if not used. * @param end of line marker characters or NULL if not used. * @return number of tokens parsed. */ unsigned token(const char *text, const char *list, const char *quote = NULL, const char *end = NULL); unsigned split(const char *text, const char *string, unsigned flags = 0); unsigned split(stringex_t& expr, const char *string, unsigned flags = 0); String join(const char *prefix = NULL, const char *middle = NULL, const char *suffix = NULL); inline operator bool() {return members > 0;} inline bool operator!() {return !members;} inline StringPager& operator=(char **list) {set(list); return *this;} inline const char *operator*() {return pull();} inline operator char **() {return list();}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; inline size_t size(void) {return memalloc::size();} inline unsigned pages(void) {return memalloc::pages();} private: member *last; char **index; }; /** * Directory pager is a paged string list for directory file names. * This protocol is used to convert a directory into a list of filenames. * As a protocol it offers a filtering method to select which files to * include in the list. * @author David Sugar */ class __EXPORT DirPager : protected StringPager { protected: const char *dir; /** * Filter filenames in a derived class. The default filter * drops "." special files. * @param filename to filter. * @param size of filename buffer. * @return true if include in final list. */ virtual bool filter(char *filename, size_t size); /** * Load a directory path. * @param path to load. * @return true if valid. */ bool load(const char *path); public: DirPager(); DirPager(const char *path); void operator=(const char *path); inline const char *operator*() const {return dir;}; inline operator bool() const {return dir != NULL;}; inline bool operator!() const {return dir == NULL;}; inline unsigned count(void) const {return StringPager::count();}; /** * Return specified filename from directory list. This is a convenience * operator. * @param item to access. * @return text of item or NULL if invalid. */ inline const char *operator[](unsigned item) const {return StringPager::get(item);}; inline const char *get(unsigned item) const {return StringPager::get(item);}; inline const char *at(unsigned item) const {return StringPager::get(item);}; inline size_t size(void) {return memalloc::size();} inline unsigned pages(void) {return memalloc::pages();} }; /** * Buffered pager for storing paged strings for character protocol. * @author David Sugar */ class __EXPORT bufpager : public memalloc, public CharacterProtocol { private: typedef struct cpage { struct cpage *next; char *text; unsigned size, used; } cpage_t; cpage_t *first, *last, *current, *freelist; unsigned cpos; unsigned long ccount; bool eom; /* null written or out of memory */ virtual int _getch(void); virtual int _putch(int code); protected: virtual void *_alloc(size_t size); public: /** * Reset pager text buffer protocol. */ void reset(void); /** * Rewind to start of text buffer protocol. */ void rewind(void); /** * Create an output string from buffer. * @return output string allocated. */ char *dup(void); /** * Set text of string buffer. * @param text to set. */ void set(const char *text); /** * Add text to string buffer. * @param text to add. */ void add(const char *text); /** * Get string from buffer. * @param text to save into. * @param size of buffer. * @return count of characters copied. */ size_t get(char *text, size_t size); /** * Put memory string into buffer including NULL byte. * @param text to add. * @param size of text to add. */ void put(const char *text, size_t size); /** * Get total size. * @return number of characters in buffer. */ inline unsigned long used(void) const {return ccount;} /** * Convenience operator to get text. * @return text string of buffer. */ inline char *operator *() {return dup();} /** * Convenience operator to add to pager. * @param text to add to list. */ inline bufpager& operator<<(const char *text) {add(text); return *this;}; bufpager(size_t page = 0); /** * Request character buffer to write into directly. * @param iosize made available. * @return pointer to buffer or NULL if out of memory. */ char *request(size_t *iosize); /** * Get pointer to copy character data. The memory pointer is * positioned at the next chunk automatically. * @param iosize of data you can copy. * @return to data from buffer or NULL if past end. */ char *copy(size_t *iosize); /** * Used to complete a request method. * @param size of data actually written. */ void update(size_t size); /** * Check if can still save into buffer. * @return true if buffer is full. */ inline bool operator!() {return eom;} /** * Check if can still save into buffer. Used for is() function. * @return true if pager can still store more. */ inline operator bool() {return !eom;} }; /** * Create a linked list of auto-releasable objects. LinkedObject derived * objects can be created that are assigned to an autorelease object list. * When the autorelease object falls out of scope, all the objects listed' * with it are automatically deleted. * @author David Sugar */ class __EXPORT autorelease { private: LinkedObject *pool; public: /** * Create an initially empty autorelease pool. */ autorelease(); /** * Destroy an autorelease pool and delete member objects. */ ~autorelease(); /** * Destroy an autorelease pool and delete member objects. This may be * used to release an existing pool programmatically when desired rather * than requiring the object to fall out of scope. */ void release(void); /** * Add a linked object to the autorelease pool. * @param object to add to pool. */ void operator+=(LinkedObject *object); }; /** * This is a base class for objects that may be created in pager pools. * This is also used to create objects which can be maintained as managed * memory and returned to a pool. The linked list is used when freeing * and re-allocating the object. These objects are reference counted * so that they are returned to the pool they come from automatically * when falling out of scope. This can be used to create automatic * garbage collection pools. * @author David Sugar */ class __EXPORT PagerObject : public LinkedObject, public CountedObject { protected: friend class PagerPool; PagerPool *pager; /** * Create a pager object. This is object is constructed by a PagerPool. */ PagerObject(); /** * Reset state of object. */ void reset(void); /** * Release a pager object reference. */ void release(void); /** * Return the pager object back to it's originating pool. */ void dealloc(void); }; /** * Pager pool base class for managed memory pools. This is a helper base * class for the pager template and generally is not used by itself. If * different type pools are intended to use a common memory pager then * you will need to mixin a memory protocol object that performs * redirection such as the MemoryRedirect class. * @author David Sugar */ class __EXPORT PagerPool : public MemoryProtocol { private: LinkedObject *freelist; pthread_mutex_t mutex; protected: PagerPool(); virtual ~PagerPool(); PagerObject *get(size_t size); public: /** * Return a pager object back to our free list. * @param object to return to pool. */ void put(PagerObject *object); }; class __EXPORT charmem : public CharacterProtocol { protected: char *buffer; size_t inp, out, size; bool dynamic; int _getch(void); int _putch(int code); public: charmem(char *mem, size_t size); charmem(size_t size); charmem(); virtual ~charmem(); void release(void); void set(char *mem, size_t size); void set(size_t size); inline void reset(void) {inp = out = 0;} inline void rewind(void) {inp = 0;} }; class __EXPORT chartext : public CharacterProtocol { private: char *pos; size_t max; int _putch(int code); int _getch(void); public: chartext(); chartext(char *buf); chartext(char *buf, size_t size); virtual ~chartext(); }; /** * A class to hold memory pointers referenced by string names. This is * used to form a typeless data pointer that can be associated and * referenced by string/logical name. The memory used for forming * the string names can itself be managed in reusable memory pools and * the entire structure uses it's own private pager heap. This allows * new string named pointers to be added and deleted at runtime in a thread- * safe manner. This might typically be used as a session id manager or for * symbol tables. * @author David Sugar */ class __EXPORT keyassoc : protected mempager { private: /** * Internal paged memory residing data class for name associated pointers. */ class __LOCAL keydata : public NamedObject { public: void *data; char text[8]; keydata(keyassoc *assoc, const char *id, unsigned max, unsigned bufsize); }; friend class keydata; unsigned keycount; unsigned paths; size_t keysize; NamedObject **root; LinkedObject **list; protected: /** * Allocate object stored in pager also. * @param name of object entry. * @param size of object to allocate. * @return pointer to allocated object or NULL on failure. */ void *allocate(const char *name, size_t size); public: /** * Create a key associated memory pointer table. * @param indexing size for hash map. * @param max size of a string name if names are in reusable managed memory. * @param page size of memory pager. */ keyassoc(unsigned indexing = 177, size_t max = 0, size_t page = 0); /** * Destroy association object. Release all pages back to the heap. */ ~keyassoc(); /** * Get the number of associations we have in our object. * @return number of associations stored. */ inline unsigned count(void) const {return keycount;}; /** * Lookup the data pointer of a string by direct operation. * @param name to lookup. * @return pointer to data or NULL if not found. */ inline void *operator()(const char *name) {return locate(name);}; /** * Purge all associations and return allocated pages to heap. */ void purge(void); /** * Lookup the data pointer by the string name given. * @param name to lookup. * @return pointer to data or NULL if not found. */ void *locate(const char *name); /** * Assign a name to a data pointer. If the name exists, it is re-assigned * with the new pointer value, otherwise it is created. * @param name to assign. * @param pointer value to assign with name. * @return false if failed because name is too long for managed table. */ bool assign(const char *name, void *pointer); /** * Create a new name in the association table and assign it's value. * @param name to create. * @param pointer value to assign with name. * @return false if already exists or name is too long for managed table. */ bool create(const char *name, void *pointer); /** * Remove a name and pointer association. If managed key names are used * then the memory allocated for the name will be re-used. * @param name to remove. * @return pointer value of the name or NULL if not found. */ void *remove(const char *name); }; template class listof : private ObjectPager { public: inline listof() : ObjectPager(sizeof(T), P) {}; inline T& operator[](unsigned item) const {return (T&)ObjectPager::get(item);} inline T* operator()(unsigned item) const {return (T*)ObjectPager::get(item);} inline const T& at(unsigned item) const {return (const T&)ObjectPager::get(item);} inline T* pull(void) {return (T*)ObjectPager::pull();} inline T* pop(void) {return (T*)ObjectPager::pop();} inline operator T**() {return (T**)ObjectPager::list();} inline T** list(void) {return (T**)ObjectPager::list();} inline T* operator++(void) {T* tmp = ObjectPager::add(); if(tmp) new((caddr_t)tmp) T; return tmp;} inline T* add(const T& object) {T* tmp = ObjectPager::add(); if(tmp) new((caddr_t)tmp) T(object); return tmp;} inline T* push(const T& object) {T* tmp = ObjectPager::push(); if(tmp) new((caddr_t)tmp) T(object); return tmp;} inline listof& operator<<(const T& object) {T* tmp = ObjectPager::add(); if(tmp) new((caddr_t)tmp) T(object); return *this;} inline listof& operator>>(const T& object) {T* tmp = ObjectPager::push(); if(tmp) new((caddr_t)tmp) T(object); return *this;} }; template class mapof : private keyassoc { public: /** * Construct an associated pointer hash map based on the class template. */ inline mapof() : keyassoc(I, M, P) {}; /** * Get the count of typed objects stored in our hash map. * @return typed objects in map. */ inline unsigned count(void) const {return keyassoc::count();}; /** * Purge the hash map of typed objects. */ inline void purge(void) {keyassoc::purge();}; /** * Lookup a typed object by name. * @param name of typed object to locate. * @return typed object pointer or NULL if not found. */ inline T *locate(const char *name) {return static_cast(keyassoc::locate(name));} inline T *operator[](const char *name) {return static_cast(keyassoc::locate(name));} /** * Reference a typed object directly by name. * @param name of typed object to locate. * @return typed object pointer or NULL if not found. */ inline T *operator()(const char *name) {return locate(name);}; /** * Create mapped entry from scratch. * @param name to assign. */ inline T *map(const char *name) {T *tmp = keyassoc::allocate(name, sizeof(T)); if(tmp) new((caddr_t)tmp) T;} /** * Remove a name and typed pointer association. If managed key names are * used then the memory allocated for the name will be re-used. * @param name to remove. */ inline void unmap(const char *name) {keyassoc::remove(name);}; /** * Access to pager utilization stats. This is needed because we * inherit keyassoc privately. * @return pager utilization, 0-100. */ inline unsigned utilization(void) {return mempager::utilization();}; /** * Access to number of pages allocated from heap for our associated * index pointer. This is needed because we inherit keyassoc * privately. * @return count of heap pages used. */ inline unsigned pages(void) const {return mempager::pages();}; }; /** * A typed template for using a key association with typed objects. * This essentially forms a form of "smart pointer" that is a reference * to specific typed objects by symbolic name. This is commonly used as * for associated indexing of typed objects. * @author David Sugar */ template class assoc_pointer : private keyassoc { public: /** * Construct an associated pointer hash map based on the class template. */ inline assoc_pointer() : keyassoc(I, M, P) {}; /** * Get the count of typed objects stored in our hash map. * @return typed objects in map. */ inline unsigned count(void) const {return keyassoc::count();} /** * Purge the hash map of typed objects. */ inline void purge(void) {keyassoc::purge();} /** * Lookup a typed object by name. * @param name of typed object to locate. * @return typed object pointer or NULL if not found. */ inline T *locate(const char *name) {return static_cast(keyassoc::locate(name));} inline T *operator[](const char *name) {return static_cast(keyassoc::locate(name));} /** * Reference a typed object directly by name. * @param name of typed object to locate. * @return typed object pointer or NULL if not found. */ inline T *operator()(const char *name) {return locate(name);} /** * Assign a name for a pointer to a typed object. If the name exists, * it is re-assigned with the new pointer value, otherwise it is created. * @param name to assign. * @param pointer of typed object to assign with name. * @return false if failed because name is too long for managed table. */ inline bool assign(char *name, T *pointer) {return keyassoc::assign(name, pointer);} /** * Create a new name in the association table and assign typed object. * @param name to create. * @param pointer of typed object to assign with name. * @return false if already exists or name is too long for managed table. */ inline bool create(char *name, T *pointer) {return keyassoc::create(name, pointer);} /** * Remove a name and typed pointer association. If managed key names are * used then the memory allocated for the name will be re-used. * @param name to remove. */ inline void remove(char *name) {keyassoc::remove(name);} /** * Access to pager utilization stats. This is needed because we * inherit keyassoc privately. * @return pager utilization, 0-100. */ inline unsigned utilization(void) const {return mempager::utilization();} /** * Access to number of pages allocated from heap for our associated * index pointer. This is needed because we inherit keyassoc * privately. * @return count of heap pages used. */ inline unsigned pages(void) const {return mempager::pages();} }; /** * Mempager managed type factory for pager pool objects. This is used to * construct a type factory that creates and manages typed objects derived * from PagerObject which can be managed through a private heap. * @author David Sugar */ template class pager : private MemoryRedirect, private PagerPool { public: /** * Construct a pager and optionally assign a private pager heap. * @param heap pager to use. If NULL, uses global heap. */ inline pager(mempager *heap = NULL) : MemoryRedirect(heap), PagerPool() {}; /** * Create a managed object by casting reference. * @return pointer to typed managed pager pool object. */ inline T *operator()(void) {return new(get(sizeof(T))) T;}; /** * Create a managed object by pointer reference. * @return pointer to typed managed pager pool object. */ inline T *operator*() {return new(get(sizeof(T))) T;}; }; /** * A template class for a hash pager. This creates objects from a pager * pool when they do not already exist in the hash map. * @author David Sugar */ template class keypager : public mempager { private: NamedObject *idx[M]; public: /** * Create the object cache. * @param size of allocation units. */ inline keypager(size_t size) : mempager(size) {}; /** * Destroy the hash pager by purging the index chains and memory pools. */ inline ~keypager() {NamedObject::purge(idx, M); mempager::purge();}; /** * Find a typed object derived from NamedObject in the hash map by name. * If the object is not found, it is created from the memory pool. * @param name to search for. * @return typed object if found through map or NULL. */ inline T *get(const char *name) const { T *node = (static_cast(NamedObject::map(idx, name, M))); if(!node) { node = init(static_cast(mempager::_alloc(sizeof(T)))); node->NamedObject::add(idx, name, M); } return node; } /** * Test if a name exists in the pool. * @param name to test. * @return true if found. */ bool test(const char *name) const {return NamedObject::map(idx, name, M) != NULL;}; /** * Find a typed object derived from NamedObject in the hash map by name. * If the object is not found, it is created from the pager pool. * @param name to search for. * @return typed object if found through map or NULL. */ inline T *operator[](const char *name) const {return get(name);}; /** * Find first typed object in hash map to iterate. * @return first typed object or NULL if nothing in list. */ inline T *begin(void) const {return static_cast(NamedObject::skip(idx, NULL, M));}; /** * Find next typed object in hash map for iteration. * @param current typed object we are referencing. * @return next iterative object or NULL if past end of map. */ inline T *next(T *current) const {return static_cast(NamedObject::skip(idx, current, M));}; /** * Count the number of typed objects in our hash map. * @return count of typed objects. */ inline unsigned count(void) const {return NamedObject::count(idx, M);}; /** * Convert our hash map into a linear object pointer array. The * object pointer array is created from the heap and must be deleted * when no longer used. * @return array of typed named object pointers. */ inline T **index(void) const {return NamedObject::index(idx, M);}; /** * Convert our hash map into an alphabetically sorted linear object * pointer array. The object pointer array is created from the heap * and must be deleted when no longer used. * @return sorted array of typed named object pointers. */ inline T **sort(void) const {return NamedObject::sort(NamedObject::index(idx, M));}; /** * Convenience typedef for iterative pointer. */ typedef linked_pointer iterator; }; /** * A convenience type for paged string lists. */ typedef StringPager stringlist_t; /** * A convenience type for paged string list items. */ typedef StringPager::member stringlistitem_t; /** * A convenience type for using DirPager directly. */ typedef DirPager dirlist_t; inline const char *shift(stringlist_t& list) {return list.pull();} inline void unshift(stringlist_t& list, const char *text) {list.push(text);} inline String str(StringPager& list, const char *prefix = NULL, const char *middle = NULL, const char *suffix = NULL) {return list.join(prefix, middle, suffix);} END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/ucommon.h0000644000175000017500000001300612163025062014173 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Top level include file for the GNU uCommon C++ core library. * This is the only include file you need to have in your sources; it * includes the remaining header files. * @file ucommon/ucommon.h */ /** * @short A portable C++ threading library for embedded applications. * GNU uCommon C++ is meant as a very light-weight library to facilitate using * C++ design patterns even for very deeply embedded applications, such as for * systems using uclibc along with posix threading support. For this reason, * uCommon disables language features that consume memory or introduce runtime * overhead, such as rtti and exception handling, and assumes one will mostly * be linking applications with other pure C based libraries rather than using * the overhead of the standard C++ library and other class frameworks. * * uCommon by default does build with support for the bloated ansi standard c++ * library unless this is changed at configure time with the --disable-stdcpp * option. This is to assure maximum portability and will be used to merge * uCommon with GNU Common C++ to form GNU Common C++ 2.0. Some specific * features are tested for when stdc++ is enabled, and these will be used * to add back in GNU Common C++ classes such as TCP Stream and serialization. * * uCommon introduces some Objective-C based design patterns, such as reference * counted objects, memory pools, smart pointers, and offers dynamic typing * through very light use of inline templates for pure type translation that are * then tied to concrete base classes to avoid template instantiation issues. C++ * auto-variable automation is also used to enable referenced objects to be * deleted and threading locks to be released that are acquired automatically when * methods return rather than requiring one to explicitly code for these things. * * uCommon depends on and when necessary will introduce some portable C * replacement functions, especially for sockets, such as adding getaddrinfo for * platforms which do not have it, or when threadsafe versions of existing C * library functions are needed. Basic socket support for connecting to named * destinations and multicast addresses, and binding to interfaces with IPV4 and * IPV6 addresses is directly supported. Support for high resolution timing and * Posix realtime clocks are also used when available. * * uCommon builds all higher level thread synchronization objects directly from * conditionals. Hence, on platforms which for example do not have rwlocks, * barriers, or semaphores, these are still found in uCommon. A common and * consistent call methodology is used for all locks, whether mutex, rw, or * semaphore, based on whether used for exclusive or "shared" locking. * * uCommon requires some knowledge of compiler switches and options to disable * language features, the C++ runtime and stdlibs, and associated C++ headers. The * current version supports compiling with GCC, which is commonly found on * GNU/Linux, OS/X, BSD based systems, and many other platforms; and the Sun * Workshop compiler, which is offered as an example how to adapt uCommon for * additional compilers. uCommon may also be built with GCC cross compiling for * mingw32 to build threaded applications for Microsoft Windows targets nativiely. * * The minimum platform support for uCommon is a modern and working posix * pthread threading library. I further use a subset of posix threads to assure * wider portability by avoiding more specialized features like process shared * synchronization objects, pthread rwlocks and pthread semaphores, as these are * not implemented on all platforms that I have found. Finally, I have * eliminated the use of posix thread cancellation. * @author David Sugar * @license GNU Lesser General Public License Version 3 or later * @mainpage GNU uCommon C++ */ #ifndef _UCOMMON_UCOMMON_H_ #define _UCOMMON_UCOMMON_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _UCOMMON_EXTENDED_ #include #include #include #endif #endif ucommon-6.0.7/inc/ucommon/string.h0000644000175000017500000015325312163025062014035 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * A common string class and character string support functions. * Ucommon offers a simple string class that operates through copy-on-write * when needing to expand buffer size. Derived classes and templates allows * one to create strings which live entirely in the stack frame rather * than using the heap. This offers the benefit of the string class * manipulative members without compromising performance or locking issues * in threaded applications. Other things found here include better and * safer char array manipulation functions. * @file ucommon/string.h */ /** * An example of the string class. * @example string.cpp */ #ifndef _UCOMMON_STRING_H_ #define _UCOMMON_STRING_H_ #ifndef _UCOMMON_CPR_H_ #include #endif #ifndef _UCOMMON_GENERICS_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_OBJECT_H_ #include #endif #include #include #include #ifdef HAVE_DIRENT_H #include #endif #define PGP_B64_WIDTH 64 #define MIME_B64_WIDTH 76 NAMESPACE_UCOMMON /** * A convenience class for size of strings. */ typedef unsigned short strsize_t; /** * A copy-on-write string class that operates by reference count. This string * class anchors a counted object that is managed as a copy-on-write * instance of the string data. This means that multiple instances of the * string class can refer to the same string in memory if it has not been * modifed, which reduces heap allocation. The string class offers functions * to manipulate both the string object, and generic safe string functions to * manipulate ordinary null terminated character arrays directly in memory. * @author David Sugar */ class __EXPORT String : public ObjectProtocol { protected: /** * This is an internal class which contains the actual string data * along with some control fields. The string can be either NULL * terminated or filled like a Pascal-style string, but with a user * selected fill character. The cstring object is an overdraft * object, as the actual string text which is of unknown size follows * immediately after the class control data. This class is primarily * for internal use. * @author David Sugar */ public: enum { SENSITIVE = 0x00, INSENSITIVE = 0x01 }; class __EXPORT regex { private: void *object; void *results; size_t count; public: regex(const char *pattern, size_t slots = 1); regex(size_t slots = 1); ~regex(); size_t offset(unsigned member); size_t size(unsigned member); inline size_t members(void) {return count;}; bool match(const char *text, unsigned flags = 0); regex& operator=(const char *string); bool operator*=(const char *string); operator bool() {return object != NULL;} bool operator!() {return object == NULL;} }; class __EXPORT cstring : public CountedObject { public: #pragma pack(1) strsize_t max; /**< Allocated size of cstring text */ strsize_t len; /**< Current length of cstring text */ char fill; /**< Filler character or 0 for none */ char text[1]; /**< Null terminated text, in overdraft space */ #pragma pack() /** * Create a cstring node allocated for specified string size. The * new operator would also need the size as an overdraft value. * @param size of string. */ cstring(strsize_t size); /** * Create a filled cstring node allocated for specified string size. * The new operator would also need the size as an overdraft value. * The newly allocated string is filled with the fill value. * @param size of string. * @param fill character value to fill string with. */ cstring(strsize_t size, char fill); /** * Used to clear a string. If null terminated, then the string ends * at the offset, otherwise it is simply filled with fill data up to * the specified size. * @param offset to clear from. * @param size of field to clear. */ void clear(strsize_t offset, strsize_t size); /** * Set part or all of a string with new text. * @param offset to set from. * @param text to insert from null terminated string. * @param size of field to modify. This is filled for fill mode. */ void set(strsize_t offset, const char *text, strsize_t size); /** * Set our string from null terminated text up to our allocated size. * @param text to set from. */ void set(const char *text); /** * Append null terminated text to our string buffer. * @param text to append. */ void add(const char *text); /** * Append a single character to our string buffer. * @param character to append. */ void add(char character); /** * Fill our string buffer to end if fill mode. */ void fix(void); /** * Trim filler at end to reduce filled string to null terminated * string for further processing. */ void unfix(void); /** * Adjust size of our string buffer by deleting characters from * start of buffer. * @param number of characters to delete. */ void inc(strsize_t number); /** * Adjust size of our string buffer by deleting characters from * end of buffer. * @param number of characters to delete. */ void dec(strsize_t number); }; protected: cstring *str; /**< cstring instance our object references. */ /** * Factory create a cstring object of specified size. * @param size of allocated space for string buffer. * @param fill character to use or 0 if null. * @return new cstring object. */ cstring *create(strsize_t size, char fill = 0) const; public: /** * Compare the values of two string. This is a virtual so that it * can be overridden for example if we want to create strings which * ignore case, or which have special ordering rules. * @param string to compare with. * @return 0 if equal, <0 if less than, 0> if greater than. */ virtual int compare(const char *string) const; inline int collate(const char *string) const {return compare(string);}; protected: /** * Test if two string values are equal. * @param string to compare with. * @return true if equal. */ bool equal(const char *string) const; /** * Increase retention of our reference counted cstring. May be overridden * for memstring which has fixed cstring object. */ virtual void retain(void); /** * Decrease retention of our reference counted cstring. May be overridden * for memstring which has fixed cstring object. */ virtual void release(void); /** * Return cstring to use in copy constructors. Is virtual for memstring. * @return cstring for copy constructor. */ virtual cstring *c_copy(void) const; /** * Copy on write operation for cstring. This always creates a new * unique copy for write/modify operations and is a virtual for memstring * to disable. * @param size to add to allocated space when creating new cstring. */ virtual void cow(strsize_t size = 0); strsize_t getStringSize(void); public: /** * A constant for an invalid position value. */ #if _MSC_VER > 1400 // windows broken dll linkage issue... const static strsize_t npos = ((strsize_t)-1); #else static const strsize_t npos; #endif /** * Create a new empty string object. */ String(); /** * Create a string from a long integer. * @param value to convert to string. */ String(long value); /** * Create a string from a floating point. * @param value to convert to string. */ String(double value); /** * Create an empty string with a buffer pre-allocated to a specified size. * @param size of buffer to allocate. */ String(strsize_t size); /** * Create a filled string with a buffer pre-allocated to a specified size. * @param size of buffer to allocate. * @param fill character to use. */ String(strsize_t size, char fill); /** * Create a string by printf-like formating into a pre-allocated space * of a specified size. A typical use might be in a concat function * like String x = (String)something + (String){10, "%ud", var}. * @param size of buffer to allocate. * @param format control for string. */ String(strsize_t size, const char *format, ...) __PRINTF(3, 4); /** * Create a string from null terminated text. * @param text to use for string. */ String(const char *text); /** * Create a string from null terminated text up to a maximum specified * size. * @param text to use for string. * @param size limit of new string. */ String(const char *text, strsize_t size); /** * Create a string for a substring. The end of the substring is a * pointer within the substring itself. * @param text to use for string. * @param end of text in substring. */ String(const char *text, const char *end); /** * Construct a copy of a string object. Our copy inherets the same * reference counted instance of cstring as in the original. * @param existing string to copy from. */ String(const String& existing); /** * Destroy string. De-reference cstring. If last reference to cstring, * then also remove cstring from heap. */ virtual ~String(); /** * Get a new string object as a substring of the current object. * @param offset of substring. * @param size of substring or 0 if to end. * @return string object holding substring. */ String get(strsize_t offset, strsize_t size = 0) const; /** * Scan input items from a string object. * @param format string of input to scan. * @return number of items scanned. */ int scanf(const char *format, ...) __SCANF(2, 3); /** * Scan input items from a string object. * @param format string of input to scan. * @param args list to scan into. * @return number of items scanned. */ int vscanf(const char *format, va_list args) __SCANF(2, 0); /** * Print items into a string object. * @param format string of print format. * @return number of bytes written to string. */ strsize_t printf(const char *format, ...) __PRINTF(2, 3); /** * Print items into a string object. * @param format string of print format. * @param args list to print. * @return number of bytes written to string. */ strsize_t vprintf(const char *format, va_list args) __PRINTF(2, 0); /** * Get memory text buffer of string object. * @return writable string buffer. */ char *c_mem(void) const; /** * Get character text buffer of string object. * @return character text buffer. */ const char *c_str(void) const; /** * Resize and re-allocate string memory. * @param size to allocate for string. * @return true if re-allocated. False in derived memstring. */ virtual bool resize(strsize_t size); /** * Set string object to text of a null terminated string. * @param text string to set. */ void set(const char *text); /** * Set a portion of the string object at a specified offset to a text * string. * @param offset in object string buffer. * @param text to set at offset. * @param size of text area to set or 0 until end of text. */ void set(strsize_t offset, const char *text, strsize_t size = 0); /** * Set a text field within our string object. * @param text to set. * @param overflow character to use as filler if text is too short. * @param offset in object string buffer to set text at. * @param size of part of buffer to set with text and overflow. */ void set(const char *text, char overflow, strsize_t offset, strsize_t size = 0); /** * Set a text field within our string object offset from the end of buffer. * @param text to set. * @param overflow character to use as filler if text is too short. * @param offset from end of object string buffer to set text at. * @param size of part of buffer to set with text and overflow. */ void rset(const char *text, char overflow, strsize_t offset, strsize_t size = 0); /** * Append null terminated text to our string buffer. * @param text to append. */ void add(const char *text); /** * Append a single character to our string buffer. * @param character to append. */ void add(char character); /** * Trim lead characters from the string. * @param list of characters to remove. */ void trim(const char *list); /** * Trim lead characters from text. * @param count of characters to remove. */ inline void trim(strsize_t count = 1) {operator+=(count);}; /** * Chop trailing characters from the string. * @param list of characters to remove. */ void chop(const char *list); /** * Chop trailing characters from text. * @param count of characters to remove. */ inline void chop(strsize_t count = 1) {operator-=(count);}; /** * Strip lead and trailing characters from the string. * @param list of characters to remove. */ void strip(const char *list); /** * Unquote a quoted string. Removes lead and trailing quote marks. * @param quote pairs of characters for open and close quote. * @return true if string was quoted. */ bool unquote(const char *quote); /** * Cut (remove) text from string. * @param offset to start of text field to remove. * @param size of text field to remove or 0 to remove to end of string. */ void cut(strsize_t offset, strsize_t size = 0); /** * Insert (paste) text into string. * @param offset to start paste. * @param text to paste. * @param size of text to paste. */ void paste(strsize_t offset, const char *text, strsize_t size = 0); /** * Clear a field of a filled string with filler. * @param offset to start of field to clear. * @param size of field to fill or 0 to fill to end of string. */ void clear(strsize_t offset, strsize_t size = 0); /** * Clear string by setting to empty. */ void clear(void); /** * Convert string to upper case. */ void upper(void); /** * Convert string to lower case. */ void lower(void); /** * Erase string memory. */ void erase(void); /** * Count number of occurrences of characters in string. * @param list of characters to find. * @return count of instances of characters in string. */ strsize_t ccount(const char *list) const; /** * Count all characters in the string (strlen). * @return count of characters. */ strsize_t count(void) const; /** * Get the size of currently allocated space for string. * @return size allocated for text. */ strsize_t size(void) const; /** * Find offset of a pointer into our string buffer. This can be used * to find the offset position of a pointer returned by find, for * example. This is used when one needs to convert a member function * that returns a pointer to call a member function that operates by * a offset value. If the pointer is outside the range of the string * then npos is returned. * @param pointer into our object's string buffer. */ strsize_t offset(const char *pointer) const; /** * Return character found at a specific position in the string. * @param position in string, negative values computed from end. * @return character code at specified position in string. */ char at(int position) const; /** * Get pointer to first character in string for iteration. * @return first character pointer or NULL if empty. */ const char *begin(void) const; /** * Get pointer to last character in string for iteration. * @return last character pointer or NULL if empty. */ const char *end(void) const; /** * Skip lead characters in the string. * @param list of characters to skip when found. * @param offset to start of scan. * @return pointer to first part of string past skipped characters. */ const char *skip(const char *list, strsize_t offset = 0) const; /** * Skip trailing characters in the string. This searches the * string in reverse order. * @param list of characters to skip when found. * @param offset to start of scan. Default is end of string. * @return pointer to first part of string before skipped characters. */ const char *rskip(const char *list, strsize_t offset = npos) const; /** * Search for a substring in the string. * @param substring to search for. * @param flags for case insensitive search. */ const char *search(const char *string, unsigned instance = 0, unsigned flags = 0) const; const char *search(regex& expr, unsigned instance = 0, unsigned flags = 0) const; unsigned replace(const char *string, const char *text = NULL, unsigned flags = 0); unsigned replace(regex& expr, const char *text = NULL, unsigned flags = 0); /** * Find a character in the string. * @param list of characters to search for. * @param offset to start of search. * @return pointer to first occurrence of character. */ const char *find(const char *list, strsize_t offset = 0) const; /** * Find last occurrence of character in the string. * @param list of characters to search for. * @param offset to start of search. Default is end of string. * @return pointer to last occurrence of character. */ const char *rfind(const char *list, strsize_t offset = npos) const; /** * Split the string by a pointer position. Everything after the pointer * is removed. * @param pointer to split position in string. */ void split(const char *pointer); /** * Split the string at a specific offset. Everything after the offset * is removed. * @param offset to split position in string. */ void split(strsize_t offset); /** * Split the string by a pointer position. Everything before the pointer * is removed. * @param pointer to split position in string. */ void rsplit(const char *pointer); /** * Split the string at a specific offset. Everything before the offset * is removed. * @param offset to split position in string. */ void rsplit(strsize_t offset); /** * Find pointer in string where specified character appears. * @param character to find. * @return string pointer for character if found, NULL if not. */ const char *chr(char character) const; /** * Find pointer in string where specified character last appears. * @param character to find. * @return string pointer for last occurrence of character if found, * NULL if not. */ const char *rchr(char character) const; /** * Get length of string. * @return length of string. */ strsize_t len(void) const; /** * Get filler character used for field array strings. * @return filler character or 0 if none. */ char fill(void); /** * Casting reference to raw text string. * @return null terminated text of string. */ inline operator const char *() const {return c_str();}; /** * Reference raw text buffer by pointer operator. * @return null terminated text of string. */ inline const char *operator*() const {return c_str();}; /** * Test if the string's allocated space is all used up. * @return true if no more room for append. */ bool full(void) const; /** * Get a new substring through object expression. * @param offset of substring. * @param size of substring or 0 if to end. * @return string object holding substring. */ String operator()(int offset, strsize_t size) const; /** * Convenience method for left of string. * @param size of substring to gather. * @return string object holding substring. */ inline String left(strsize_t size) const {return operator()(0, size);} /** * Convenience method for right of string. * @param offset of substring from right. * @return string object holding substring. */ inline String right(strsize_t offset) const {return operator()(-((int)offset), 0);} /** * Convenience method for substring extraction. * @param offset into string. * @param size of string to return. * @return string object holding substring. */ inline String copy(strsize_t offset, strsize_t size) const {return operator()((int)offset, size);} /** * Reference a string in the object by relative offset. Positive * offsets are from the start of the string, negative from the * end. * @param offset to string position. * @return pointer to string data or NULL if invalid offset. */ const char *operator()(int offset) const; /** * Reference a single character in string object by array offset. * @param offset to character. * @return character value at offset. */ const char operator[](int offset) const; /** * Test if string is empty. * @return true if string is empty. */ bool operator!() const; /** * Test if string has data. * @return true if string has data. */ operator bool() const; /** * Create new cow instance and assign value from another string object. * @param object to assign from. * @return our object for expression use. */ String& operator^=(const String& object); /** * Concatenate text to an existing string object. This will use the * old behavior when +/= updated. */ String& operator|=(const char *text); String& operator&=(const char *text); /** * Concatenate text to an existing string object. * @param text to add. * @return our object for expression use. */ String& operator+=(const char *text); /** * Create new cow instance and assign value from null terminated text. * @param text to assign from. * @return our object for expression use. */ String& operator^=(const char *text); /** * Concatenate null terminated text to our object. * @param text to concatenate. */ String operator+(const char *text); /** * Concatenate null terminated text to our object. This creates a new * copy-on-write instance to hold the concatenated string. This will * eventually replace '+' when + creates a new string instance instead. * @param text to concatenate. */ String& operator|(const char *text); /** * Concatenate null terminated text to our object. This directly * appends the text to the string buffer and does not resize the * object if the existing cstring allocation space is fully used. * @param text to concatenate. */ String& operator&(const char *text); /** * Assign our string with the cstring of another object. If we had * an active string reference, it is released. The object now has * a duplicate reference to the cstring of the other object. * @param object to assign from. */ String& operator=(const String& object); bool operator*=(const char *substring); bool operator*=(regex& expr); /** * Assign text to our existing buffer. This performs a set method. * @param text to assign from. */ String& operator=(const char *text); /** * Delete first character from string. */ String& operator++(void); /** * Delete a specified number of characters from start of string. * @param number of characters to delete. */ String& operator+=(strsize_t number); /** * Delete last character from string. */ String& operator--(void); /** * Delete a specified number of characters from end of string. * @param number of characters to delete. */ String& operator-=(strsize_t number); /** * Delete a specified number of characters from start of string. * @param number of characters to delete. */ String& operator*=(strsize_t number); /** * Compare our object with null terminated text. * @param text to compare with. * @return true if we are equal. */ bool operator==(const char *text) const; /** * Compare our object with null terminated text. Compare method is used. * @param text to compare with. * @return true if we are not equal. */ bool operator!=(const char *text) const; /** * Compare our object with null terminated text. Compare method is used. * @param text to compare with. * @return true if we are less than text. */ bool operator<(const char *text) const; /** * Compare our object with null terminated text. Compare method is used. * @param text to compare with. * @return true if we are less than or equal to text. */ bool operator<=(const char *text) const; /** * Compare our object with null terminated text. Compare method is used. * @param text to compare with. * @return true if we are greater than text. */ bool operator>(const char *text) const; /** * Compare our object with null terminated text. Compare method is used. * @param text to compare with. * @return true if we are greater than or equal to text. */ bool operator>=(const char *text) const; inline String& operator<<(const char *text) {add(text); return *this;} inline String& operator<<(char code) {add(code); return *this;} /** * Parse short integer value from a string. * @param value to store. * @return object in expression. */ String &operator%(short& value); /** * Parse long integer value from a string. * @param value to store. * @return object in expression. */ String &operator%(unsigned short& value); /** * Parse long integer value from a string. * @param value to store. * @return object in expression. */ String &operator%(long& value); /** * Parse long integer value from a string. * @param value to store. * @return object in expression. */ String &operator%(unsigned long& value); /** * Parse double value from a string. * @param value to store. * @return object in expression. */ String &operator%(double& value); /** * Parse text from a string in a scan expression. * @param text to scan and bypass. * @return object in expression. */ String &operator%(const char *text); /** * Swap the cstring references between two strings. * @param object1 to swap. * @param object2 to swap. */ static void swap(String& object1, String& object2); /** * Fix and reset string object filler. * @param object to fix. */ static void fix(String& object); /** * Erase string memory. Often used to clear out passwords. * @param text string to erase. */ static void erase(char *text); /** * Convert null terminated text to lower case. * @param text to convert. */ static void lower(char *text); /** * Convert null terminated text to upper case. * @param text to convert. */ static void upper(char *text); /** * A thread-safe token parsing routine for null terminated strings. This * is related to strtok, but with safety checks for NULL values and a * number of enhancements including support for quoted text that may * contain token separators within quotes. The text string is modified * as it is parsed. * @param text string to examine for tokens. * @param last token position or set to NULL for start of string. * @param list of characters to use as token separators. * @param quote pairs of characters for quoted text or NULL if not used. * @param end of line marker characters or NULL if not used. * @return token extracted from string or NULL if no more tokens found. */ static char *token(char *text, char **last, const char *list, const char *quote = NULL, const char *end = NULL); /** * Skip after lead characters in a null terminated string. * @param text pointer to start at. * @param list of characters to skip when found. * @return pointer to first part of string past skipped characters. */ static char *skip(char *text, const char *list); /** * Skip before trailing characters in a null terminated string. * @param text pointer to start at. * @param list of characters to skip when found. * @return pointer to last part of string past skipped characters. */ static char *rskip(char *text, const char *list); /** * Unquote a quoted null terminated string. Returns updated string * position and replaces trailing quote with null byte if quoted. * @param text to examine. * @param quote pairs of character for open and close quote. * @return new text pointer if quoted, NULL if unchanged. */ static char *unquote(char *text, const char *quote); /** * Set a field in a null terminated string relative to the end of text. * @param buffer to modify. * @param size of field to set. * @param text to replace end of string with. * @return pointer to text buffer. */ static char *rset(char *buffer, size_t size, const char *text); /** * Safely set a null terminated string buffer in memory. If the text * is too large to fit into the buffer, it is truncated to the size. * @param buffer to set. * @param size of buffer. Includes null byte at end of string. * @param text to set in buffer. * @return pointer to text buffer. */ static char *set(char *buffer, size_t size, const char *text); /** * Safely set a null terminated string buffer in memory. If the text * is too large to fit into the buffer, it is truncated to the size. * @param buffer to set. * @param size of buffer. Includes null byte at end of string. * @param text to set in buffer. * @param max size of text to set. * @return pointer to text buffer. */ static char *set(char *buffer, size_t size, const char *text, size_t max); /** * Safely append a null terminated string into an existing string in * memory. If the resulting string is too large to fit into the buffer, * it is truncated to the size. * @param buffer to set. * @param size of buffer. Includes null byte at end of string. * @param text to set in buffer. * @return pointer to text buffer. */ static char *add(char *buffer, size_t size, const char *text); /** * Safely append a null terminated string into an existing string in * memory. If the resulting string is too large to fit into the buffer, * it is truncated to the size. * @param buffer to set. * @param size of buffer. Includes null byte at end of string. * @param text to set in buffer. * @param max size of text to append. * @return pointer to text buffer. */ static char *add(char *buffer, size_t size, const char *text, size_t max); /** * Find position of case insensitive substring within a string. * @param text to search in. * @param key string to locate. * @param optional separator chars if formatted as list of keys. * @return substring position if found, or NULL. */ static const char *ifind(const char *text, const char *key, const char *optional); /** * Find position of substring within a string. * @param text to search in. * @param key string to locate. * @param optional separator chars if formatted as list of keys. * @return substring position if found, or NULL. */ static const char *find(const char *text, const char *key, const char *optional); /** * Safe version of strlen function. Accepts NULL as 0 length strings. * @param text string. * @return length of string. */ static size_t count(const char *text); /** * Safe string collation function. * @param text1 to compare. * @param text2 to compare. * @return 0 if equal, >0 if text1 > text2, <0 if text1 < text2. */ static int compare(const char *text1, const char *text2); static inline int collate(const char *text1, const char *text2) {return compare(text1, text2);}; /** * Simple equal test for strings. * @param text1 to test. * @param text2 to test. * @return true if equal and case is same. */ static bool equal(const char *text1, const char *text2); /** * Depreciated string comparison function. * @param text1 to compare. * @param text2 to compare. * @param size limit of strings to compare. * @return 0 if equal, >0 if text1 > text2, <0 if text1 < text2. */ static int compare(const char *text1, const char *text2, size_t size); /** * Simple equal test for strings. * @param text1 to test. * @param text2 to test. * @param size limit of strings to compare. * @return true if equal and case is same. */ static bool equal(const char *text1, const char *text2, size_t size); /** * Depreciated case insensitive string comparison function. * @param text1 to compare. * @param text2 to compare. * @return 0 if equal, >0 if text1 > text2, <0 if text1 < text2. */ static int case_compare(const char *text1, const char *text2); /** * Simple case insensitive equal test for strings. * @param text1 to test. * @param text2 to test. * @return true if equal. */ static bool eq_case(const char *text1, const char *text2); /** * Depreciated case insensitive string comparison function. * @param text1 to compare. * @param text2 to compare. * @param size limit of strings to compare. * @return 0 if equal, >0 if text1 > text2, <0 if text1 < text2. */ static int case_compare(const char *text1, const char *text2, size_t size); /** * Simple case insensitive equal test for strings. * @param text1 to test. * @param text2 to test. * @param size limit of strings to compare. * @return true if equal. */ static bool eq_case(const char *text1, const char *text2, size_t size); /** * Return start of string after characters to trim from beginning. * This function does not modify memory. * @param text buffer to examine. * @param list of characters to skip from start. * @return position in text past lead trim. */ static char *trim(char *text, const char *list); /** * Strip trailing characters from the text string. This function will * modify memory. * @param text buffer to examine. * @param list of characters to chop from trailing end of string. * @return pointer to text buffer. */ static char *chop(char *text, const char *list); /** * Skip lead and remove trailing characters from a text string. This * function will modify memory. * @param text buffer to examine. * @param list of characters to trim and chop. * @return position in text past lead trim. */ static char *strip(char *text, const char *list); /** * Fill a section of memory with a fixed text character. Adds a null * byte at the end. * @param text buffer to fill. * @param size of text buffer with null terminated byte. * @param character to fill with. * @return pointer to text buffer. */ static char *fill(char *text, size_t size, char character); /** * Count instances of characters in a list in a text buffer. * @param text buffer to examine. * @param list of characters to count in buffer. * @return number of instances of the characters in buffer. */ static unsigned ccount(const char *text, const char *list); /** * Find the first occurrence of a character in a text buffer. * @param text buffer to examine. * @param list of characters to search for. * @return pointer to first instance found or NULL. */ static char *find(char *text, const char *list); /** * Offset until next occurrence of character in a text or length. * @param text buffer to examine. * @param list of characters to search for. * @return offset to next occurrence or length of string. */ static size_t seek(char *text, const char *list); /** * Find the last occurrence of a character in a text buffer. * @param text buffer to examine. * @param list of characters to search for. * @return pointer to last instance found or NULL. */ static char *rfind(char *text, const char *list); /** * Duplicate null terminated text into the heap. * @param text to duplicate. * @return duplicate copy of text allocated from heap. */ static char *dup(const char *text); /** * Duplicate null terminated text of specific size to heap. * @param text to duplicate. * @param size of text, maximum space allocated. * @return duplicate copy of text allocated on heap. */ static char *left(const char *text, size_t size); /** * Compute position in string. * @param text of string. * @param offset from start, negative values from end. * @return pointer to string position. */ static const char *pos(const char *text, ssize_t offset); inline static char *right(const char *text, size_t size) {return dup(pos(text, -(signed)size));} inline static char *copy(const char *text, size_t offset, size_t len) {return left(pos(text, offset), len);} static void cut(char *text, size_t offset, size_t len); static void paste(char *text, size_t max, size_t offset, const char *data, size_t len = 0); /** * A thread-safe token parsing routine for strings objects. This * is related to strtok, but with safety checks for NULL values and a * number of enhancements including support for quoted text that may * contain token separators within quotes. The object is modified * as it is parsed. * @param last token position or set to NULL for start of string. * @param list of characters to use as token separators. * @param quote pairs of characters for quoted text or NULL if not used. * @param end of line marker characters or NULL if not used. * @return token extracted from string or NULL if no more tokens found. */ inline char *token(char **last, const char *list, const char *quote = NULL, const char *end = NULL) {return token(c_mem(), last, list, quote, end);}; /** * Convert string to a double value. * @param object to convert. * @param pointer to update with end of parsed value. * @return double value of object. */ inline double tod(char **pointer = NULL) {return strtod(c_mem(), pointer);} /** * Convert string to a long value. * @param object to convert. * @param pointer to update with end of parsed value. * @return long value of object. */ inline long tol(char **pointer = NULL) {return strtol(c_mem(), pointer, 0);} /** * Convert text to a double value. * @param text to convert. * @param pointer to update with end of parsed value. * @return double value of object. */ inline static double tod(const char *text, char **pointer = NULL) {return strtod(text, pointer);} /** * Convert text to a long value. * @param text to convert. * @param pointer to update with end of parsed value. * @return long value of object. */ inline static long tol(const char *text, char **pointer = NULL) {return strtol(text, pointer, 0);} /** * Standard radix 64 encoding. * @param string of encoded text save into. * @param binary data to encode. * @param size of binary data to encode. * @param width of string buffer for data if partial supported. * @return number of bytes encoded. */ static size_t b64encode(char *string, const uint8_t *binary, size_t size, size_t width = 0); /** * Standard radix 64 decoding. * @param binary data to save. * @param string of encoded text. * @param size of destination buffer. * @return number of bytes actually decoded. */ static size_t b64decode(uint8_t *binary, const char *string, size_t size); /** * 24 bit crc as used in openpgp. * @param binary data to sum. * @param size of binary data to sum. * @return 24 bit crc of data. */ static uint32_t crc24(uint8_t *binary, size_t size); /** * ccitt 16 bit crc for binary data. * @param binary data to sum. * @param size of binary data to sum. * @return 16 bit crc. */ static uint16_t crc16(uint8_t *binary, size_t size); /** * Dump hex data to a string buffer. * @param binary memory to dump. * @param string to save into. * @param format string to convert with. * @return number of bytes processed. */ static unsigned hexdump(const unsigned char *binary, char *string, const char *format); /** * Pack hex data from a string buffer. * @param binary memory to pack. * @param string to save into. * @param format string to convert with. * @return number of bytes processed. */ static unsigned hexpack(unsigned char *binary, const char *string, const char *format); static unsigned hexsize(const char *format); }; /** * A string class that uses a cstring buffer that is fixed in memory. * This allows one to manipulate a fixed buffer of text in memory through * the string class. The size of the memory used must include space for * the overhead() size needed for the cstring object control data. * @author David Sugar */ class __EXPORT memstring : public String { public: #if _MSC_VER > 1400 // windows broken dll linkage issue... const static size_t header = sizeof(string::cstring); #else static const size_t header; #endif private: bool resize(strsize_t size); void cow(strsize_t adj = 0); void release(void); protected: cstring *c_copy(void) const; public: /** * Assign the text of a string to our object. * @param object to copy text from. */ inline void operator=(String& object) {set(object.c_str());}; /** * Assign null terminated text to our object. * @param text to copy. */ inline void operator=(const char *text) {set(text);}; /** * Create an instance of a memory string. * @param memory to use for cstring object. * @param size of string. Total size must include space for overhead. * @param fill character for fixed character fields. */ memstring(void *memory, strsize_t size, char fill = 0); /** * Destroy memory string. */ ~memstring(); /** * Create a memory string with memory allocated from the heap. * @param size of string to allocate. Automatically adds control size. * @param fill character for fixed field strings. */ static memstring *create(strsize_t size, char fill = 0); /** * Create a memory string with memory allocated from a pager. * @param pager to allocate memory from. * @param size of string to allocate. Automatically adds control size. * @param fill character for fixed field strings. */ static memstring *create(MemoryProtocol *pager, strsize_t size, char fill = 0); }; /** * A template to create a character array that can be manipulated as a string. * This is a mini string/stringbuf class that supports a subset of * functionality but does not require a complex supporting object. Like * stringbuf, this can be used to create local string variables. * @author David Sugar */ template class charbuf { private: char buffer[S]; public: /** * Create a new character buffer with an empty string. */ inline charbuf() {buffer[0] = 0;} /** * Create a character buffer with assigned text. If the text is * larger than the size of the object, it is truncated. * @param text to assign. */ inline charbuf(const char *text) {String::set(buffer, S, text);} /** * Copy constructor. */ inline charbuf(const charbuf& copy) {String::set(buffer, S, copy.buffer);} /** * Assign null terminated text to the object. * @param text to assign. */ inline void operator=(const char *text) {String::set(buffer, S, text);} /** * Concatenate text into the object. If the text is larger than the * size of the object, then it is truncated. * @param text to append. */ inline void operator+=(const char *text) {String::add(buffer, S, text);} /** * Test if data is contained in the object. * @return true if there is text. */ inline operator bool() const {return buffer[0];} /** * Test if the object is empty. * @return true if the object is empty. */ inline bool operator!() const {return buffer[0] == 0;} /** * Get text by casting reference. * @return pointer to text in object. */ inline operator char *() {return buffer;}; /** * Get text by object pointer reference. * @return pointer to text in object. */ inline char *operator*() {return buffer;}; /** * Array operator to get a character from the object. * @param offset of character in string buffer. * @return character at offset. */ inline char& operator[](size_t offset) const {return buffer[offset];} /** * Get a pointer to an offset in the object by expression operator. * @param offset of character in string buffer. * @return pointer to offset in object. */ inline char *operator()(size_t offset) {return buffer + offset;} /** * Get allocated size of the object. * @return allocated size. */ inline size_t size(void) const {return S;} /** * Get current length of string. * @return length of string. */ inline size_t len(void) const {return strlen(buffer);} }; /** * A convenience type for string. */ typedef String string_t; typedef String::regex stringex_t; /** * A string class that has a predefined string buffer. The string class * and buffer are allocated together as one object. This allows one to use * string objects entirely resident on the local stack as well as on the * heap. Using a string class on the local stack may be more convenient * than a char array since one can use all the features of the class * including assignment and concatenation which a char buffer cannot as * easily do. * @author David Sugar */ template class stringbuf : public memstring { private: char buffer[sizeof(cstring) + S]; public: /** * Create an empty instance of a string buffer. */ inline stringbuf() : memstring(buffer, S) {}; /** * Create a string buffer from a null terminated string. * @param text to place in object. */ inline stringbuf(const char *text) : memstring(buffer, S) {set(text);}; /** * Assign a string buffer from a null terminated string. * @param text to assign to object. */ inline void operator=(const char *text) {set(text);}; /** * Assign a string buffer from another string object. * @param object to assign from. */ inline void operator=(String& object) {set(object.c_str());}; }; #if !defined(_MSWINDOWS_) && !defined(__QNX__) /** * Convenience function for case insensitive null terminated string compare. * @param string1 to compare. * @param string2 to compare. * @return 0 if equal, > 0 if s2 > s1, < 0 if s2 < s1. */ extern "C" inline int stricmp(const char *string1, const char *string2) {return String::case_compare(string1, string2);} /** * Convenience function for case insensitive null terminated string compare. * @param string1 to compare. * @param string2 to compare. * @param max size of string to compare. * @return 0 if equal, > 0 if s2 > s1, < 0 if s2 < s1. */ extern "C" inline int strnicmp(const char *string1, const char *string2, size_t max) {return String::case_compare(string1, string2, max);} #endif /** * Compare two null terminated strings if equal. * @param s1 string to compare. * @param s2 string to compare. * @return true if equal. */ inline bool eq(char const *s1, char const *s2) {return String::equal(s1, s2);} inline bool ne(char const *s1, char const *s2) {return !String::equal(s1, s2);} /** * Compare two null terminated strings if equal up to specified size. * @param s1 string to compare. * @param s2 string to compare. * @param size of string to compare. * @return true if equal. */ inline bool eq(char const *s1, char const *s2, size_t size) {return String::equal(s1, s2, size);} inline bool ne(char const *s1, char const *s2, size_t size) {return !String::equal(s1, s2, size);} /** * Compare two string objects if equal. The left string is an object, * the right may be an object or converted to a const string. The * compare virtual method of the left object is used, so we can do * things like collation order or derived class specific sorting. * @param s1 string to compare. * @param s2 string to compare. * @return true if equal. */ inline bool eq(String &s1, const char *s2) {return s1.compare(s2) == 0;} inline bool ne(String &s1, String &s2) {return s1.compare(s2) != 0;} inline bool lt(String &s1, const char *s2) {return s1.compare(s2) < 0;} inline bool gt(String &s1, const char *s2) {return s1.compare(s2) > 0;} inline bool le(String &s1, const char *s2) {return s1.compare(s2) <= 0;} inline bool ge(String &s1, const char *s2) {return s1.compare(s2) >= 0;} /** * Compare two null terminated strings if equal ignoring case. This is * related to stricmp or gcc strcasecmp. * @param s1 string to compare. * @param s2 string to compare. * @return true if equal. */ inline bool eq_case(char const *s1, char const *s2) {return String::eq_case(s1, s2);} inline bool ne_case(char const *s1, char const *s2) {return !String::eq_case(s1, s2);} /** * Compare two null terminated strings if equal for a specified size * ignoring case. This is related to stricmp or gcc strcasecmp. * @param s1 string to compare. * @param s2 string to compare. * @param size of string to compare. * @return true if equal. */ inline bool eq_case(char const *s1, char const *s2, size_t size) {return String::eq_case(s1, s2, size);} inline String str(const char *string) {return (String)string;} inline String str(String& string) {return (String)string;} inline String str(short value) {String temp(16, "%hd", value); return temp;} inline String str(unsigned short value) {String temp(16, "%hu", value); return temp;} inline String str(long value) {String temp(32, "%ld", value); return temp;} inline String str(unsigned long value) {String temp(32, "%lu", value); return temp;} inline String str(double value) {String temp(40, "%f", value); return temp;} String str(CharacterProtocol& cp, strsize_t size); template<> inline void swap(string_t& s1, string_t& s2) {String::swap(s1, s2);} class __EXPORT strdup_t { private: char *data; public: inline strdup_t() {data = NULL;} inline strdup_t(char *str) {data = str;} inline ~strdup_t() {if(data) ::free(data);} inline strdup_t& operator=(char *str) {if(data) ::free(data); data = str; return *this;} inline operator bool() const {return data != NULL;} inline bool operator!() const {return data == NULL;} inline operator char*() const {return data;} inline const char *c_str(void) const {return data;}; inline const char *operator*() const {return data;} inline char& operator[](int size) {return data[size];} inline char *operator+(size_t size) {return data + size;} }; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/containers.h0000644000175000017500000005444112163025062014673 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Threadsafe object containers. This is used to better define * object containers and manipulating classes which can be presumed to be * fully threadsafe and thread-aware. This has to be defined separately * to assure correct order of preceeding headers as well as to better * organize the library for clarity. Most of these classes and templates * work with classes derived from Object and LinkedObject and make use of * conditional for time constrained acquisition of managed objects. * @file ucommon/containers.h */ #ifndef _UCOMMON_CONTAINERS_H_ #define _UCOMMON_CONTAINERS_H_ #ifndef _UCOMMON_CONFIG_H_ #include #endif #ifndef _UCOMMON_PROTOCOLS_H_ #include #endif #ifndef _UCOMMON_LINKED_H_ #include #endif #ifndef _UCOMMON_MEMORY_H_ #include #endif #ifndef _UCOMMON_THREAD_H_ #include #endif NAMESPACE_UCOMMON /** * Linked allocator helper for linked_allocator template. This is used * to alloc an array of typed objects tied to a free list in a single * operation. * @author David Sugar */ class __EXPORT LinkedAllocator : private Conditional { protected: LinkedObject *freelist; LinkedAllocator(); LinkedObject *get(void); LinkedObject *get(timeout_t timeout); void release(LinkedObject *node); public: /** * Test if there is still objects in the free list. * @return true if there are objects. */ operator bool(); /** * Test if the free list is empty. * @return true if the free list is empty. */ bool operator!(); }; /** * A thread-safe buffer for serializing and streaming class data. While * the queue and stack operate by managing lists of reference pointers to * objects of various mixed kind, the buffer holds physical copies of objects * that being passed through it, and all must be the same size. For this * reason the buffer is normally used through the bufferof template * rather than stand-alone. The buffer is accessed in fifo order. * @author David Sugar */ class __EXPORT Buffer : protected Conditional { private: size_t bufsize, objsize; caddr_t buf, head, tail; unsigned objcount, limit; protected: /** * Create a buffer to hold a series of objects. * @param size of each object in buffer. * @param count of objects in the buffer. */ Buffer(size_t typesize, size_t count); /** * Deallocate buffer and unblock any waiting threads. */ virtual ~Buffer(); /** * Get the next object from the buffer. * @param timeout to wait when buffer is empty in milliseconds. * @return pointer to next object in the buffer or NULL if timed out. */ void *get(timeout_t timeout); /** * Get the next object from the buffer. This blocks until an object * becomes available. * @return pointer to next object from buffer. */ void *get(void); /** * Put (copy) an object into the buffer. This blocks while the buffer * is full. * @param data to copy into the buffer. */ void put(void *data); /** * Put (copy) an object into the buffer. * @param data to copy into the buffer. * @param timeout to wait if buffer is full. * @return true if copied, false if timed out while full. */ bool put(void *data, timeout_t timeout); /** * Release must be called when we get an object from the buffer. This * is because the pointer we return is a physical pointer to memory * that is part of the buffer. The object we get cannot be removed or * the memory modified while the object is being used. */ void release(void); /** * Copy the next object from the buffer. This blocks until an object * becomes available. Buffer is auto-released. * @param data pointer to copy into. */ void copy(void *data); /** * Copy the next object from the buffer. Buffer is auto-released. * @param data pointer to copy into. * @param timeout to wait when buffer is empty in milliseconds. * @return true if object copied, or false if timed out. */ bool copy(void *data, timeout_t timeout); /** * Peek at pending data in buffer. This returns a pointer to * objects relative to the head. In effect it is the same as * get() for item = 0. * @param item to examine in buffer. * @return pointer to item or NULL if invalid item number. */ void *peek(unsigned item); virtual void *invalid(void) const; public: /** * Get the size of the buffer. * @return size of the buffer. */ unsigned size(void); /** * Get the number of objects in the buffer currently. * @return number of objects buffered. */ unsigned count(void); /** * Test if there is data waiting in the buffer. * @return true if buffer has data. */ operator bool(); /** * Test if the buffer is empty. * @return true if the buffer is empty. */ bool operator!(); }; /** * Manage a thread-safe queue of objects through reference pointers. This * can be particularly interesting when used to enqueue/dequeue reference * counted managed objects. Thread-safe access is managed through a * conditional. Both lifo and fifo forms of queue access may be used. A * pool of self-managed member objects are used to operate the queue. This * queue is optimized for fifo access; while lifo is supported, it will be * slow. If you need primarily lifo, you should use stack instead. * @author David Sugar */ class __EXPORT Queue : protected OrderedIndex, protected Conditional { private: mempager *pager; LinkedObject *freelist; size_t used; class __LOCAL member : public OrderedObject { public: member(Queue *q, ObjectProtocol *obj); ObjectProtocol *object; }; friend class member; protected: size_t limit; virtual ObjectProtocol *invalid(void) const; public: /** * Create a queue that uses a memory pager for internally managed * member objects for a specified maximum number of object pointers. * @param pager to use for internal member object or NULL to use heap. * @param number of pointers that can be in the queue or 0 for unlimited. * size limit. */ Queue(mempager *pager = NULL, size_t number = 0); /** * Destroy queue. If no mempager is used, then frees heap. */ ~Queue(); /** * Remove a specific object pointer for the queue. This can remove * a member from any location in the queue, whether beginning, end, or * somewhere in the middle. This also releases the object. * @param object to remove. * @return true if object was removed, false if not found. */ bool remove(ObjectProtocol *object); /** * Post an object into the queue by it's pointer. This can wait for * a specified timeout if the queue is full, for example, for another * thread to remove an object pointer. This also retains the object. * @param object to post. * @param timeout to wait if queue is full in milliseconds. * @return true if object posted, false if queue full and timeout expired. */ bool post(ObjectProtocol *object, timeout_t timeout = 0); /** * Examine pending existing object in queue. Does not remove it. * @param number of elements back. * @return object in queue or NULL if invalid value. */ ObjectProtocol *get(unsigned offset = 0); /** * Get and remove last object posted to the queue. This can wait for * a specified timeout of the queue is empty. The object is still * retained and must be released or deleted by the receiving function. * @param timeout to wait if empty in milliseconds. * @return object from queue or NULL if empty and timed out. */ ObjectProtocol *fifo(timeout_t timeout = 0); /** * Get and remove first object posted to the queue. This can wait for * a specified timeout of the queue is empty. The object is still * retained and must be released or deleted by the receiving function. * @param timeout to wait if empty in milliseconds. * @return object from queue or NULL if empty and timed out. */ ObjectProtocol *lifo(timeout_t timeout = 0); /** * Get number of object points currently in the queue. * @return number of objects in queue. */ size_t count(void); }; /** * Manage a thread-safe stack of objects through reference pointers. This * Thread-safe access is managed through a conditional. This differs from * the queue in lifo mode because delinking the last object is immediate, * and because it has much less overhead. A pool of self-managed * member objects are used to operate the stack. * @author David Sugar */ class __EXPORT Stack : protected Conditional { private: LinkedObject *freelist, *usedlist; mempager *pager; size_t used; class __LOCAL member : public LinkedObject { public: member(Stack *s, ObjectProtocol *obj); ObjectProtocol *object; }; friend class member; protected: size_t limit; virtual ObjectProtocol *invalid(void) const; public: /** * Create a stack that uses a memory pager for internally managed * member objects for a specified maximum number of object pointers. * @param pager to use for internal member object or NULL to use heap. * @param number of pointers that can be in the stack or 0 if unlimited. */ Stack(mempager *pager = NULL, size_t number = 0); /** * Destroy queue. If no pager is used, then frees heap. */ virtual ~Stack(); /** * Remove a specific object pointer for the queue. This can remove * a member from any location in the queue, whether beginning, end, or * somewhere in the middle. This also releases the object. * @param object to remove. * @return true if object was removed, false if not found. */ bool remove(ObjectProtocol *object); /** * Push an object into the stack by it's pointer. This can wait for * a specified timeout if the stack is full, for example, for another * thread to remove an object pointer. This also retains the object. * @param object to push. * @param timeout to wait if stack is full in milliseconds. * @return true if object pushed, false if stack full and timeout expired. */ bool push(ObjectProtocol *object, timeout_t timeout = 0); /** * Get and remove last object pushed on the stack. This can wait for * a specified timeout of the stack is empty. The object is still * retained and must be released or deleted by the receiving function. * @param timeout to wait if empty in milliseconds. * @return object pulled from stack or NULL if empty and timed out. */ ObjectProtocol *pull(timeout_t timeout = 0); /** * Examine an existing object on the stack. * @param offset to stack entry. * @return object examined. */ ObjectProtocol *get(unsigned offset = 0); /** * Get number of object points currently in the stack. * @return number of objects in stack. */ size_t count(void); const ObjectProtocol *peek(timeout_t timeout = 0); }; /** * Linked allocator template to gather linked objects. This allocates the * object pool in a single array as a single heap allocation, and releases * the whole pool with a single delete when done. It is also threadsafe. * The types used must be derived of LinkedObject. * @author David Sugar */ template class linked_allocator : public LinkedAllocator { private: T* array; public: inline linked_allocator(size_t size) : LinkedAllocator() { array = new T[size]; for(unsigned i = 0; i < size; ++i) array[i].enlist(&freelist); } ~linked_allocator() {delete[] array;}; inline T *get(void) {return static_cast(LinkedAllocator::get());}; inline T *get(timeout_t timeout) {return static_cast(LinkedAllocator::get(timeout));}; inline void release(T *node) {LinkedAllocator::release(node);}; }; /** * A templated typed class for buffering of objects. This operates as a * fifo buffer of typed objects which are physically copied into the buffer. * The objects that are buffered are accessed from allocated buffer space. * As designed this may be used with multiple producer threads and one * consumer thread. To use multiple consumers, one can copy the typed object * from the buffer through the get pointer and then call release. The * copied object can then be used safely. This is what the copy method is * used for. * @author David Sugar */ template class bufferof : public Buffer { public: /** * Create a buffer to hold a series of typed objects. * @param count of typed objects in the buffer. */ inline bufferof(unsigned capacity) : Buffer(sizeof(T), capacity) {}; /** * Get the next typed object from the buffer. This blocks until an object * becomes available. * @return pointer to next typed object from buffer. */ inline T *get(void) {return static_cast(get());}; /** * Get the next typed object from the buffer. * @param timeout to wait when buffer is empty in milliseconds. * @return pointer to next typed object in the buffer or NULL if timed out. */ inline T *get(timeout_t timeout) {return static_cast(get(timeout));}; /** * Put (copy) a typed object into the buffer. This blocks while the buffer * is full. * @param object to copy into the buffer. */ inline void put(T *object) {put(object);}; /** * Put (copy) an object into the buffer. * @param object to copy into the buffer. * @param timeout to wait if buffer is full. * @return true if copied, false if timed out while full. */ inline bool put(T *object, timeout_t timeout) {return put(object, timeout);}; /** * Copy the next typed object from the buffer. This blocks until an object * becomes available. * @param object pointer to copy typed object into. */ inline void copy(T *object) {copy(object);}; /** * Copy the next typed object from the buffer. * @param object pointer to copy typed object into. * @param timeout to wait when buffer is empty in milliseconds. * @return true if object copied, or false if timed out. */ inline bool get(T *object, timeout_t timeout) {return copy(object, timeout);}; /** * Examine past item in the buffer. This is a typecast of the peek * operation. * @param item in buffer. * @return item pointer if valid or NULL. */ inline const T& at(unsigned item) {return static_cast(Buffer::peek(item));}; /** * Examine past item in the buffer. This is a typecast of the peek * operation. * @param item in buffer. * @return item pointer if valid or NULL. */ inline T&operator[](unsigned item) {return static_cast(Buffer::peek(item));}; inline T* operator()(unsigned offset = 0) {return static_cast(Buffer::peek(offset));} }; /** * A templated typed class for thread-safe stack of object pointers. This * allows one to use the stack class in a typesafe manner for a specific * object type derived from Object rather than generically for any derived * object class. * @author David Sugar */ template class stackof : public Stack { public: /** * Create templated stack of typed objects. * @param memory pool for internal use of stack. * @param size of stack to construct. Uses 0 if no size limit. */ inline stackof(mempager *memory, size_t size = 0) : Stack(memory, size) {}; /** * Remove a specific typed object pointer for the stack. This can remove * a member from any location in the stack, whether beginning, end, or * somewhere in the middle. This releases the object. * @param object to remove. * @return true if object was removed, false if not found. */ inline bool remove(T *object) {return Stack::remove(object);}; /** * Push a typed object into the stack by it's pointer. This can wait for * a specified timeout if the queue is full, for example, for another * thread to remove an object pointer. This retains the object. * @param object to push. * @param timeout to wait if queue is full in milliseconds. * @return true if object pushed, false if queue full and timeout expired. */ inline bool push(T *object, timeout_t timeout = 0) {return Stack::push(object);}; /** * Get and remove last typed object posted to the stack. This can wait for * a specified timeout of the stack is empty. The object is still retained * and must be released or deleted by the receiving function. * @param timeout to wait if empty in milliseconds. * @return object from queue or NULL if empty and timed out. */ inline T *pull(timeout_t timeout = 0) {return static_cast(Stack::pull(timeout));}; /** * Examine last typed object posted to the stack. This can wait for * a specified timeout of the stack is empty. * @param timeout to wait if empty in milliseconds. * @return object in queue or NULL if empty and timed out. */ inline const T *peek(timeout_t timeout = 0) {return static_cast(Stack::peek(timeout));}; inline T* operator()(unsigned offset = 0) {return static_cast(Stack::get(offset));} /** * Examine past item in the stack. This is a typecast of the peek * operation. * @param offset in stack. * @return item pointer if valid or NULL. */ inline const T& at(unsigned offset = 0) {return static_cast(Stack::get(offset));}; /** * Examine past item in the stack. This is a typecast of the peek * operation. * @param offset in stack. * @return item pointer if valid or NULL. */ inline const T& operator[](unsigned offset) {return static_cast(Stack::get(offset));}; }; /** * A templated typed class for thread-safe queue of object pointers. This * allows one to use the queue class in a typesafe manner for a specific * object type derived from Object rather than generically for any derived * object class. * @author David Sugar */ template class queueof : public Queue { public: /** * Create templated queue of typed objects. * @param memory pool for internal use by queue. * @param size of queue to construct. Uses 0 if no size limit. */ inline queueof(mempager *memory, size_t size = 0) : Queue(memory, size) {}; /** * Remove a specific typed object pointer for the queue. This can remove * a member from any location in the queue, whether beginning, end, or * somewhere in the middle. This releases the object. * @param object to remove. * @return true if object was removed, false if not found. */ inline bool remove(T *object) {return Queue::remove(object);}; /** * Post a typed object into the queue by it's pointer. This can wait for * a specified timeout if the queue is full, for example, for another * thread to remove an object pointer. This retains the object. * @param object to post. * @param timeout to wait if queue is full in milliseconds. * @return true if object posted, false if queue full and timeout expired. */ inline bool post(T *object, timeout_t timeout = 0) {return Queue::post(object);}; /** * Get and remove first typed object posted to the queue. This can wait for * a specified timeut of the queue is empty. The object is still retained * and must be released or deleted by the receiving function. * @param timeout to wait if empty in milliseconds. * @return object from queue or NULL if empty and timed out. */ inline T *fifo(timeout_t timeout = 0) {return static_cast(Queue::fifo(timeout));}; /** * Get and remove last typed object posted to the queue. This can wait for * a specified timeout of the queue is empty. The object is still retained * and must be released or deleted by the receiving function. * @param timeout to wait if empty in milliseconds. * @return object from queue or NULL if empty and timed out. */ inline T *lifo(timeout_t timeout = 0) {return static_cast(Queue::lifo(timeout));}; /** * Examine past item in the queue. This is a typecast of the peek * operation. * @param offset in queue. * @return item pointer if valid or NULL. */ inline const T& at(unsigned offset = 0) {return static_cast(Queue::get(offset));}; /** * Examine past item in the queue. This is a typecast of the peek * operation. * @param offset in queue. * @return item pointer if valid or NULL. */ inline T& operator[](unsigned offset) {return static_cast(Queue::get(offset));}; inline T* operator()(unsigned offset = 0) {return static_cast(Queue::get(offset));} }; /** * Convenience type for using thread-safe object stacks. */ typedef Stack stack_t; /** * Convenience type for using thread-safe object fifo (queue). */ typedef Queue fifo_t; END_NAMESPACE #endif ucommon-6.0.7/inc/ucommon/stl.h0000644000175000017500000000254612163025062013327 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Placeholder for future classes that require stl support. * @file ucommon/stl.h */ #if defined(OLD_STDCPP) || defined(NEW_STDCPP) #if !defined(_MSC_VER) || _MSC_VER >= 1400 #ifndef _UCOMMON_STL_H_ #define _UCOMMON_STL_H_ #define _UCOMMON_STL_EXTENDED_ #ifndef _UCOMMON_PLATFORM_H_ #include #endif #include // example... NAMESPACE_UCOMMON /* In the future we may introduce optional classes which require and/or build upon the standard template library. This header indicates how and where they may be added. */ END_NAMESPACE #endif #endif #endif ucommon-6.0.7/inc/ucommon/protocols.h0000644000175000017500000004431612163025062014552 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . /** * Abstract interfaces and support. This is a set of "protocols", a concept * borrowed from other object oriented languages, to define interfaces for * low level services. By using a protocol base class which offers both * virtuals and support methods only, one can easily stack and share these * as common base classes without having to consider when the final derived * object implements them. Core protocol methods always are tagged with a * _ prefix to make it easier to track their derivation. * @file ucommon/protocols.h * @author David Sugar */ #ifndef _UCOMMON_PROTOCOLS_H_ #define _UCOMMON_PROTOCOLS_H_ #ifndef _UCOMMON_CPR_H_ #include #endif NAMESPACE_UCOMMON class String; class StringPager; class __EXPORT MemoryProtocol { protected: friend class MemoryRedirect; /** * Protocol to allocate memory from the pager heap. The size of the * request must be less than the size of the memory page used. The * actual method is in a derived or stacked object. * @param size of memory request. * @return allocated memory or NULL if not possible. */ virtual void *_alloc(size_t size) = 0; /** * Allocation failure handler. */ virtual void fault(void) const; public: virtual ~MemoryProtocol(); /** * Convenience function. * @param size of memory request. * @return alocated memory or NULL if not possible. */ inline void *alloc(size_t size) {return _alloc(size);}; /** * Allocate memory from the pager heap. The size of the request must be * less than the size of the memory page used. The memory is initialized * to zero. This uses alloc. * @param size of memory request. * @return allocated memory or NULL if not possible. */ void *zalloc(size_t size); /** * Duplicate NULL terminated string into allocated memory. This uses * alloc. * @param string to copy into memory. * @return allocated memory with copy of string or NULL if cannot allocate. */ char *dup(const char *string); /** * Duplicate existing memory block into allocated memory. This uses alloc. * @param memory to data copy from. * @param size of memory to allocate. * @return allocated memory with copy or NULL if cannot allocate. */ void *dup(void *memory, size_t size); }; /** * A redirection base class for the memory protocol. This is used because * sometimes we choose a common memory pool to manage different objects. * @author David Sugar */ class __EXPORT MemoryRedirect : public MemoryProtocol { private: MemoryProtocol *target; public: MemoryRedirect(MemoryProtocol *protocol); virtual void *_alloc(size_t size); }; /** * Common locking protocol. This is used for objects that may internally * have sync'd functions, directly or in a derived class, that lock the * current object. The default handlers do nothing but offer the virtuals * as a stub. * @author David Sugar */ class __EXPORT LockingProtocol { protected: virtual void _lock(void); virtual void _unlock(void); public: virtual ~LockingProtocol(); }; /** * Used for forming stream output. We would create a derived class who's * constructor creates an internal string object, and a single method to * extract that string. * @author David Sugar */ class __EXPORT PrintProtocol { public: virtual ~PrintProtocol(); /** * Extract formatted string for object. */ virtual const char *_print(void) const = 0; }; /** * Used for processing input. We create a derived class that processes a * single character of input, and returns a status value. EOF means it * accepts no more input and any value other than 0 is a character to also * unget. Otherwise 0 is good to accept more input. The constructor is * used to reference a final destination object in the derived class. * @author David Sugar */ class __EXPORT InputProtocol { public: virtual ~InputProtocol(); /** * Extract formatted string for object. * @param character code we are pushing. * @return 0 to keep processing, EOF if done, or char to unget. */ virtual int _input(int code) = 0; }; /** * Common character processing protocol. This is used to access a character * from some type of streaming buffer or memory object. * @author David Sugar */ class __EXPORT CharacterProtocol { protected: const char *eol; int back; CharacterProtocol(); /** * Get the next character. * @return next character or EOF. */ virtual int _getch(void) = 0; /** * Put the next character. * @param code to put. * @return code or EOF if cannot put. */ virtual int _putch(int code) = 0; /** * Write to back buffer. Mostly used for input format processing. * @param code to write into backbuffer. */ inline void putback(int code) {back = code;} /** * Set end of line marker. Normally this is set to cr & lf, which * actually supports both lf alone and cr/lf termination of lines. * However, putline() will always add the full cr/lf if this mode is * used. This option only effects getline() and putline(). * @param string for eol for getline and putline. */ inline void seteol(const char *string) {eol = string;}; public: virtual ~CharacterProtocol(); /** * Get the next character. * @return next character or EOF. */ inline int getchar(void) {return _getch();}; /** * Put the next character. * @param code to put. * @return code or EOF if cannot put. */ inline int putchar(int code) {return _putch(code);}; size_t print(const PrintProtocol& format); size_t input(InputProtocol& format); /** * Get text as a line of input from the buffer. The eol character(s) * are used to mark the end of a line. Because the end of line character * is stripped, the length of the string may be less than the actual * count read. If at the end of the file buffer and unable to read more * data an error occured then 0 is returned. * @param string to save input into. * @param size limit of string to save. * @return count of characters actually read or 0 if at end of data. */ size_t getline(char *string, size_t size); /** * Get a string as a line of input from the buffer. The eol character(s) * are used to mark the end of a line. Because the end of line character * is stripped, the length of the string may be less than the actual * count read. If at the end of the file buffer and unable to read more * data an error occured then 0 is returned. * @param buffer to save input into. * @return count of characters actually read or 0 if at end of data. */ size_t getline(String& buffer); /** * Put a string as a line of output to the buffer. The eol character is * appended to the end. * @param string to write. * @return total characters successfully written, including eol chars. */ size_t putline(const char *string); size_t putchars(const char *string, size_t count = 0); /** * Load input to a string list. The string list filter method is used to * control loading. * @param list to load into. * @return number of items loaded. */ size_t load(StringPager *list); /** * Save output from a string list. * @param list to save from. * @return number of items loaded. */ size_t save(const StringPager *list); }; /** * Common buffer protocol class. This is used to create objects which will * stream character data as needed. This class can support bidirectional * streaming as may be needed for serial devices, sockets, and pipes. The * buffering mechanisms are hidden from derived classes, and two virtuals * are used to communicate with the physical transport. * @author David Sugar */ class __EXPORT BufferProtocol : public CharacterProtocol { public: typedef enum {RDONLY, WRONLY, RDWR} mode_t; private: char *buffer; char *input, *output; size_t bufsize, bufpos, insize, outsize; bool end; protected: const char *format; /** * Construct an empty (unallocated) buffer. */ BufferProtocol(); /** * Construct a buffer of pre-allocated size and access type. * @param size of buffer to allocate. * @param access mode of buffer. */ BufferProtocol(size_t size, mode_t access = RDWR); /** * Destroy object by releasing buffer memory. */ virtual ~BufferProtocol(); /** * Allocation error handler. */ virtual void fault(void) const; /** * Allocate I/O buffer(s) of specified size. If a buffer is currently * allocated, it is released. * @param size of buffer to allocate. * @param access mode of buffer. */ void allocate(size_t size, mode_t access = RDWR); /** * Release (free) buffer memory. */ void release(void); /** * Request workspace in output buffer. This returns a pointer to * memory from the output buffer and advances the output position. * This is sometimes used for a form of zero copy write. * @param size of request area. * @return data pointer or NULL if not available. */ char *request(size_t size); /** * Gather returns a pointer to contiguous input of specified size. * This may require moving the input data in memory. * @param size of gather space. * @return data pointer to gathered data or NULL if not available. */ char *gather(size_t size); /** * Method to push buffer into physical i/o (write). The address is * passed to this virtual since it is hidden as private. * @param address of data to push. * @param size of data to push. * @return number of bytes written, 0 on error. */ virtual size_t _push(const char *address, size_t size) = 0; /** * Method to pull buffer from physical i/o (read). The address is * passed to this virtual since it is hidden as private. * @param address of buffer to pull data into. * @param size of buffer area being pulled.. * @return number of read written, 0 on error or end of data. */ virtual size_t _pull(char *address, size_t size) = 0; /** * Method to get low level i/o error. * @return error from low level i/o methods. */ virtual int _err(void) const = 0; /** * Method to clear low level i/o error. */ virtual void _clear(void) = 0; /** * Return true if blocking. */ virtual bool _blocking(void); /** * Check if data is pending. */ virtual bool _pending(void); /** * Flush buffer to physical i/o. */ virtual bool _flush(void); virtual int _getch(void); virtual int _putch(int ch); /** * Get current input position. Sometimes used to help compute and report * a "tell" offset. * @return offset of input buffer. */ inline size_t input_pending(void) {return bufpos;}; /** * Get current output position. Sometimes used to help compute a * "trunc" operation. */ inline size_t output_waiting(void) {return outsize;}; public: const char *endl(void) {return eol;} /** * Put memory into the buffer. If count is 0 then put as NULL * terminated string. * @param address of characters to put into buffer. * @param count of characters to put into buffer. * @return number of characters actually written. */ size_t put(const void *address, size_t count); /** * Get memory from the buffer. * @param address of characters save from buffer. * @param count of characters to get from buffer. * @return number of characters actually copied. */ size_t get(void *address, size_t count); /** * Print formatted string to the buffer. The maximum output size is * the buffer size, and the operation flushes the buffer. * @param format string. * @return number of bytes written. */ size_t printf(const char *format, ...) __PRINTF(2, 3); /** * Flush buffered memory to physical I/O. * @return true on success, false if not active or fails. */ inline bool flush(void) {return _flush();} /** * Purge any pending input or output buffer data. */ void purge(void); /** * Reset input buffer state. Drops any pending input. */ void reset(void); /** * Check if at end of input. * @return true if end of data, false if input still buffered. */ bool eof(void); /** * See if buffer open. * @return true if buffer active. */ inline operator bool() {return buffer != NULL;} /** * See if buffer closed. * @return true if buffer inactive. */ inline bool operator!() {return buffer == NULL;} /** * See if buffer open. * @return true if buffer active. */ inline bool is_open(void) {return buffer != NULL;} /** * See if input active. * @return true if input active. */ inline bool is_input(void) {return input != NULL;} /** * See if output active. * @return true if output active. */ inline bool is_output(void) {return output != NULL;} /** * See if pending input. * @return true if input pending. */ inline bool is_pending(void) {return _pending();} /** * Set eof flag. */ inline void seteof(void) {end = true;} inline int err(void) {return _err();} template inline size_t write(const T& data) {return put(&data, sizeof(T));} template inline size_t read(T& data) {return get(&data, sizeof(T));} template inline size_t write(const T* data, unsigned count) {return put(data, sizeof(T) * count) / sizeof(T);} template inline size_t read(T* data, unsigned count) {return get(data, sizeof(T) * count) / sizeof(T);} }; /** * A common base class for all managed objects. This is used to manage * objects that might be linked or reference counted. The base class defines * only core virtuals some common public methods that should be used by * all inherited object types. * @author David Sugar */ class __EXPORT ObjectProtocol { public: /** * Method to retain (or increase retention) of an object. */ virtual void retain(void) = 0; /** * Method to release (or decrease retention) of an object. */ virtual void release(void) = 0; /** * Required virtual destructor. */ virtual ~ObjectProtocol(); /** * Retain (increase retention of) object when copying. */ ObjectProtocol *copy(void); /** * Increase retention operator. */ inline void operator++(void) {retain();}; /** * Decrease retention operator. */ inline void operator--(void) {release();}; }; /** * At least with gcc, linking of stream operators was broken. This provides * an auxillory class to solve the issue. */ class __EXPORT _character_operators { private: inline _character_operators() {}; public: static CharacterProtocol& print(CharacterProtocol& p, const char *s); static CharacterProtocol& print(CharacterProtocol& p, const char& ch); static CharacterProtocol& input(CharacterProtocol& p, char& ch); static CharacterProtocol& input(CharacterProtocol& p, String& str); static CharacterProtocol& print(CharacterProtocol& p, const long& value); static CharacterProtocol& input(CharacterProtocol& p, long& value); static CharacterProtocol& print(CharacterProtocol& p, const double& value); static CharacterProtocol& input(CharacterProtocol& p, double& value); }; inline CharacterProtocol& operator<< (CharacterProtocol& p, const char *s) {return _character_operators::print(p, s);} inline CharacterProtocol& operator<< (CharacterProtocol& p, const char& ch) {return _character_operators::print(p, ch);} inline CharacterProtocol& operator>> (CharacterProtocol& p, char& ch) {return _character_operators::input(p, ch);} inline CharacterProtocol& operator>> (CharacterProtocol& p, String& str) {return _character_operators::input(p, str);} inline CharacterProtocol& operator<< (CharacterProtocol& p, const PrintProtocol& format) {p.print(format); return p;} inline CharacterProtocol& operator>> (CharacterProtocol& p, InputProtocol& format) {p.input(format); return p;} inline CharacterProtocol& operator<< (CharacterProtocol& p, const StringPager& list) {p.save(&list); return p;} inline CharacterProtocol& operator>> (CharacterProtocol& p, StringPager& list) {p.load(&list); return p;} inline CharacterProtocol& operator<< (CharacterProtocol& p, const long& value) {return _character_operators::print(p, value);} inline CharacterProtocol& operator>> (CharacterProtocol& p, long& value) {return _character_operators::input(p, value);} inline CharacterProtocol& operator<< (CharacterProtocol& p, const double& value) {return _character_operators::print(p, value);} inline CharacterProtocol& operator>> (CharacterProtocol& p, double& value) {return _character_operators::input(p, value);} END_NAMESPACE #endif ucommon-6.0.7/inc/Makefile.am0000644000175000017500000000120512163025062012722 00000000000000# Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = $(LT_VERSION) -release $(LT_RELEASE) AM_CXXFLAGS = $(UCOMMON_FLAGS) EXTRA_DIST = *.cmake SUBDIRS = ucommon commoncpp ucommon-6.0.7/inc/Makefile.in0000644000175000017500000004634012175171470012754 00000000000000# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = inc DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ucommon-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKFLAGS = @CHECKFLAGS@ COMPAT = @COMPAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_GENERIC = @LT_GENERIC@ LT_VERSION = @LT_VERSION@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SECURE = @SECURE@ SECURE_LIBS = @SECURE_LIBS@ SECURE_LOCAL = @SECURE_LOCAL@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UCOMMON_CFGPATH = @UCOMMON_CFGPATH@ UCOMMON_CLINK = @UCOMMON_CLINK@ UCOMMON_FLAGS = @UCOMMON_FLAGS@ UCOMMON_INCLUDES = @UCOMMON_INCLUDES@ UCOMMON_LIBC = @UCOMMON_LIBC@ UCOMMON_LIBS = @UCOMMON_LIBS@ UCOMMON_LINKED = @UCOMMON_LINKED@ UCOMMON_LOCALE = @UCOMMON_LOCALE@ UCOMMON_MODEL = @UCOMMON_MODEL@ UCOMMON_PREFIX = @UCOMMON_PREFIX@ UCOMMON_VARPATH = @UCOMMON_VARPATH@ UCOMMON_VISIBILITY = @UCOMMON_VISIBILITY@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ includes = @includes@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libs = @libs@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = $(LT_VERSION) -release $(LT_RELEASE) AM_CXXFLAGS = $(UCOMMON_FLAGS) EXTRA_DIST = *.cmake SUBDIRS = ucommon commoncpp all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu inc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu inc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ucommon-6.0.7/aclocal.m40000644000175000017500000127573512175171465012017 00000000000000# generated automatically by aclocal 1.14 -*- Autoconf -*- # Copyright (C) 1996-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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # 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($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # 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) $(top_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 # 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], [[!?.]$], [], [.]) )]) # _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 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 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 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 # 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. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _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. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _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. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _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. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _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'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [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], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _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'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [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], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _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'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [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], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _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'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [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]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) # 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. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # 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. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # 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. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # 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. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # 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. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # 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. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) # 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 m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [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) ]) # 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. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) 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])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # 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. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # PKG_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable pkgconfigdir as the location where a module # should install pkg-config .pc files. By default the directory is # $libdir/pkgconfig, but the default can be changed by passing # DIRECTORY. The user can override through the --with-pkgconfigdir # parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_INSTALLDIR # PKG_NOARCH_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable noarch_pkgconfigdir as the location where a # module should install arch-independent pkg-config .pc files. By # default the directory is $datadir/pkgconfig, but the default can be # changed by passing DIRECTORY. The user can override through the # --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_NOARCH_INSTALLDIR # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ------------------------------------------- # Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR # Copyright (C) 2002-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_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-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. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # 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) 1999-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. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-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_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-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. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-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_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-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. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-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_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- 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_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # -*- Autoconf -*- # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # # Copyright (C) 1996-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. AC_DEFUN([AM_CONFIG_HEADER], [AC_DIAGNOSE([obsolete], ['$0': this macro is obsolete. You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl AC_CONFIG_HEADERS($@)]) AC_DEFUN([AM_PROG_CC_STDC], [AC_PROG_CC am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc AC_DIAGNOSE([obsolete], ['$0': this macro is obsolete. You should simply use the 'AC][_PROG_CC' macro instead. Also, your code should no longer depend upon 'am_cv_prog_cc_stdc', but upon 'ac_cv_prog_cc_stdc'.])]) AC_DEFUN([AM_C_PROTOTYPES], [AC_FATAL([automatic de-ANSI-fication support has been removed])]) AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-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_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-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_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-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_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-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_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-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_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-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_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # 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($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-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_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR ucommon-6.0.7/Makefile.am0000644000175000017500000000276512163025062012165 00000000000000# Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. AUTOMAKE_OPTIONS = no-dependencies dist-zip EXTRA_DIST = autogen.sh README* *.pc.in *.spec.in *.spec *-config.in \ *-config.1 Doxyfile cmodel.sh BUILDS SUPPORT COPYING* COPYRIGHT \ CMakeLists.txt ucommon-config.cmake ucommon.pc.cmake \ commoncpp-config.cmake commoncpp.pc.cmake ucommon.spec.cmake \ ucommon-config.h.cmake doxy.config.cmake directive.in DIST_SUBDIRS = corelib commoncpp openssl gnutls nossl utils inc test SUBDIRS = corelib @SECURE@ @COMPAT@ utils inc test pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = ucommon.pc commoncpp.pc scriptdir = $(bindir) script_SCRIPTS = ucommon-config commoncpp-config man_MANS = ucommon-config.1 commoncpp-config.1 .phony: doxy doxy: -rm -rf doc $(DOXYGEN) Doxyfile clean-local: -rm -rf doc dist-hook: cleandist cleandist: @rm -f ${PACKAGE}-[0-9]*.tar.gz @rm -f ${PACKAGE}-[0-9]*.tar.bz2 @rm -f ${PACKAGE}-[0-9]*.shar.gz @rm -f ${PACKAGE}-[0-9]*.zip @rm -f *${PACKAGE}*.rpm @rm -f *${PACKAGE}*.deb @rm -f ${PACKAGE}_*.gz @rm -f ${PACKAGE}_*.dsc @rm -f *.changes ucommon-6.0.7/ucommon-config.10000644000175000017500000000600012163025062013115 00000000000000.\" ucommon-config - script to get information about ucommon library .\" Copyright (c) 2009 David Sugar .\" .\" This manual page is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 3 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. .\" .\" This manual page is written especially for Debian GNU/Linux. .\" .TH ucommon-config "1" "July 2009" "GNU Common C++ uCommon" "GNU Telephony" .SH NAME ucommon-config \- script to get information about ucommon library .SH SYNOPSIS .B ucommon-config .RB [ options ] .SH DESCRIPTION .B ucommon-config is a tool that is used to configure to determine the compiler and linker flags that should be used to compile and link programs that use the .BR ucommon library. .IR Note : .B ucommon-config is provided for compatibility with legacy software only. Current projects should use .B pkg-config instead! .SH OPTIONS .TP .B --version Print the currently installed version of .B ucommon on the standard output. .TP .B --secure Print additional libraries needed to link a program with .BR ucommon secure crytographic library .TP .B --scripting Print additional linker flags needed to link a program with .BR ucommon script library .TP .B --includes Print the include directory for .BR ucommon headers .TP .B --libs Print the linker flags that are necessary to link a program with .BR ucommon .TP .B --plugins Print the directory for .BR ucommon plugins .TP .B --cflags Print the compiler flags that are necessary to compile a program with .BR ucommon .TP .BI --prefix= PREFIX If specified, use .I PREFIX instead of the installation prefix that .B ucommon was built with when computing the output for the .B --cflags and .B --libs options. This option is also used for the exec prefix if .B --exec-prefix was not specified. This option must be specified before any .B --libs or .B --cflags options. .TP .BI --exec-prefix= PREFIX If specified, use .I PREFIX instead of the installation exec prefix that .B ucommon was built with when computing the output for the .B --cflags and .B --libs options. This option must be specified before any .B --libs or .B --cflags options. .SH "SEE ALSO" .IR pkg-config (1). .SH AUTHOR .B ucommon-config was written by David Sugar . .SH COPYRIGHT Copyright \(co 2009 David Sugar, Tycho Softworks. .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ucommon-6.0.7/ucommon.pc.in0000644000175000017500000000041612163025062012526 00000000000000clink=@UCOMMON_CLINK@ model=@UCOMMON_MODEL@ includes=@UCOMMON_INCLUDES@ minimal="-lucommon @UCOMMON_LINKED@" Name: ucommon Description: GNU uCommon C++ class framework Version: @VERSION@ Libs: -lusecure -lucommon @SECURE_LIBS@ @UCOMMON_LINKED@ Cflags: @UCOMMON_FLAGS@ ucommon-6.0.7/AUTHORS0000644000175000017500000000054512163025062011173 00000000000000Authors of GNU uCommon. David Sugar designed and implemented commoncpp & ucommon Eric Schendel recent improvements on the serial I/O classes Angelo Naselli as contributor and for bug fixing Leandro Melo de Sales as contributor for DCCP socket support ucommon-6.0.7/README0000644000175000017500000001203412163025062010777 00000000000000GNU uCommon C++ is meant as a very light-weight C++ library to facilitate using C++ design patterns even for very deeply embedded applications, such as for systems using uclibc along with posix threading support. For this reason, uCommon disables language features that consume memory or introduce runtime overhead, such as rtti and exception handling, and assumes one will mostly be linking applications with other pure C based libraries rather than using the overhead of the standard C++ library and other class frameworks. GNU uCommon C++ by default does build with support for the bloated ansi standard c++ library unless this is changed at configure time with the --disable-stdcpp option. This is to assure maximum portability and will be used to merge UCommon with GNU Common C++ to form GNU Common C++ 2.0. Some specific features are tested for when stdc++ is enabled, and these will be used to add back in GNU Common C++ classes such as TCP Stream and serialization. GNU uCommon C++ introduces some Objective-C based design patterns, such as reference counted objects, memory pools, smart pointers, and offers dynamic typing through very light use of inline templates for pure type translation that are then tied to concrete base classes to avoid template instantiation issues. C++ auto-variable automation is also used to enable referenced objects to be deleted and threading locks to be released that are acquired automatically when methods return rather than requiring one to explicitly code for these things. GNU uCommon C++ depends on and when necessary will introduce some portable C replacement functions, especially for sockets, such as adding getaddrinfo for platforms which do not have it, or when threadsafe versions of existing C library functions are needed. Basic socket support for connecting to named destinations and multicast addresses, and binding to interfaces with IPV4 and IPV6 addresses is directly supported. Support for high resolution timing and Posix realtime clocks are also used when available. While GNU uCommon C++ has been influenced by GNU Common C++, it introduces some new concepts for handling of thread locking and synchronization. GNU uCommon C++ also builds all higher level thread synchronization objects directly from conditionals. Hence, on platforms which for example do not have rwlocks, barriers, or semaphores, these are still found in uCommon. A common and consistent call methodology is used for all locks, whether mutex, rw, or semaphore, based on whether used for exclusive or "shared" locking. GNU uCommon C++ requires some knowledge of compiler switches and options to disable language features, the C++ runtime and stdlibs, and associated C++ headers. The current version supports compiling with GCC, which is commonly found on GNU/Linux, OS/X, BSD based systems, and many other platforms; and the Sun Workshop compiler, which is offered as an example how to adapt UCommon for additional compilers. GNU uCommon C++ may also be built with GCC cross compiling for mingw32 to build Microsoft Windows targets natively. The cmake build system can also be used, to create project files for various platforms including xcode for OS/X and various Microsoft Visual Studio project file formats. The minimum platform support for uCommon is a modern and working posix pthread threading library. I use a subset of posix threads to assure wider portability by avoiding more specialized features like process shared synchronization objects, pthread rwlocks and pthread semaphores, as these are not implemented on all platforms that I have found. I also eliminate the practice and dependency on pthread automatic cancellation behavior, which otherwise introduces much greater complexity to user applications and can often lead to defective coding practices. The first three releases of uCommon were introduced in 1999-2000 as a pure "C" library for embedded targets, and had not seen an update in 7 years. Hence I have had the package name in use for a very long time. Work on what became uCommon C++ 0.4 was originally intended as a refactoring effort for GNU Common C++ to better support IPV6, and became something different as entirely new code was written in 2006. I originally hoped to release GNU uCommon C++ in March of 2007 as a new package under the GNU GPL V3, but the license was unavoidably delayed. GNU uCommon C++ will merge code from and replace GNU Common C++ in future releases. GNU uCommon C++ is a linkable library distributed under the GNU General Public License, Version 3 or later. As of version 2.0, we are now using the GNU Lesser General Public License, Version 3 or later, to remain consistent and compatible with past GNU Common C++ licensing. A new release series of GNU uCommon C++ is 2.1 involved refactoring the abi release from prior 2.0.x releases, offering greater clarity, consistency of use, and some new features that were migrated from Common C++. To better focus on standardizing secure and runtime services, uCommon was somewhat simplified in release 3.4. ccscript is now part of GNU Bayonne, and ccaudio has been separated again. ucommon-6.0.7/gnutls/0000755000175000017500000000000012175176705011531 500000000000000ucommon-6.0.7/gnutls/hmac.cpp0000644000175000017500000000560312163025062013053 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" // for older/broken versions of gnutls_hmac_init headers class multicode { public: int code; inline operator HMAC_ID() {return (HMAC_ID)code;} inline operator MD_ID() {return (MD_ID)code;} }; void HMAC::release(void) { if(context) { gnutls_hmac_deinit((HMAC_CTX)context, buffer); context = NULL; } bufsize = 0; textbuf[0] = 0; hmacid = 0; } int context::map_hmac(const char *type) { if(eq_case(type, "sha") || eq_case(type, "sha1")) return GNUTLS_MAC_SHA1; else if(eq_case(type, "sha256")) return GNUTLS_MAC_SHA256; else if(eq_case(type, "sha224")) return GNUTLS_MAC_SHA224; else if(eq_case(type, "sha384")) return GNUTLS_MAC_SHA384; else if(eq_case(type, "sha512")) return GNUTLS_MAC_SHA512; else if(eq_case(type, "md5")) return GNUTLS_MAC_MD5; else if(eq_case(type, "md2")) return GNUTLS_MAC_MD2; else if(eq_case(type, "rmd160")) return GNUTLS_MAC_RMD160; else return 0; } void HMAC::set(const char *digest, const char *key, size_t len) { secure::init(); release(); if(!len) len = strlen(key); if(!len) return; hmacid = context::map_hmac(digest); multicode id; id.code = hmacid; if(hmacid) gnutls_hmac_init((HMAC_CTX *)&context, id, key, len); } bool HMAC::has(const char *type) { HMAC_ID id = (HMAC_ID)context::map_hmac(type); if(!id || (gnutls_hmac_get_len(id) < 1)) return false; return true; } bool HMAC::put(const void *address, size_t size) { if(!context || hmacid == 0) return false; gnutls_hmac((HMAC_CTX)context, address, size); return true; } const unsigned char *HMAC::get(void) { unsigned count = 0; unsigned size = 0; if(bufsize) return buffer; if(!context || hmacid == 0) return NULL; size = gnutls_hmac_get_len((HMAC_ID)hmacid); release(); bufsize = size; while(count < bufsize) { snprintf(textbuf + (count * 2), 3, "%2.2x", buffer[count]); ++count; } return buffer; } ucommon-6.0.7/gnutls/local.h0000644000175000017500000000367012164016165012711 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include #include #include #include #include #include #ifdef _MSWINDOWS_ #include #endif #define NAMESPACE_LOCAL namespace __secure__ { #define LOCAL_NAMESPACE __secure__ NAMESPACE_LOCAL using namespace UCOMMON_NAMESPACE; class __LOCAL context : public secure { public: ~context(); unsigned int connect; gnutls_credentials_type_t xtype; gnutls_certificate_credentials_t xcred; gnutls_dh_params_t dh; static gnutls_priority_t priority_cache; static gnutls_session_t session(context *ctx); static int map_digest(const char *type); static int map_cipher(const char *type); static int map_hmac(const char *type); }; typedef gnutls_session_t SSL; typedef gnutls_mac_algorithm_t HMAC_ID; typedef gnutls_hmac_hd_t HMAC_CTX; typedef gnutls_digest_algorithm_t MD_ID; typedef gnutls_hash_hd_t MD_CTX; typedef gnutls_cipher_hd_t CIPHER_CTX; typedef gnutls_cipher_algorithm_t CIPHER_ID; typedef gnutls_datum_t CIPHER_KEYDATA; typedef context *SSL_CTX; END_NAMESPACE using namespace UCOMMON_NAMESPACE; using namespace LOCAL_NAMESPACE; ucommon-6.0.7/gnutls/Makefile.am0000644000175000017500000000157112163025062013473 00000000000000# Copyright (C) 2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = -version-info $(LT_VERSION) AM_CXXFLAGS = -I$(top_srcdir)/inc @UCOMMON_FLAGS@ noinst_HEADERS = local.h lib_LTLIBRARIES = libusecure.la libusecure_la_LDFLAGS = ../corelib/libucommon.la @UCOMMON_LIBS@ @SECURE_LIBS@ @UCOMMON_CLINK@ $(RELEASE) libusecure_la_SOURCES = secure.cpp ssl.cpp digest.cpp random.cpp cipher.cpp \ hmac.cpp sstream.cpp ../nossl/common.cpp ucommon-6.0.7/gnutls/sstream.cpp0000644000175000017500000000523712164016165013631 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" #if defined(OLD_STDCPP) || defined(NEW_STDCPP) sstream::sstream(secure::client_t scontext) : tcpstream() { ssl = context::session((context *)scontext); bio = NULL; server = false; } sstream::sstream(const TCPServer *tcp, secure::server_t scontext, size_t size) : tcpstream(tcp, size) { ssl = context::session((context *)scontext); bio = NULL; server = true; if(!is_open() || !ssl) return; gnutls_transport_set_ptr((SSL)ssl, reinterpret_cast( so)); int result = gnutls_handshake((SSL)ssl); if(result >= 0) bio = ssl; } sstream::~sstream() { release(); } void sstream::open(const char *host, const char *service, size_t bufsize) { if(server) return; close(); tcpstream::open(host, service, bufsize); if(!is_open() || !ssl) return; gnutls_transport_set_ptr((SSL)ssl, reinterpret_cast(so)); int result = gnutls_handshake((SSL)ssl); if(result >= 0) bio = ssl; } void sstream::close(void) { if(server) return; if(bio) { gnutls_bye((SSL)ssl, GNUTLS_SHUT_RDWR); bio = NULL; } tcpstream::close(); } void sstream::release(void) { server = false; close(); if(ssl) { gnutls_deinit((SSL)ssl); ssl = NULL; } } ssize_t sstream::_write(const char *address, size_t size) { if(!bio) return tcpstream::_write(address, size); return gnutls_record_send((SSL)ssl, address, size); } ssize_t sstream::_read(char *address, size_t size) { if(!bio) return tcpstream::_read(address, size); return gnutls_record_recv((SSL)ssl, address, size); } bool sstream::_wait(void) { // we have no way to examine the pending queue in gnutls?? if(ssl) return true; return tcpstream::_wait(); } int sstream::sync() { return tcpstream::sync(); } #endif ucommon-6.0.7/gnutls/secure.cpp0000644000175000017500000000667612163025062013444 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" extern "C" { static void secure_shutdown(void) { gnutls_global_deinit(); } } gnutls_priority_t context::priority_cache; bool secure::fips(void) { return false; } bool secure::init(void) { static bool initialized = false; if(!initialized) { Thread::init(); Socket::init(); gnutls_global_init(); gnutls_priority_init (&context::priority_cache, "NORMAL", NULL); atexit(secure_shutdown); initialized = true; } return true; } secure::server_t secure::server(const char *certfile, const char *ca) { context *ctx = new context; if(!ctx) return NULL; ctx->error = secure::OK; ctx->connect = GNUTLS_SERVER; ctx->xtype = GNUTLS_CRD_CERTIFICATE; ctx->xcred = NULL; ctx->dh = NULL; gnutls_certificate_allocate_credentials(&ctx->xcred); gnutls_certificate_set_x509_key_file(ctx->xcred, certfile, certfile, GNUTLS_X509_FMT_PEM); if(!ca) return ctx; if(eq(ca, "*")) ca = oscerts(); gnutls_certificate_set_x509_trust_file (ctx->xcred, ca, GNUTLS_X509_FMT_PEM); return ctx; } secure::client_t secure::client(const char *ca) { context *ctx = new context; if(!ctx) return NULL; ctx->error = secure::OK; ctx->connect = GNUTLS_CLIENT; ctx->xtype = GNUTLS_CRD_CERTIFICATE; ctx->xcred = NULL; ctx->dh = NULL; gnutls_certificate_allocate_credentials(&ctx->xcred); if(!ca) return ctx; if(eq(ca, "*")) ca = oscerts(); gnutls_certificate_set_x509_trust_file (ctx->xcred, ca, GNUTLS_X509_FMT_PEM); return ctx; } context::~context() { if(dh) gnutls_dh_params_deinit(dh); if(!xcred) return; switch(xtype) { case GNUTLS_CRD_ANON: gnutls_anon_free_client_credentials((gnutls_anon_client_credentials_t)xcred); break; case GNUTLS_CRD_CERTIFICATE: gnutls_certificate_free_credentials(xcred); break; default: break; } } secure::~secure() { } gnutls_session_t context::session(context *ctx) { SSL ssl = NULL; if(ctx && ctx->xcred && ctx->err() == secure::OK) { gnutls_init(&ssl, ctx->connect); switch(ctx->connect) { case GNUTLS_CLIENT: gnutls_priority_set_direct(ssl, "PERFORMANCE", NULL); break; case GNUTLS_SERVER: gnutls_priority_set(ssl, context::priority_cache); gnutls_certificate_server_set_request(ssl, GNUTLS_CERT_REQUEST); gnutls_session_enable_compatibility_mode(ssl); default: break; } gnutls_credentials_set(ssl, ctx->xtype, ctx->xcred); } return ssl; } ucommon-6.0.7/gnutls/Makefile.in0000644000175000017500000005546012175171470013522 00000000000000# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = gnutls DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/autoconf/depcomp $(noinst_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ucommon-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libusecure_la_LIBADD = am_libusecure_la_OBJECTS = secure.lo ssl.lo digest.lo random.lo \ cipher.lo hmac.lo sstream.lo common.lo libusecure_la_OBJECTS = $(am_libusecure_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libusecure_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libusecure_la_LDFLAGS) $(LDFLAGS) \ -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libusecure_la_SOURCES) DIST_SOURCES = $(libusecure_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKFLAGS = @CHECKFLAGS@ COMPAT = @COMPAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_GENERIC = @LT_GENERIC@ LT_VERSION = @LT_VERSION@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SECURE = @SECURE@ SECURE_LIBS = @SECURE_LIBS@ SECURE_LOCAL = @SECURE_LOCAL@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UCOMMON_CFGPATH = @UCOMMON_CFGPATH@ UCOMMON_CLINK = @UCOMMON_CLINK@ UCOMMON_FLAGS = @UCOMMON_FLAGS@ UCOMMON_INCLUDES = @UCOMMON_INCLUDES@ UCOMMON_LIBC = @UCOMMON_LIBC@ UCOMMON_LIBS = @UCOMMON_LIBS@ UCOMMON_LINKED = @UCOMMON_LINKED@ UCOMMON_LOCALE = @UCOMMON_LOCALE@ UCOMMON_MODEL = @UCOMMON_MODEL@ UCOMMON_PREFIX = @UCOMMON_PREFIX@ UCOMMON_VARPATH = @UCOMMON_VARPATH@ UCOMMON_VISIBILITY = @UCOMMON_VISIBILITY@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ includes = @includes@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libs = @libs@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = Makefile.in Makefile RELEASE = -version-info $(LT_VERSION) AM_CXXFLAGS = -I$(top_srcdir)/inc @UCOMMON_FLAGS@ noinst_HEADERS = local.h lib_LTLIBRARIES = libusecure.la libusecure_la_LDFLAGS = ../corelib/libucommon.la @UCOMMON_LIBS@ @SECURE_LIBS@ @UCOMMON_CLINK@ $(RELEASE) libusecure_la_SOURCES = secure.cpp ssl.cpp digest.cpp random.cpp cipher.cpp \ hmac.cpp sstream.cpp ../nossl/common.cpp all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu gnutls/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu gnutls/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libusecure.la: $(libusecure_la_OBJECTS) $(libusecure_la_DEPENDENCIES) $(EXTRA_libusecure_la_DEPENDENCIES) $(AM_V_CXXLD)$(libusecure_la_LINK) -rpath $(libdir) $(libusecure_la_OBJECTS) $(libusecure_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cipher.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hmac.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sstream.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< common.lo: ../nossl/common.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT common.lo -MD -MP -MF $(DEPDIR)/common.Tpo -c -o common.lo `test -f '../nossl/common.cpp' || echo '$(srcdir)/'`../nossl/common.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/common.Tpo $(DEPDIR)/common.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='../nossl/common.cpp' object='common.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o common.lo `test -f '../nossl/common.cpp' || echo '$(srcdir)/'`../nossl/common.cpp mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ucommon-6.0.7/gnutls/digest.cpp0000644000175000017500000000702612163025062013423 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" void Digest::release(void) { if(context) { gnutls_hash_deinit((MD_CTX)context, buffer); context = NULL; } bufsize = 0; textbuf[0] = 0; hashid = 0; } int context::map_digest(const char *type) { if(eq_case(type, "sha") || eq_case(type, "sha1")) return GNUTLS_DIG_SHA1; else if(eq_case(type, "sha256")) return GNUTLS_DIG_SHA256; else if(eq_case(type, "sha512")) return GNUTLS_DIG_SHA512; else if(eq_case(type, "md5")) return GNUTLS_DIG_MD5; else if(eq_case(type, "md2")) return GNUTLS_DIG_MD2; else if(eq_case(type, "rmd160")) return GNUTLS_DIG_RMD160; else return 0; } void Digest::set(const char *type) { secure::init(); release(); hashid = context::map_digest(type); if(!hashid || gnutls_hash_get_len((MD_ID)hashid) < 1) { hashid = 0; return; } gnutls_hash_init((MD_CTX *)&context, (MD_ID)hashid); } bool Digest::has(const char *type) { MD_ID id = (MD_ID)context::map_digest(type); if(!id || (gnutls_hash_get_len(id) < 1)) return false; return true; } bool Digest::put(const void *address, size_t size) { if(!context || hashid == 0) return false; gnutls_hash((MD_CTX)context, address, size); return true; } void Digest::reset(void) { unsigned char temp[MAX_DIGEST_HASHSIZE / 8]; if(context) { gnutls_hash_deinit((MD_CTX)context, temp); context = NULL; } if(hashid == 0) return; gnutls_hash_init((MD_CTX *)&context, (MD_ID)hashid); bufsize = 0; } void Digest::recycle(bool bin) { unsigned size = bufsize; if(!context || hashid == 0) return; if(!bufsize) { gnutls_hash_deinit((MD_CTX)context, buffer); context = NULL; gnutls_hash_init((MD_CTX *)&context, (MD_ID)hashid); } else Digest::reset(); size = gnutls_hash_get_len((MD_ID)hashid); if(!size || !context || !hashid) return; if(bin) gnutls_hash((MD_CTX)context, buffer, size); else { unsigned count = 0; while(count < size) { snprintf(textbuf + (count * 2), 3, "%2.2x", buffer[count]); ++count; } gnutls_hash((MD_CTX)context, textbuf, size * 2); } bufsize = 0; } const unsigned char *Digest::get(void) { unsigned count = 0; unsigned size = 0; if(bufsize) return buffer; if(!context || hashid == 0) return NULL; gnutls_hash_deinit((MD_CTX)context, buffer); size = gnutls_hash_get_len((MD_ID)hashid); context = NULL; bufsize = size; while(count < bufsize) { snprintf(textbuf + (count * 2), 3, "%2.2x", buffer[count]); ++count; } return buffer; } ucommon-6.0.7/gnutls/random.cpp0000644000175000017500000000231112163025062013414 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" void Random::seed(void) { secure::init(); } bool Random::seed(const unsigned char *buf, size_t size) { secure::init(); return true; } size_t Random::key(unsigned char *buf, size_t size) { gnutls_rnd(GNUTLS_RND_KEY, buf, size); return 0; } size_t Random::fill(unsigned char *buf, size_t size) { gnutls_rnd(GNUTLS_RND_RANDOM, buf, size); return 0; } bool Random::status(void) { return true; } ucommon-6.0.7/gnutls/cipher.cpp0000644000175000017500000002176312163025062013422 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" static const unsigned char *_salt = NULL; static unsigned _rounds = 1; int context::map_cipher(const char *cipher) { char algoname[64]; enum { NONE, CBC, ECB, CFB, OFB } modeid; String::set(algoname, sizeof(algoname), cipher); char *fpart = strchr(algoname, '-'); char *lpart = strrchr(algoname, '-'); modeid = NONE; if(lpart) { if(fpart != lpart) *(fpart++) = 0; else ++fpart; *(lpart++) = 0; if(eq_case(lpart, "cbc")) modeid = CBC; else if(eq_case(lpart, "ecb")) modeid = ECB; else if(eq_case(lpart, "cfb") || eq_case(lpart, "pgp")) modeid = CFB; else if(eq_case(lpart, "ofb")) modeid = OFB; else modeid = NONE; } else if(eq_case(cipher, "aes128") || eq_case(cipher, "aes")) return GNUTLS_CIPHER_AES_128_CBC; else if(eq_case(cipher, "aes256")) return GNUTLS_CIPHER_AES_256_CBC; else if(eq_case(cipher, "aes192")) return GNUTLS_CIPHER_AES_192_CBC; else if(eq_case(cipher, "arcfour") || eq_case(cipher, "arc4")) return GNUTLS_CIPHER_ARCFOUR_128; else if(eq_case(cipher, "des")) return GNUTLS_CIPHER_DES_CBC; else if(eq_case(cipher, "3des")) return GNUTLS_CIPHER_3DES_CBC; else if(eq_case(cipher, "rc2")) return GNUTLS_CIPHER_RC2_40_CBC; else if(eq_case(cipher, "idea")) return GNUTLS_CIPHER_IDEA_PGP_CFB; else if(eq_case(cipher, "twofish") || eq_case(cipher, "2fish")) return GNUTLS_CIPHER_TWOFISH_PGP_CFB; else if(eq_case(cipher, "blowfish")) return GNUTLS_CIPHER_BLOWFISH_PGP_CFB; else if(eq_case(algoname, "cast") || eq_case(algoname, "cast5")) return GNUTLS_CIPHER_CAST5_PGP_CFB; switch(modeid) { case CFB: if(eq_case(algoname, "aes")) { if(atoi(fpart) == 128) return GNUTLS_CIPHER_AES128_PGP_CFB; if(atoi(fpart) == 192) return GNUTLS_CIPHER_AES192_PGP_CFB; if(atoi(fpart) == 256) return GNUTLS_CIPHER_AES256_PGP_CFB; return 0; } if(eq_case(algoname, "idea")) return GNUTLS_CIPHER_IDEA_PGP_CFB; if(eq_case(algoname, "3des")) return GNUTLS_CIPHER_3DES_PGP_CFB; if(eq_case(algoname, "cast") || eq_case(algoname, "cast5")) return GNUTLS_CIPHER_CAST5_PGP_CFB; if(eq_case(algoname, "twofish") || eq_case(algoname, "2fish")) return GNUTLS_CIPHER_TWOFISH_PGP_CFB; if(eq_case(algoname, "blowfish")) return GNUTLS_CIPHER_BLOWFISH_PGP_CFB; if(eq_case(algoname, "sk")) return GNUTLS_CIPHER_SAFER_SK128_PGP_CFB; return 0; case CBC: if(eq_case(algoname, "aes")) { if(atoi(fpart) == 128) return GNUTLS_CIPHER_AES_128_CBC; if(atoi(fpart) == 192) return GNUTLS_CIPHER_AES_192_CBC; if(atoi(fpart) == 256) return GNUTLS_CIPHER_AES_256_CBC; return 0; } if(eq_case(algoname, "camellia")) { if(atoi(fpart) == 128) return GNUTLS_CIPHER_CAMELLIA_128_CBC; if(atoi(fpart) == 256) return GNUTLS_CIPHER_CAMELLIA_256_CBC; return 0; } if(eq_case(algoname, "3des")) return GNUTLS_CIPHER_3DES_CBC; if(eq_case(algoname, "des")) return GNUTLS_CIPHER_DES_CBC; if(eq_case(algoname, "rc2")) return GNUTLS_CIPHER_RC2_40_CBC; return 0; default: if(eq_case(algoname, "arc4") || eq_case(algoname, "arcfour")) { if(atoi(fpart) == 40) return GNUTLS_CIPHER_ARCFOUR_40; if(atoi(fpart) == 128) return GNUTLS_CIPHER_ARCFOUR_128; } return 0; } } void Cipher::Key::assign(const char *text, size_t size, const unsigned char *salt, unsigned count) { if(!hashid || !algoid) { keysize = 0; return; } size_t kpos = 0, ivpos = 0; size_t mdlen = gnutls_hash_get_len((MD_ID)hashid); size_t tlen = strlen(text); if(!hashid || !mdlen) { clear(); return; } char previous[MAX_DIGEST_HASHSIZE / 8]; unsigned char temp[MAX_DIGEST_HASHSIZE / 8]; MD_CTX mdc; unsigned prior = 0; unsigned loop; if(!salt) salt = _salt; if(!count) count = _rounds; do { gnutls_hash_init(&mdc, (MD_ID)hashid); if(prior++) gnutls_hash(mdc, previous, mdlen); gnutls_hash(mdc, text, tlen); if(salt) gnutls_hash(mdc, salt, 8); gnutls_hash_deinit(mdc, previous); for(loop = 1; loop < count; ++loop) { memcpy(temp, previous, mdlen); gnutls_hash_fast((MD_ID)hashid, temp, mdlen, previous); } size_t pos = 0; while(kpos < keysize && pos < mdlen) keybuf[kpos++] = previous[pos++]; while(ivpos < blksize && pos < mdlen) ivbuf[ivpos++] = previous[pos++]; } while(kpos < keysize || ivpos < blksize); } void Cipher::Key::assign(const char *text, size_t size) { assign(text, size, _salt, _rounds); } void Cipher::Key::options(const unsigned char *salt, unsigned rounds) { _salt = salt; _rounds = rounds; } void Cipher::Key::set(const char *cipher, const char *digest) { set(cipher); hashid = context::map_digest(digest); } void Cipher::Key::set(const char *cipher) { clear(); algoid = context::map_cipher(cipher); if(algoid) { blksize = gnutls_cipher_get_block_size((CIPHER_ID)algoid); keysize = gnutls_cipher_get_key_size((CIPHER_ID)algoid); } } void Cipher::push(unsigned char *address, size_t size) { } void Cipher::release(void) { keys.clear(); if(context) { gnutls_cipher_deinit((CIPHER_CTX)context); context = NULL; } } bool Cipher::has(const char *cipher) { return context::map_cipher(cipher) != 0; } void Cipher::set(const key_t key, mode_t mode, unsigned char *address, size_t size) { release(); bufsize = size; bufmode = mode; bufaddr = address; memcpy(&keys, key, sizeof(keys)); if(!keys.keysize) return; gnutls_datum_t keyinfo, ivinfo; keyinfo.data = keys.keybuf; keyinfo.size = keys.keysize; ivinfo.data = keys.ivbuf; ivinfo.size = keys.blksize; gnutls_cipher_init((CIPHER_CTX *)&context, (CIPHER_ID)keys.algoid, &keyinfo, &ivinfo); } size_t Cipher::put(const unsigned char *data, size_t size) { if(size % keys.iosize() || !bufaddr) return 0; size_t count = 0; while(bufsize && size + bufpos > bufsize) { size_t diff = bufsize - bufpos; count += put(data, diff); data += diff; size -= diff; } switch(bufmode) { case Cipher::ENCRYPT: gnutls_cipher_encrypt2((CIPHER_CTX)context, (void *)data, size, bufaddr + bufpos, size); break; case Cipher::DECRYPT: gnutls_cipher_decrypt2((CIPHER_CTX)context, data, size, bufaddr + bufpos, size); } count += size; if(!count) { release(); return 0; } bufpos += size; if(bufsize && bufpos >= bufsize) { push(bufaddr, bufsize); bufpos = 0; } return count; } size_t Cipher::pad(const unsigned char *data, size_t size) { size_t padsz = 0; unsigned char padbuf[64]; const unsigned char *ep; if(!bufaddr) return 0; switch(bufmode) { case DECRYPT: if(size % keys.iosize()) return 0; put(data, size); ep = data + size - 1; bufpos -= *ep; size -= *ep; break; case ENCRYPT: padsz = size % keys.iosize(); put(data, size - padsz); if(padsz) { memcpy(padbuf, data + size - padsz, padsz); memset(padbuf + padsz, keys.iosize() - padsz, keys.iosize() - padsz); size = (size - padsz) + keys.iosize(); } else { size += keys.iosize(); memset(padbuf, keys.iosize(), keys.iosize()); } put((const unsigned char *)padbuf, keys.iosize()); zerofill(padbuf, sizeof(padbuf)); } flush(); return size; } ucommon-6.0.7/gnutls/ssl.cpp0000644000175000017500000000544112164016165012751 00000000000000// Copyright (C) 2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include "local.h" SSLBuffer::SSLBuffer(const TCPServer *tcp, secure::server_t scontext, size_t size) : TCPBuffer(tcp, size) { ssl = context::session((context *)scontext); bio = NULL; server = true; if(!is_open() || !ssl) return; gnutls_transport_set_ptr((SSL)ssl, reinterpret_cast( so)); int result = gnutls_handshake((SSL)ssl); if(result >= 0) bio = ssl; } SSLBuffer::SSLBuffer(secure::client_t scontext) : TCPBuffer() { ssl = context::session((context *)scontext); bio = NULL; server = false; } SSLBuffer::~SSLBuffer() { release(); } bool SSLBuffer::_pending(void) { return TCPBuffer::_pending(); } void SSLBuffer::open(const char *host, const char *service, size_t size) { if(server) { ioerr = EBADF; return; } close(); TCPBuffer::open(host, service, size); if(!is_open() || !ssl) return; gnutls_transport_set_ptr((SSL)ssl, reinterpret_cast(so)); int result = gnutls_handshake((SSL)ssl); if(result >= 0) bio = ssl; } void SSLBuffer::close(void) { if(server) { ioerr = EBADF; return; } if(bio) gnutls_bye((SSL)ssl, GNUTLS_SHUT_RDWR); bio = NULL; TCPBuffer::close(); } void SSLBuffer::release(void) { server = false; close(); if(ssl) { gnutls_deinit((SSL)ssl); ssl = NULL; } } bool SSLBuffer::_flush(void) { return TCPBuffer::_flush(); } size_t SSLBuffer::_push(const char *address, size_t size) { if(!bio) return TCPBuffer::_push(address, size); int result = gnutls_record_send((SSL)ssl, address, size); if(result < 0) { result = 0; ioerr = EIO; } return (size_t)result; } size_t SSLBuffer::_pull(char *address, size_t size) { if(!bio) return TCPBuffer::_pull(address, size); int result = gnutls_record_recv((SSL)ssl, address, size); if(result < 0) { result = 0; ioerr = EIO; } return (size_t)result; } ucommon-6.0.7/Makefile.in0000644000175000017500000010363712175171470012206 00000000000000# Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2006-2010 David Sugar, Tycho Softworks. # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/ucommon-config.h.in $(srcdir)/directive.in \ $(srcdir)/commoncpp.pc.in $(srcdir)/ucommon.pc.in \ $(srcdir)/ucommon.spec.in $(srcdir)/ucommon-config.in \ $(srcdir)/commoncpp-config.in COPYING COPYING.LESSER TODO \ autoconf/compile autoconf/config.guess autoconf/config.sub \ autoconf/install-sh autoconf/missing autoconf/ltmain.sh \ $(top_srcdir)/autoconf/compile \ $(top_srcdir)/autoconf/config.guess \ $(top_srcdir)/autoconf/config.sub \ $(top_srcdir)/autoconf/install-sh \ $(top_srcdir)/autoconf/ltmain.sh \ $(top_srcdir)/autoconf/missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = ucommon-config.h CONFIG_CLEAN_FILES = directive commoncpp.pc ucommon.pc ucommon.spec \ ucommon-config commoncpp-config CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(scriptdir)" "$(DESTDIR)$(man1dir)" \ "$(DESTDIR)$(pkgconfigdir)" SCRIPTS = $(script_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac man1dir = $(mandir)/man1 NROFF = nroff MANS = $(man_MANS) DATA = $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)ucommon-config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz $(distdir).shar.gz $(distdir).zip GZIP_ENV = --best DIST_TARGETS = dist-shar dist-gzip dist-zip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKFLAGS = @CHECKFLAGS@ COMPAT = @COMPAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_GENERIC = @LT_GENERIC@ LT_VERSION = @LT_VERSION@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SECURE = @SECURE@ SECURE_LIBS = @SECURE_LIBS@ SECURE_LOCAL = @SECURE_LOCAL@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UCOMMON_CFGPATH = @UCOMMON_CFGPATH@ UCOMMON_CLINK = @UCOMMON_CLINK@ UCOMMON_FLAGS = @UCOMMON_FLAGS@ UCOMMON_INCLUDES = @UCOMMON_INCLUDES@ UCOMMON_LIBC = @UCOMMON_LIBC@ UCOMMON_LIBS = @UCOMMON_LIBS@ UCOMMON_LINKED = @UCOMMON_LINKED@ UCOMMON_LOCALE = @UCOMMON_LOCALE@ UCOMMON_MODEL = @UCOMMON_MODEL@ UCOMMON_PREFIX = @UCOMMON_PREFIX@ UCOMMON_VARPATH = @UCOMMON_VARPATH@ UCOMMON_VISIBILITY = @UCOMMON_VISIBILITY@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ includes = @includes@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libs = @libs@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = no-dependencies dist-zip EXTRA_DIST = autogen.sh README* *.pc.in *.spec.in *.spec *-config.in \ *-config.1 Doxyfile cmodel.sh BUILDS SUPPORT COPYING* COPYRIGHT \ CMakeLists.txt ucommon-config.cmake ucommon.pc.cmake \ commoncpp-config.cmake commoncpp.pc.cmake ucommon.spec.cmake \ ucommon-config.h.cmake doxy.config.cmake directive.in DIST_SUBDIRS = corelib commoncpp openssl gnutls nossl utils inc test SUBDIRS = corelib @SECURE@ @COMPAT@ utils inc test pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = ucommon.pc commoncpp.pc scriptdir = $(bindir) script_SCRIPTS = ucommon-config commoncpp-config man_MANS = ucommon-config.1 commoncpp-config.1 all: ucommon-config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): ucommon-config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/ucommon-config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status ucommon-config.h $(srcdir)/ucommon-config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f ucommon-config.h stamp-h1 directive: $(top_builddir)/config.status $(srcdir)/directive.in cd $(top_builddir) && $(SHELL) ./config.status $@ commoncpp.pc: $(top_builddir)/config.status $(srcdir)/commoncpp.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ ucommon.pc: $(top_builddir)/config.status $(srcdir)/ucommon.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ ucommon.spec: $(top_builddir)/config.status $(srcdir)/ucommon.spec.in cd $(top_builddir) && $(SHELL) ./config.status $@ ucommon-config: $(top_builddir)/config.status $(srcdir)/ucommon-config.in cd $(top_builddir) && $(SHELL) ./config.status $@ commoncpp-config: $(top_builddir)/config.status $(srcdir)/commoncpp-config.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-scriptSCRIPTS: $(script_SCRIPTS) @$(NORMAL_INSTALL) @list='$(script_SCRIPTS)'; test -n "$(scriptdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(scriptdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(scriptdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n' \ -e 'h;s|.*|.|' \ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) { files[d] = files[d] " " $$1; \ if (++n[d] == $(am__install_max)) { \ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ else { print "f", d "/" $$4, $$1 } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(scriptdir)$$dir'"; \ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(scriptdir)$$dir" || exit $$?; \ } \ ; done uninstall-scriptSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(script_SCRIPTS)'; test -n "$(scriptdir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ dir='$(DESTDIR)$(scriptdir)'; $(am__uninstall_files_from_dir) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-man1: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(SCRIPTS) $(MANS) $(DATA) ucommon-config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(scriptdir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man install-pkgconfigDATA \ install-scriptSCRIPTS install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man1 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-man uninstall-pkgconfigDATA \ uninstall-scriptSCRIPTS uninstall-man: uninstall-man1 .MAKE: $(am__recursive_targets) all install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool clean-local cscope cscopelist-am ctags ctags-am \ dist dist-all dist-bzip2 dist-gzip dist-hook dist-lzip \ dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \ distclean-generic distclean-hdr distclean-libtool \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man1 \ install-pdf install-pdf-am install-pkgconfigDATA install-ps \ install-ps-am install-scriptSCRIPTS install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-man uninstall-man1 \ uninstall-pkgconfigDATA uninstall-scriptSCRIPTS .phony: doxy doxy: -rm -rf doc $(DOXYGEN) Doxyfile clean-local: -rm -rf doc dist-hook: cleandist cleandist: @rm -f ${PACKAGE}-[0-9]*.tar.gz @rm -f ${PACKAGE}-[0-9]*.tar.bz2 @rm -f ${PACKAGE}-[0-9]*.shar.gz @rm -f ${PACKAGE}-[0-9]*.zip @rm -f *${PACKAGE}*.rpm @rm -f *${PACKAGE}*.deb @rm -f ${PACKAGE}_*.gz @rm -f ${PACKAGE}_*.dsc @rm -f *.changes # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ucommon-6.0.7/corelib/0000755000175000017500000000000012175176705011634 500000000000000ucommon-6.0.7/corelib/numbers.cpp0000644000175000017500000000636712163025062013731 00000000000000// Copyright (C) 1999-2005 Open Source Telecom Corporation. // Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif using namespace UCOMMON_NAMESPACE; Number::Number(char *buf, unsigned width) { if(width > 10) width = 10; if(width < 1) width = 1; size = width; buffer = buf; } long Number::get(void) const { int count = size; bool sign = false; long ret = 0; char *bp = buffer; if(*bp == '-') { --count; ++bp; sign = true; } else if(*bp == '+') { --count; ++bp; } while(count && *bp >='0' && *bp <='9') { ret = ret * 10l + (*bp - '0'); --count; ++bp; } if(sign) ret = -ret; return ret; } void Number::set(long value) { int count = size; char *bp = buffer; long max = 1; int exp; bool z = false; if(value < 0) { value = -value; --count; *(bp++) = '-'; } exp = count; while(--exp) max *= 10; while(max) { if(value >= max || z) { --count; *(bp++) = '0' + ((char)(value / max)); } if(value >= max) { z = true; value -= (value / max) * max; } max /= 10; } while(count-- && *bp >= '0' && *bp <='9') *(bp++) = ' '; } long Number::operator=(long value) { set(value); return value; } long Number::operator=(const Number& num) { set(num.get()); return get(); } long Number::operator+=(long value) { long value1 = get() + value; set(value1); return value1; } long Number::operator-=(long value) { long value1 = get() - value; set(value1); return value1; } long Number::operator--() { long val = get(); set(--val); return val; } long Number::operator++() { long val = get(); set(++val); return val; } ZNumber::ZNumber(char *buf, unsigned chars) : Number(buf, chars) {} void ZNumber::set(long value) { int count = size; char *bp = buffer; long max = 1; int exp; if(value < 0) { value = -value; --count; *(bp++) = '-'; } exp = count; while(--exp) max *= 10; while(max) { --count; *(bp++) = '0' + (char)(value / max); value -= (value / max) * max; max /= 10; } } long ZNumber::operator=(long value) { set(value); return value; } ucommon-6.0.7/corelib/persist.cpp0000644000175000017500000001675612163025062013752 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #if defined(OLD_STDCPP) || defined(NEW_STDCPP) #if !defined(_MSC_VER) || _MSC_VER >= 1400 #include #include #include using namespace UCOMMON_NAMESPACE; using namespace std; const uint32_t NullObject = 0xffffffff; PersistException::PersistException(const std::string& reason) : _what(reason) { } const std::string& PersistException::getString() const { return _what; } PersistException::~PersistException() throw() { } const char* PersistObject::getPersistenceID() const { return "PersistObject"; } PersistObject::PersistObject() { // Do nothing } PersistObject::~PersistObject() { // Do nothing } bool PersistObject::write(PersistEngine& archive) const { // Do nothing return true; // Successfully } bool PersistObject::read(PersistEngine& archive) { // Do nothing return true; // Successfully } static TypeManager::StringFunctionMap* theInstantiationFunctions = 0; static int refCount = 0; TypeManager::StringFunctionMap& _internal_GetMap() { return *theInstantiationFunctions; } void TypeManager::add(const char* name, NewPersistObjectFunction construction) { if (refCount++ == 0) { theInstantiationFunctions = new StringFunctionMap; } assert(_internal_GetMap().find(std::string(name)) == _internal_GetMap().end()); _internal_GetMap()[std::string(name)] = construction; } void TypeManager::remove(const char* name) { assert(_internal_GetMap().find(std::string(name)) != _internal_GetMap().end()); _internal_GetMap().erase(_internal_GetMap().find(std::string(name))); if (--refCount == 0) { delete theInstantiationFunctions; theInstantiationFunctions = 0; } } PersistObject* TypeManager::createInstanceOf(const char* name) { assert(refCount); assert(_internal_GetMap().find(std::string(name)) != _internal_GetMap().end()); return (_internal_GetMap()[std::string(name)])(); } TypeManager::registration::registration(const char *name, NewPersistObjectFunction func) : myName(name) { TypeManager::add(name, func); } TypeManager::registration::~registration() { TypeManager::remove(myName.c_str()); } PersistEngine::PersistEngine(std::iostream& stream, EngineMode mode) throw(PersistException) : myUnderlyingStream(stream), myOperationalMode(mode) { } PersistEngine::~PersistEngine() { if (myUnderlyingStream.good()) myUnderlyingStream.sync(); } void PersistEngine::writeBinary(const uint8_t* data, const uint32_t size) throw(PersistException) { if(myOperationalMode != modeWrite) throw("Cannot write to an input Engine"); myUnderlyingStream.write((const char *)data,size); } void PersistEngine::readBinary(uint8_t* data, uint32_t size) throw(PersistException) { if(myOperationalMode != modeRead) throw("Cannot read from an output Engine"); myUnderlyingStream.read((char *)data,size); } void PersistEngine::write(const PersistObject *object) throw(PersistException) { // Pre-step, if object is NULL, then don't serialize it - serialize a // marker to say that it is null. // as ID's are uint32's, NullObject will do nicely for the task if (object == NULL) { uint32_t id = NullObject; write(id); return; } // First off - has this Object been serialized already? ArchiveMap::const_iterator itor = myArchiveMap.find(object); if (itor == myArchiveMap.end()) { // Unfortunately we need to serialize it - here we go .... uint32_t id = (uint32_t)myArchiveMap.size(); myArchiveMap[object] = id; // bumps id automatically for next one write(id); ClassMap::const_iterator classItor = myClassMap.find(object->getPersistenceID()); if (classItor == myClassMap.end()) { uint32_t classId = (uint32_t)myClassMap.size(); myClassMap[object->getPersistenceID()] = classId; write(classId); write(static_cast(object->getPersistenceID())); } else { write(classItor->second); } std::string majik; majik = "OBST"; write(majik); object->write(*this); majik = "OBEN"; write(majik); } else { // This object has been serialized, so just pop its ID out write(itor->second); } } void PersistEngine::read(PersistObject &object) throw(PersistException) { uint32_t id = 0; read(id); if (id == NullObject) throw("Object Id should not be NULL when un-persisting to a reference"); // Do we already have this object in memory? if (id < myArchiveVector.size()) { object = *(myArchiveVector[id]); return; } // Okay - read the identifier for the class in... // we won't need it later since this object is already allocated readClass(); // Okay then - we can read data straight into this object readObject(&object); } void PersistEngine::read(PersistObject *&object) throw(PersistException) { uint32_t id = 0; read(id); // Is the ID a NULL object? if (id == NullObject) { object = NULL; return; } // Do we already have this object in memory? if (id < myArchiveVector.size()) { object = myArchiveVector[id]; return; } // Okay - read the identifier for the class in... std::string className = readClass(); // is the pointer already initialized? if so then no need to reallocate if (object != NULL) { readObject(object); return; } // Create the object (of the relevant type) object = TypeManager::createInstanceOf(className.c_str()); if (object) { // Okay then - we can make this object readObject(object); } else throw(PersistException(std::string("Unable to instantiate object of class ")+className)); } void PersistEngine::readObject(PersistObject* object) throw(PersistException) { // Okay then - we can make this object myArchiveVector.push_back(object); std::string majik; read(majik); if(majik != std::string("OBST")) throw( PersistException("Missing Start-of-Object marker")); object->read(*this); read(majik); if(majik != std::string("OBEN")) throw( PersistException("Missing End-of-Object marker")); } const std::string PersistEngine::readClass() throw(PersistException) { // Okay - read the identifier for the class in... uint32_t classId = 0; read(classId); std::string className; if (classId < myClassVector.size()) { className = myClassVector[classId]; } else { // Okay the class wasn't known yet - save its name read(className); myClassVector.push_back(className); } return className; } void PersistEngine::write(const std::string& str) throw(PersistException) { uint32_t len = (uint32_t)str.length(); write(len); writeBinary((uint8_t*)str.c_str(),len); } void PersistEngine::read(std::string& str) throw(PersistException) { uint32_t len = 0; read(len); uint8_t *buffer = new uint8_t[len+1]; readBinary(buffer,len); buffer[len] = 0; str = (char*)buffer; delete[] buffer; } #endif #endif ucommon-6.0.7/corelib/vector.cpp0000644000175000017500000002653312163025062013555 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include #include #include #include #include #include #include #include using namespace UCOMMON_NAMESPACE; const vectorsize_t Vector::npos = (vectorsize_t)(-1); Vector::array::array(vectorsize_t size) { assert(size > 0); max = size; len = 0; list[0] = 0; } void Vector::array::dealloc(void) { purge(); CountedObject::dealloc(); } void Vector::array::purge(void) { vectorsize_t pos = 0; while(list[pos]) list[pos++]->release(); len = 0; list[0] = 0; } void Vector::array::dec(vectorsize_t offset) { if(!len) return; if(offset >= len) { purge(); return; } while(offset--) { list[--len]->release(); list[len] = 0; } } void Vector::array::inc(vectorsize_t offset) { if(!offset) ++offset; if(offset >= len) { purge(); return; } if(!len) return; for(vectorsize_t pos = 0; pos < offset; ++pos) list[pos]->release(); memmove(list, &list[offset], (len - offset) * sizeof(void *)); len -= offset; list[len] = 0; } void Vector::array::set(ObjectProtocol **items) { assert(items != NULL); purge(); add(items); } void Vector::array::add(ObjectProtocol **items) { assert(items != NULL); vectorsize_t size = Vector::size((void **)(items)); if(!size) return; if(len + size > max) size = max - len; if(size < 1) return; for(vectorsize_t pos = 0; pos < size; ++pos) { list[len++] = items[pos]; items[pos]->retain(); } list[len] = 0; } void Vector::array::add(ObjectProtocol *obj) { assert(obj); if(len == max) return; obj->retain(); list[len++] = obj; list[len] = 0; } vectorsize_t Vector::size(void) const { if(!data) return 0; return data->max; } vectorsize_t Vector::len(void) const { if(!data) return 0; return data->len; } Vector::Vector() { data = NULL; } Vector::Vector(ObjectProtocol **items, vectorsize_t limit) { assert(items); if(!limit) limit = size((void **)items); data = create(limit); data->retain(); data->set(items); } Vector::Vector(vectorsize_t size) { assert(size > 0); data = create(size); data->retain(); } Vector::~Vector() { release(); } ObjectProtocol **Vector::list(void) const { if(!data) return NULL; return data->list; } ObjectProtocol *Vector::invalid(void) const { return NULL; } ObjectProtocol *Vector::get(int offset) const { if(!data || !data->len) return invalid(); if(offset >= (int)(data->len)) return invalid(); if(((vectorsize_t)(-offset)) >= data->len) return invalid(); if(offset >= 0) return data->list[offset]; return data->list[data->len + offset]; } vectorsize_t Vector::get(void **target, vectorsize_t limit) const { assert(target != NULL && limit > 0); vectorsize_t pos; if(!data) { target[0] = 0; return 0; } for(pos = 0; pos < data->len && pos < limit - 1; ++pos) target[pos] = data->list[pos]; target[pos] = 0; return pos; } Vector::array *Vector::create(vectorsize_t size) const { assert(size > 0); return new((size_t)size) array(size); } void Vector::release(void) { if(data) data->release(); data = NULL; } ObjectProtocol *Vector::begin(void) const { if(!data) return NULL; return data->list[0]; } ObjectProtocol *Vector::end(void) const { if(!data || !data->len) return NULL; return data->list[data->len - 1]; } vectorsize_t Vector::find(ObjectProtocol *obj, vectorsize_t pos) const { assert(obj != NULL); if(!data) return npos; while(pos < data->len) { if(data->list[pos] == obj) return pos; ++pos; } return npos; } void Vector::split(vectorsize_t pos) { if(!data || pos >= data->len) return; while(data->len > pos) { --data->len; data->list[data->len]->release(); } data->list[data->len] = NULL; } void Vector::rsplit(vectorsize_t pos) { vectorsize_t head = 0; if(!data || pos >= data->len || !pos) return; while(head < pos) data->list[head++]->release(); head = 0; while(data->list[pos]) data->list[head++] = data->list[pos++]; data->len = head; data->list[head] = NULL; } void Vector::set(ObjectProtocol **list) { assert(list); if(!data && list) { data = create(size((void **)list)); data->retain(); } if(data && list) data->set(list); } void Vector::set(vectorsize_t pos, ObjectProtocol *obj) { assert(obj != NULL); if(!data || pos > data->len) return; if(pos == data->len && data->len < data->max) { data->list[data->len++] = obj; data->list[data->len] = NULL; obj->retain(); return; } data->list[pos]->release(); data->list[pos] = obj; obj->retain(); } void Vector::add(ObjectProtocol **list) { assert(list); if(data && list) data->add(list); } void Vector::add(ObjectProtocol *obj) { assert(obj); if(data && obj) data->add(obj); } void Vector::clear(void) { if(data) data->purge(); } bool Vector::resize(vectorsize_t size) { if(!size) { release(); data = NULL; return true; } if(data->is_copied() || data->max < size) { data->release(); data = create(size); data->retain(); } return true; } void Vector::cow(vectorsize_t size) { if(data) { size += data->len; } if(!size) return; if(!data || !data->max || data->is_copied() || size > data->max) { array *a = create(size); a->len = data->len; memcpy(a->list, data->list, data->len * sizeof(ObjectProtocol *)); a->list[a->len] = 0; a->retain(); data->release(); data = a; } } void Vector::operator^=(Vector &v) { release(); set(v.list()); } Vector &Vector::operator^(Vector &v) { vectorsize_t vs = v.len(); if(!vs) return *this; if(data && data->len + vs > data->max) cow(); add(v.list()); return *this; } void Vector::operator++() { if(!data) return; data->inc(1); } void Vector::operator--() { if(!data) return; data->dec(1); } void Vector::operator+=(vectorsize_t inc) { if(!data) return; data->inc(inc); } void Vector::operator-=(vectorsize_t dec) { if(!data) return; data->inc(dec); } MemVector::MemVector(void *mem, vectorsize_t size) { assert(mem != NULL); assert(size > 0); data = new((caddr_t)mem) array(size); } MemVector::~MemVector() { data = NULL; } void MemVector::release(void) { data = NULL; } bool MemVector::resize(vectorsize_t size) { return false; } void MemVector::cow(vectorsize_t adj) { } ArrayReuse::ArrayReuse(size_t size, unsigned c, void *memory) : ReusableAllocator() { assert(c > 0 && size > 0 && memory != NULL); objsize = size; count = 0; limit = c; used = 0; mem = (caddr_t)memory; } ArrayReuse::ArrayReuse(size_t size, unsigned c) : ReusableAllocator() { assert(c > 0 && size > 0); objsize = size; count = 0; limit = c; used = 0; mem = (caddr_t)malloc(size * c); crit(mem != NULL, "vector reuse alloc failed"); } ArrayReuse::~ArrayReuse() { if(mem) { free(mem); mem = NULL; } } bool ArrayReuse::avail(void) { bool rtn = false; lock(); if(count < limit) rtn = true; unlock(); return rtn; } ReusableObject *ArrayReuse::get(timeout_t timeout) { bool rtn = true; struct timespec ts; ReusableObject *obj = NULL; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(!freelist && used >= limit && rtn) { ++waiting; if(timeout == Timer::inf) wait(); else if(timeout) rtn = wait(&ts); else rtn = false; --waiting; } if(!rtn) { unlock(); return NULL; } if(freelist) { obj = freelist; freelist = next(obj); } else if(used < limit) { obj = (ReusableObject *)&mem[used * objsize]; ++used; } if(obj) ++count; unlock(); return obj; } ReusableObject *ArrayReuse::get(void) { return get(Timer::inf); } ReusableObject *ArrayReuse::request(void) { ReusableObject *obj = NULL; lock(); if(freelist) { obj = freelist; freelist = next(obj); } else if(used < limit) { obj = (ReusableObject *)(mem + (used * objsize)); ++used; } if(obj) ++count; unlock(); return obj; } vectorsize_t Vector::size(void **list) { assert(list != NULL); vectorsize_t pos = 0; while(list[pos]) ++pos; return pos; } PagerReuse::PagerReuse(mempager *p, size_t objsize, unsigned c) : MemoryRedirect(p), ReusableAllocator() { assert(objsize > 0 && c > 0); limit = c; count = 0; osize = objsize; } PagerReuse::~PagerReuse() { } bool PagerReuse::avail(void) { bool rtn = false; if(!limit) return true; lock(); if(count < limit) rtn = true; unlock(); return rtn; } ReusableObject *PagerReuse::request(void) { ReusableObject *obj = NULL; lock(); if(!limit || count < limit) { if(freelist) { ++count; obj = freelist; freelist = next(obj); } else { ++count; unlock(); return (ReusableObject *)_alloc(osize); } } unlock(); return obj; } ReusableObject *PagerReuse::get(void) { return get(Timer::inf); } ReusableObject *PagerReuse::get(timeout_t timeout) { bool rtn = true; struct timespec ts; ReusableObject *obj; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(rtn && limit && count >= limit) { ++waiting; if(timeout == Timer::inf) wait(); else if(timeout) rtn = wait(&ts); else rtn = false; --waiting; } if(!rtn) { unlock(); return NULL; } if(freelist) { obj = freelist; freelist = next(obj); } else { ++count; unlock(); return (ReusableObject *)_alloc(osize); } if(obj) ++count; unlock(); return obj; } ucommon-6.0.7/corelib/containers.cpp0000644000175000017500000003233612163025062014416 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include #include #include #include #include #include #include #include using namespace UCOMMON_NAMESPACE; LinkedAllocator::LinkedAllocator() : Conditional() { freelist = NULL; } LinkedObject *LinkedAllocator::get(void) { LinkedObject *node; lock(); node = freelist; if(node) freelist = freelist->getNext(); unlock(); return node; } LinkedObject *LinkedAllocator::get(timeout_t timeout) { struct timespec ts; bool rtn = true; LinkedObject *node = NULL; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(!freelist && rtn) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(rtn && freelist) { node = freelist; if(node) freelist = freelist->getNext(); } unlock(); return node; } void LinkedAllocator::release(LinkedObject *node) { lock(); node->enlist(&freelist); signal(); unlock(); } LinkedAllocator::operator bool() { bool rtn = false; lock(); if(freelist) rtn = true; unlock(); return rtn; } bool LinkedAllocator::operator!() { bool rtn = false; lock(); if(!freelist) rtn = true; unlock(); return rtn; } Buffer::Buffer(size_t osize, size_t c) : Conditional() { assert(osize > 0 && c > 0); bufsize = osize * c; objsize = osize; objcount = 0; limit = c; if(osize) { buf = (char *)malloc(bufsize); crit(buf != NULL, "buffer alloc failed"); } else buf = NULL; head = tail = buf; } Buffer::~Buffer() { if(buf) free(buf); buf = NULL; } unsigned Buffer::count(void) { unsigned bcount = 0; lock(); if(tail > head) bcount = (unsigned)((size_t)(tail - head) / objsize); else if(head > tail) bcount = (unsigned)((((buf + bufsize) - head) + (tail - buf)) / objsize); unlock(); return bcount; } unsigned Buffer::size(void) { return bufsize / objsize; } void *Buffer::get(void) { caddr_t dbuf; lock(); while(!objcount) wait(); dbuf = head; unlock(); return dbuf; } void *Buffer::invalid(void) const { return NULL; } void *Buffer::peek(unsigned offset) { caddr_t dbuf; lock(); if(offset >= objcount) { unlock(); return invalid(); } dbuf = head + (objsize * offset); if(dbuf >= buf + bufsize) dbuf -= bufsize; unlock(); return dbuf; } void Buffer::copy(void *data) { assert(data != NULL); void *ptr = get(); memcpy(data, ptr, objsize); release(); } bool Buffer::copy(void *data, timeout_t timeout) { assert(data != NULL); void *ptr = get(timeout); if(!ptr) return false; memcpy(data, ptr, objsize); release(); return true; } void *Buffer::get(timeout_t timeout) { caddr_t dbuf = NULL; struct timespec ts; bool rtn = true; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(!objcount && rtn) { if(timeout == Timer::inf) wait(); else if(timeout) rtn = wait(&ts); else rtn = false; } if(objcount && rtn) dbuf = head; unlock(); return dbuf; } void Buffer::release(void) { lock(); head += objsize; if(head >= buf + bufsize) head = buf; --objcount; signal(); unlock(); } void Buffer::put(void *dbuf) { assert(dbuf != NULL); lock(); while(objcount == limit) wait(); memcpy(tail, dbuf, objsize); tail += objsize; if(tail >= (buf + bufsize)) tail = buf; ++objcount; signal(); unlock(); } bool Buffer::put(void *dbuf, timeout_t timeout) { assert(dbuf != NULL); bool rtn = true; struct timespec ts; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(objcount == limit && rtn) { if(timeout == Timer::inf) wait(); else if(timeout) rtn = wait(&ts); else rtn = false; } if(rtn && objcount < limit) { memcpy(tail, dbuf, objsize); tail += objsize; if(tail >= (buf + bufsize)) tail = 0; ++objcount; signal(); } unlock(); return rtn; } Buffer::operator bool() { bool rtn = false; lock(); if(buf && head != tail) rtn = true; unlock(); return rtn; } bool Buffer::operator!() { bool rtn = false; lock(); if(!buf || head == tail) rtn = true; unlock(); return rtn; } Queue::member::member(Queue *q, ObjectProtocol *o) : OrderedObject(q) { assert(o != NULL); o->retain(); object = o; } Queue::Queue(mempager *p, size_t size) : OrderedIndex(), Conditional() { assert(size > 0); pager = p; freelist = NULL; used = 0; limit = size; } Queue::~Queue() { linked_pointer mp; OrderedObject *next; if(pager) return; mp = freelist; while(is(mp)) { next = mp->getNext(); delete *mp; mp = next; } mp = head; while(is(mp)) { next = mp->getNext(); delete *mp; mp = next; } } bool Queue::remove(ObjectProtocol *o) { assert(o != NULL); bool rtn = false; linked_pointer node; lock(); node = begin(); while(node) { if(node->object == o) break; node.next(); } if(node) { --used; rtn = true; node->object->release(); node->delist(this); node->LinkedObject::enlist(&freelist); } unlock(); return rtn; } ObjectProtocol *Queue::lifo(timeout_t timeout) { struct timespec ts; bool rtn = true; member *member; ObjectProtocol *obj = NULL; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(!tail && rtn) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(rtn && tail) { --used; member = static_cast(tail); obj = member->object; member->delist(this); member->LinkedObject::enlist(&freelist); } if(rtn) signal(); unlock(); return obj; } ObjectProtocol *Queue::fifo(timeout_t timeout) { bool rtn = true; struct timespec ts; linked_pointer node; ObjectProtocol *obj = NULL; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(rtn && !head) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(rtn && head) { --used; node = begin(); obj = node->object; head = head->getNext(); if(!head) tail = NULL; node->LinkedObject::enlist(&freelist); } if(rtn) signal(); unlock(); return obj; } ObjectProtocol *Queue::invalid(void) const { return NULL; } ObjectProtocol *Queue::get(unsigned back) { linked_pointer node; ObjectProtocol *obj; lock(); node = begin(); do { if(!is(node)) { obj = invalid(); break; } obj = node->object; node.next(); } while(back-- > 0); unlock(); return obj; } bool Queue::post(ObjectProtocol *object, timeout_t timeout) { assert(object != NULL); bool rtn = true; struct timespec ts; LinkedObject *mem; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(rtn && limit && used == limit) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(!rtn) { unlock(); return false; } ++used; if(freelist) { mem = freelist; freelist = freelist->getNext(); new((caddr_t)mem) member(this, object); } else { if(pager) new((caddr_t)(pager->alloc(sizeof(member)))) member(this, object); else new member(this, object); } signal(); unlock(); return true; } size_t Queue::count(void) { size_t qcount; lock(); qcount = used; unlock(); return qcount; } Stack::member::member(Stack *S, ObjectProtocol *o) : LinkedObject((&S->usedlist)) { assert(o != NULL); o->retain(); object = o; } Stack::Stack(mempager *p, size_t size) : Conditional() { assert(size > 0); pager = p; freelist = usedlist = NULL; limit = size; used = 0; } Stack::~Stack() { linked_pointer mp; LinkedObject *next; if(pager) return; mp = freelist; while(is(mp)) { next = mp->getNext(); delete *mp; mp = next; } mp = usedlist; while(is(mp)) { next = mp->getNext(); delete *mp; mp = next; } } bool Stack::remove(ObjectProtocol *o) { assert(o != NULL); bool rtn = false; linked_pointer node; lock(); node = static_cast(usedlist); while(node) { if(node->object == o) break; node.next(); } if(node) { --used; rtn = true; node->object->release(); node->delist(&usedlist); node->enlist(&freelist); } unlock(); return rtn; } ObjectProtocol *Stack::invalid(void) const { return NULL; } ObjectProtocol *Stack::get(unsigned back) { linked_pointer node; ObjectProtocol *obj; lock(); node = usedlist; do { if(!is(node)) { obj = invalid(); break; } obj = node->object; node.next(); } while(back-- > 0); unlock(); return obj; } const ObjectProtocol *Stack::peek(timeout_t timeout) { bool rtn = true; struct timespec ts; member *member; ObjectProtocol *obj = NULL; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(rtn && !usedlist) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(!rtn) { unlock(); return NULL; } if(usedlist) { member = static_cast(usedlist); obj = member->object; } if(rtn) signal(); unlock(); return obj; } ObjectProtocol *Stack::pull(timeout_t timeout) { bool rtn = true; struct timespec ts; member *member; ObjectProtocol *obj = NULL; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(rtn && !usedlist) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(!rtn) { unlock(); return NULL; } if(usedlist) { member = static_cast(usedlist); obj = member->object; usedlist = member->getNext(); member->enlist(&freelist); } if(rtn) signal(); unlock(); return obj; } bool Stack::push(ObjectProtocol *object, timeout_t timeout) { assert(object != NULL); bool rtn = true; struct timespec ts; LinkedObject *mem; if(timeout && timeout != Timer::inf) set(&ts, timeout); lock(); while(rtn && limit && used == limit) { if(timeout == Timer::inf) Conditional::wait(); else if(timeout) rtn = Conditional::wait(&ts); else rtn = false; } if(!rtn) { unlock(); return false; } ++used; if(freelist) { mem = freelist; freelist = freelist->getNext(); new((caddr_t)mem) member(this, object); } else { if(pager) { caddr_t ptr = (caddr_t)pager->alloc(sizeof(member)); new(ptr) member(this, object); } else new member(this, object); } signal(); unlock(); return true; } size_t Stack::count(void) { size_t scount; lock(); scount = used; unlock(); return scount; } ucommon-6.0.7/corelib/stream.cpp0000644000175000017500000004061212163025062013540 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #if defined(OLD_STDCPP) || defined(NEW_STDCPP) #include #include #include #include #include #include #include #include #ifndef _MSWINDOWS_ #include #include #include #include #ifdef HAVE_FCNTL_H #include #endif #endif #ifdef HAVE_SYS_RESOURCE_H #include #include #endif using namespace UCOMMON_NAMESPACE; using namespace std; StreamBuffer::StreamBuffer() : streambuf(), #ifdef OLD_STDCPP iostream() #else iostream((streambuf *)this) #endif { bufsize = 0; gbuf = pbuf = NULL; #ifdef OLD_STDCPP init((streambuf *)this); #endif } int StreamBuffer::uflow() { int ret = underflow(); if (ret == EOF) return EOF; if (bufsize != 1) gbump(1); return ret; } void StreamBuffer::allocate(size_t size) { if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; if(size < 2) { bufsize = 1; return; } gbuf = new char[size]; pbuf = new char[size]; assert(gbuf != NULL && pbuf != NULL); bufsize = size; clear(); #if (defined(__GNUC__) && (__GNUC__ < 3)) && !defined(MSWINDOWS) && !defined(STLPORT) setb(gbuf, gbuf + size, 0); #endif setg(gbuf, gbuf + size, gbuf + size); setp(pbuf, pbuf + size); } void StreamBuffer::release(void) { if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; bufsize = 0; clear(); } int StreamBuffer::sync(void) { if(!bufsize) return 0; overflow(EOF); setg(gbuf, gbuf + bufsize, gbuf + bufsize); return 0; } tcpstream::tcpstream(const tcpstream ©) : StreamBuffer() { so = Socket::create(Socket::family(copy.so), SOCK_STREAM, IPPROTO_TCP); timeout = copy.timeout; } tcpstream::tcpstream(int family, timeout_t tv) : StreamBuffer() { so = Socket::create(family, SOCK_STREAM, IPPROTO_TCP); timeout = tv; } tcpstream::tcpstream(Socket::address& list, unsigned segsize, timeout_t tv) : StreamBuffer() { so = Socket::create(list.family(), SOCK_STREAM, IPPROTO_TCP); timeout = tv; open(list); } tcpstream::tcpstream(const TCPServer *server, unsigned segsize, timeout_t tv) : StreamBuffer() { so = server->accept(); timeout = tv; if(so == INVALID_SOCKET) { clear(ios::failbit | rdstate()); return; } allocate(segsize); } tcpstream::~tcpstream() { tcpstream::release(); } void tcpstream::release(void) { StreamBuffer::release(); Socket::release(so); } #ifndef MSG_WAITALL #define MSG_WAITALL 0 #endif bool tcpstream::_wait(void) { if(!timeout) return true; return Socket::wait(so, timeout); } ssize_t tcpstream::_read(char *buffer, size_t size) { return Socket::recvfrom(so, buffer, size, MSG_WAITALL); } ssize_t tcpstream::_write(const char *buffer, size_t size) { return Socket::sendto(so, buffer, size); } int tcpstream::underflow(void) { ssize_t rlen = 1; unsigned char ch; if(bufsize == 1) { if(!_wait()) { clear(ios::failbit | rdstate()); return EOF; } else rlen = _read((char *)&ch, 1); if(rlen < 1) { if(rlen < 0) reset(); return EOF; } return ch; } if(!gptr()) return EOF; if(gptr() < egptr()) return (unsigned char)*gptr(); rlen = (ssize_t)((gbuf + bufsize) - eback()); if(!_wait()) { clear(ios::failbit | rdstate()); return EOF; } else { rlen = _read(eback(), rlen); } if(rlen < 1) { // clear(ios::failbit | rdstate()); if(rlen < 0) reset(); else clear(ios::failbit | rdstate()); return EOF; } setg(eback(), eback(), eback() + rlen); return (unsigned char) *gptr(); } int tcpstream::overflow(int c) { unsigned char ch; ssize_t rlen, req; if(bufsize == 1) { if(c == EOF) return 0; ch = (unsigned char)(c); rlen = _write((const char *)&ch, 1); if(rlen < 1) { if(rlen < 0) reset(); return EOF; } else return c; } if(!pbase()) return EOF; req = (ssize_t)(pptr() - pbase()); if(req) { rlen = _write(pbase(), req); if(rlen < 1) { if(rlen < 0) reset(); return EOF; } req -= rlen; } // if write "partial", rebuffer remainder if(req) // memmove(pbuf, pptr() + rlen, req); memmove(pbuf, pbuf + rlen, req); setp(pbuf, pbuf + bufsize); pbump(req); if(c != EOF) { *pptr() = (unsigned char)c; pbump(1); } return c; } void tcpstream::open(Socket::address& list, unsigned mss) { if(bufsize) close(); // close if existing is open... if(Socket::connectto(so, *list)) return; allocate(mss); } void tcpstream::open(const char *host, const char *service, unsigned mss) { if(bufsize) close(); struct addrinfo *list = Socket::query(host, service, SOCK_STREAM, 0); if(!list) return; if(Socket::connectto(so, list)) { Socket::release(list); return; } Socket::release(list); allocate(mss); } void tcpstream::reset(void) { if(!bufsize) return; if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; bufsize = 0; clear(); Socket::disconnect(so); } void tcpstream::close(void) { if(!bufsize) return; sync(); if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; bufsize = 0; clear(); Socket::disconnect(so); } void tcpstream::allocate(unsigned mss) { unsigned size = mss; unsigned max = 0; #ifdef TCP_MAXSEG socklen_t alen = sizeof(max); #endif if(mss == 1) goto allocate; #ifdef TCP_MAXSEG if(mss) setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&max, sizeof(max)); getsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&max, &alen); #endif if(max && max < mss) mss = max; if(!mss) { if(max) mss = max; else mss = 536; goto allocate; } #ifdef TCP_MAXSEG setsockopt(so, IPPROTO_TCP, TCP_MAXSEG, (char *)&mss, sizeof(mss)); #endif if(mss < 80) mss = 80; if(mss * 7 < 64000u) bufsize = mss * 7; else if(mss * 6 < 64000u) bufsize = mss * 6; else bufsize = mss * 5; Socket::sendsize(so, bufsize); Socket::recvsize(so, bufsize); if(mss < 512) Socket::sendwait(so, mss * 4); allocate: StreamBuffer::allocate(size); } pipestream::pipestream() : StreamBuffer() { } pipestream::pipestream(const char *cmd, access_t access, char **args, char **envp, size_t size) : StreamBuffer() { open(cmd, access, args, envp, size); } pipestream::~pipestream() { close(); } void pipestream::terminate(void) { if(bufsize) { shell::cancel(pid); close(); } } void pipestream::release(void) { if(gbuf) fsys::release(rd); if(pbuf) fsys::release(wr); StreamBuffer::release(); } void pipestream::allocate(size_t size, access_t mode) { if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; if(size < 2) { bufsize = 1; return; } if(mode == RDONLY || mode == RDWR) gbuf = new char[size]; if(mode == WRONLY || mode == RDWR) pbuf = new char[size]; bufsize = size; clear(); if(mode == RDONLY || mode == RDWR) { #if (defined(__GNUC__) && (__GNUC__ < 3)) && !defined(MSWINDOWS) && !defined(STLPORT) setb(gbuf, gbuf + size, 0); #endif setg(gbuf, gbuf + size, gbuf + size); } if(mode == WRONLY || mode == RDWR) setp(pbuf, pbuf + size); } int pipestream::underflow(void) { ssize_t rlen = 1; unsigned char ch; if(!gbuf) return EOF; if(bufsize == 1) { rlen = rd.read(&ch, 1); if(rlen < 1) { if(rlen < 0) close(); return EOF; } return ch; } if(!gptr()) return EOF; if(gptr() < egptr()) return (unsigned char)*gptr(); rlen = (ssize_t)((gbuf + bufsize) - eback()); rlen = rd.read(eback(), rlen); if(rlen < 1) { // clear(ios::failbit | rdstate()); if(rlen < 0) close(); else clear(ios::failbit | rdstate()); return EOF; } setg(eback(), eback(), eback() + rlen); return (unsigned char) *gptr(); } int pipestream::overflow(int c) { unsigned char ch; ssize_t rlen, req; if(!pbuf) return EOF; if(bufsize == 1) { if(c == EOF) return 0; ch = (unsigned char)(c); rlen = wr.write(&ch, 1); if(rlen < 1) { if(rlen < 0) close(); return EOF; } else return c; } if(!pbase()) return EOF; req = (ssize_t)(pptr() - pbase()); if(req) { rlen = wr.write(pbase(), req); if(rlen < 1) { if(rlen < 0) close(); return EOF; } req -= rlen; } // if write "partial", rebuffer remainder if(req) // memmove(pbuf, pptr() + rlen, req); memmove(pbuf, pbuf + rlen, req); setp(pbuf, pbuf + bufsize); pbump(req); if(c != EOF) { *pptr() = (unsigned char)c; pbump(1); } return c; } void pipestream::open(const char *path, access_t mode, char **args, char **envp, size_t size) { /*#ifdef RLIMIT_NOFILE struct rlimit rlim; if(!getrlimit(RLIMIT_NOFILE, &rlim)) max = rlim.rlim_max; #endif */ close(); fd_t stdio[3] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}; fd_t input = INVALID_HANDLE_VALUE, output = INVALID_HANDLE_VALUE; if(mode == RDONLY || mode == RDWR) { if(fsys::pipe(input, stdio[1])) return; fsys::inherit(input, false); } else stdio[1] = fsys::null(); if(mode == WRONLY || mode == RDWR) { if(fsys::pipe(stdio[0], output)) { if(mode == RDWR) { fsys::release(stdio[1]); fsys::release(input); input = INVALID_HANDLE_VALUE; } return; } } else stdio[0] = fsys::null(); pid = shell::spawn(path, args, envp, stdio); fsys::release(stdio[0]); fsys::release(stdio[1]); if(pid == INVALID_PID_VALUE) { fsys::release(input); fsys::release(output); input = output = INVALID_HANDLE_VALUE; } else allocate(size, mode); rd.assign(input); wr.assign(output); } int pipestream::close(void) { sync(); if(bufsize) { release(); return shell::wait(pid); } return -1; } filestream::filestream() : StreamBuffer() { } filestream::filestream(const filestream& copy) : StreamBuffer() { if(copy.bufsize) fd = copy.fd; if(is(fd)) allocate(copy.bufsize, copy.ac); } filestream::filestream(const char *filename, fsys::access_t mode, size_t size) : StreamBuffer() { open(filename, mode, size); } filestream::filestream(const char *filename, unsigned mode, fsys::access_t access, size_t size) : StreamBuffer() { open(filename, mode, access, size); } filestream::~filestream() { close(); } void filestream::seek(fsys::offset_t offset) { if(bufsize) { sync(); fd.seek(offset); } } void filestream::close(void) { sync(); if(bufsize) fd.close(); StreamBuffer::release(); } void filestream::allocate(size_t size, fsys::access_t mode) { if(gbuf) delete[] gbuf; if(pbuf) delete[] pbuf; gbuf = pbuf = NULL; ac = mode; if(size < 2) { bufsize = 1; return; } if(mode == fsys::RDONLY || fsys::RDWR || fsys::SHARED) gbuf = new char[size]; if(mode == fsys::WRONLY || fsys::APPEND || fsys::SHARED || fsys::RDWR) pbuf = new char[size]; bufsize = size; clear(); if(mode == fsys::RDONLY || fsys::RDWR || fsys::SHARED) { #if (defined(__GNUC__) && (__GNUC__ < 3)) && !defined(MSWINDOWS) && !defined(STLPORT) setb(gbuf, gbuf + size, 0); #endif setg(gbuf, gbuf + size, gbuf + size); } if(mode == fsys::WRONLY || fsys::APPEND || fsys::SHARED || fsys::RDWR) setp(pbuf, pbuf + size); } void filestream::open(const char *fname, unsigned fmode, fsys::access_t access, size_t size) { close(); fd.open(fname, fmode, access); if(is(fd)) allocate(size, access); } void filestream::open(const char *fname, fsys::access_t access, size_t size) { close(); fd.open(fname, access); if(is(fd)) allocate(size, access); } int filestream::underflow(void) { ssize_t rlen = 1; if(!gbuf) return EOF; if(!gptr()) return EOF; if(gptr() < egptr()) return (unsigned char)*gptr(); rlen = (ssize_t)((gbuf + bufsize) - eback()); rlen = fd.read(eback(), rlen); if(rlen < 1) { // clear(ios::failbit | rdstate()); if(rlen < 0) close(); else clear(ios::failbit | rdstate()); return EOF; } setg(eback(), eback(), eback() + rlen); return (unsigned char) *gptr(); } int filestream::overflow(int c) { ssize_t rlen, req; if(!pbuf) return EOF; if(!pbase()) return EOF; req = (ssize_t)(pptr() - pbase()); if(req) { rlen = fd.write(pbase(), req); if(rlen < 1) { if(rlen < 0) close(); return EOF; } req -= rlen; } // if write "partial", rebuffer remainder if(req) // memmove(pbuf, pptr() + rlen, req); memmove(pbuf, pbuf + rlen, req); setp(pbuf, pbuf + bufsize); pbump(req); if(c != EOF) { *pptr() = (unsigned char)c; pbump(1); } return c; } std::istream& _stream_operators::input(std::istream& inp, InputProtocol& fmt) { int c = 0; while(!c) { if(!inp.good()) c = EOF; else c = inp.get(); c = fmt._input(c); if(!c) continue; if(c != EOF) inp.putback(c); } return inp; } std::ostream& _stream_operators::print(std::ostream& out, const PrintProtocol& fmt) { if(out.good()) { const char *cp = fmt._print(); if(cp) out.write(cp, strlen(cp)); else out << std::endl; } return out; } std::istream& _stream_operators::input(std::istream& inp, string_t& str) { inp.getline(str.c_mem(), str.size()); return inp; } std::ostream& _stream_operators::print(std::ostream& out, const string_t& str) { out.write(str.c_str(), str.len()); return out; } std::istream& _stream_operators::input(std::istream& inp, stringlist_t& list) { size_t size = list.size() - 64; char *tmp = (char *)malloc(size); while(inp.good()) { inp.getline(tmp, size); if(!list.filter(tmp, size)) break; } free(tmp); return inp; } std::ostream& _stream_operators::print(std::ostream& out, const stringlist_t& list) { StringPager::iterator sp = list.begin(); while(is(sp) && out.good()) { const char *cp = sp->get(); size_t size = strlen(cp); if(size) out.write(cp, size); out.put('\n'); sp.next(); } return out; } #endif ucommon-6.0.7/corelib/counter.cpp0000644000175000017500000000353412163025062013726 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif using namespace UCOMMON_NAMESPACE; counter::counter() { cycle = value = 0; } counter::counter(unsigned max) { assert(max > 0); cycle = max; value = 0; } void counter::operator=(unsigned v) { if(!cycle || v < cycle) value = v; } unsigned counter::get(void) { unsigned v = value++; if(cycle && value >= cycle) value = 0; return v; } SeqCounter::SeqCounter(void *base, size_t size, unsigned limit) : counter(limit) { assert(base != NULL); assert(size > 0); assert(limit > 0); item = base; offset = size; } void *SeqCounter::get(void) { unsigned pos = counter::get(); return (caddr_t)item + (pos * offset); } void *SeqCounter::get(unsigned pos) { if(pos >= range()) return NULL; return (caddr_t)item + (pos * offset); } bool toggle::get(void) { bool v = value; if(value) value = false; else value = true; return v; } ucommon-6.0.7/corelib/shell.cpp0000644000175000017500000015652012163025062013362 00000000000000// Copyright (C) 2006-2010 David Sugar, Tycho Softworks. // // This file is part of GNU uCommon C++. // // GNU uCommon C++ is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GNU uCommon C++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with GNU uCommon C++. If not, see . #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #ifdef _MSWINDOWS_ #include #include #include #else #include #include #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_TERMIOS_H #include #endif #ifdef HAVE_TERMIO_H #include #endif #endif #ifdef HAVE_SYS_RESOURCE_H #include #include #endif #ifdef HAVE_SETLOCALE #include #else #define setlocale(s, t) #endif #ifndef HAVE_LIBINTL_H #undef HAVE_GETTEXT #endif #ifdef HAVE_GETTEXT #include #else #define dgettext(d, s) s #define gettext(s) s #define bindtextdomain(s, t) #define textdomain(s) #endif #ifdef HAVE_SYSLOG_H #include #endif #ifndef OPEN_MAX #define OPEN_MAX 20 #endif #ifndef WEXITSTATUS #define WEXITSTATUS(status) ((unsigned)(status) >> 8) #endif #ifndef _PATH_TTY #define _PATH_TTY "/dev/tty" #endif using namespace UCOMMON_NAMESPACE; static shell::loglevel_t errlevel = shell::WARN; static shell::logmode_t errmode = shell::NONE; static const char *errname = NULL; static shell::logproc_t errproc = (shell::logproc_t)NULL; static mutex_t symlock; static char **_orig = NULL; static shell::Option *ofirst = NULL, *olast = NULL; static const char *_domain = NULL; static shell::exitproc_t _exitproc = NULL; static shell::numeric_t numeric_mode = shell::NO_NUMERIC; static long numeric_value = 0l; shell::Option::Option(char shortopt, const char *longopt, const char *value, const char *help) : LinkedObject() { if(olast) { olast->Next = this; olast = this; } else ofirst = olast = this; while(longopt && *longopt == '-') ++longopt; short_option = shortopt; long_option = longopt; uses_option = value; help_string = help; trigger_option = false; } shell::Option::~Option() { } void shell::Option::reset(void) { ofirst = olast = NULL; } LinkedObject *shell::Option::first(void) { return ofirst; } void shell::Option::disable(void) { short_option = 0; long_option = NULL; help_string = NULL; uses_option = NULL; } shell::flagopt::flagopt(char short_option, const char *long_option, const char *help_string, bool single_use) : shell::Option(short_option, long_option, NULL, help_string) { single = single_use; counter = 0; } const char *shell::flagopt::assign(const char *value) { if(single && counter) return shell::errmsg(shell::OPTION_USED); ++counter; return NULL; } shell::numericopt::numericopt(char short_option, const char *long_option, const char *help_string, const char *type, long def_value) : shell::Option(short_option, long_option, type, help_string) { used = false; number = def_value; } const char *shell::numericopt::assign(const char *value) { char *endptr = NULL; if(used) return errmsg(shell::OPTION_USED); used = true; number = strtol(value, &endptr, 0); if(!endptr || *endptr != 0) return errmsg(shell::BAD_VALUE); return NULL; } shell::counteropt::counteropt(char short_option, const char *long_option, const char *help_string, const char *type, long def_value) : shell::Option(short_option, long_option, type, help_string) { used = false; number = def_value; trigger_option = true; } const char *shell::counteropt::assign(const char *value) { char *endptr = NULL; // trigger option mode received... if(value == NULL) { ++number; used = true; return NULL; } if(used) return errmsg(shell::OPTION_USED); used = true; number = strtol(value, &endptr, 0); if(!endptr || *endptr != 0) return errmsg(shell::BAD_VALUE); return NULL; } shell::groupopt::groupopt(const char *help_string) : shell::Option(0, NULL, NULL, help_string) { } const char *shell::groupopt::assign(const char *value) { return NULL; } shell::stringopt::stringopt(char short_option, const char *long_option, const char *help_string, const char *type, const char *def_value) : shell::Option(short_option, long_option, type, help_string) { used = false; text = def_value; } const char *shell::stringopt::assign(const char *value) { if(used) return shell::errmsg(shell::OPTION_USED); text = value; used = true; return NULL; } shell::charopt::charopt(char short_option, const char *long_option, const char *help_string, const char *type, char def_value) : shell::Option(short_option, long_option, type, help_string) { used = false; code = def_value; } const char *shell::charopt::assign(const char *value) { long number; char *endptr = NULL; if(used) return shell::errmsg(shell::OPTION_USED); used = true; if(value[1] == 0) { code = value[0]; return NULL; } number = strtol(value, &endptr, 0); if(!endptr || *endptr != 0) return errmsg(shell::BAD_VALUE); if(number < 0 || number > 255) return errmsg(shell::BAD_VALUE); code = (char)(number); return NULL; } void shell::collapse(LinkedObject *first) { char **argv = _argv = (char **)mempager::_alloc(sizeof(char **) * (_argc + 1)); linked_pointer ap = first; while(is(ap)) { *(argv++) = ap->item; ap.next(); } *argv = NULL; } void shell::set0(char *argv0) { char prefix[256]; if(_argv0) return; if(*argv0 != '/' && *argv0 != '\\' && argv0[1] != ':') { fsys::prefix(prefix, sizeof(prefix)); String::add(prefix, sizeof(prefix), "/"); String::add(prefix, sizeof(prefix), argv0); } else String::set(prefix, sizeof(prefix), argv0); argv0 = _exedir = dup(prefix); _argv0 = strrchr(argv0, '/'); #ifdef _MSWINDOWS_ if(!_argv0) _argv0 = strrchr(argv0, '\\'); if(!_argv0) _argv0 = strchr(argv0, ':'); #endif if(!_argv0) _argv0 = argv0; else (*_argv0++) = 0; if(eq(_argv0, "lt-", 3)) _argv0 += 3; // _argv0 = dup(_argv0); #ifdef _MSWINDOWS_ char *ext = strrchr(_argv0, '.'); if(eq_case(ext, ".exe") || eq_case(ext, ".com")) *ext = 0; #endif if(!_domain) bind(_argv0); } shell::shell(size_t pagesize) : mempager(pagesize) { _exedir = NULL; _argv0 = NULL; _argv = NULL; _argc = 0; _syms = NULL; } shell::shell(const char *string, size_t pagesize) : mempager(pagesize) { _argv0 = NULL; _argv = NULL; _argc = 0; _syms = NULL; parse(string); } shell::shell(int argc, char **argv, size_t pagesize) : mempager(pagesize) { _argv0 = NULL; _argv = NULL; _argc = 0; _syms = NULL; parse(argc, argv); } static const char *msgs[] = { _TEXT("missing command line arguments"), _TEXT("missing argument for option"), _TEXT("option does not have argument"), _TEXT("unknown command option"), _TEXT("option already used"), _TEXT("invalid argument used"), _TEXT("numeric value already set"), NULL}; const char *shell::errmsg(errmsg_t id) { return dgettext("ucommon", msgs[id]); } void shell::errmsg(errmsg_t id, const char *text) { msgs[id] = shell::text(text); } void shell::setNumeric(numeric_t mode) { numeric_mode = mode; numeric_value = 0l; } long shell::getNumeric(void) { return numeric_value; } unsigned shell::count(char **argv) { unsigned count = 0; while(argv && argv[count]) ++count; return count; } void shell::help(void) { linked_pointer