objfw-1.3 040755 001750 001750 00000000000 14767513714 011462 5 ustar 00js js 000000 000000 objfw-1.3/COPYING 100644 001750 001750 00000104515 14767513633 012577 0 ustar 00js js 000000 000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free 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
.
objfw-1.3/COPYING.LESSER 100644 001750 001750 00000016744 14767513633 013601 0 ustar 00js js 000000 000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
objfw-1.3/ChangeLog 100644 001750 001750 00000074150 14767513633 013317 0 ustar 00js js 000000 000000 Legend:
* Changes of existing features or bugfixes
+ New features
This file only contains the most significant changes.
ObjFW 1.2.4 -> ObjFW 1.3, 2025-03-22
+ OFStdIOStream adds support truecolor, 256 colors, bold, italic, underlined
and italic.
* OFStdIOStream now keeps track of state to reduce the amount of escape codes
used.
+ Adds support for getting peer credentials to UNIX sockets.
+ Adds support for MPTCP.
+ Adds more functions to parse integers to OFString.
+ Adds range checks to OFNumber instead of truncating values.
* Deprecates OFPlugin in favor of OFModule.
* Deprecates a few methods in various classes, their replacements are
specified in the deprecation message.
* Optimizes lookup for embedded files.
* Improves EINTR handling throughout the entire code base.
+ ObjFWRT calls +[load] on categories now.
* Adds and uses more error codes for OFTLSStream.
+ Adds OFX509Certificate with support for PKCS #12 and PEM files.
+ Adds server mode for OFTLSStream.
+ Adds support for TLS to OFHTTPServer.
+ Adds support for mbedTLS 3 to ObjFWTLS.
* Fixes handling of unexpected stream end in OFOpenSSLTLSStream.
+ OFRunLoop now supports interacting with foreign run loops.
+ ObjFWBridge now provides an OFKernelEventObserver implementation that uses
CFRunLoop to allow running code that needs a CFRunLoop inside an OFRunLoop.
+ ObjFWBridge now bridges OFDate/NSDate and OFData/NSData.
* Fixes ObjFWBridge on macOS 10.5 (Leopard).
+ Adds documentation for ObjFWBridge.
+ Adds support for game controllers on macOS & iOS to ObjFWHID.
+ Adds OFNotifications for changes values to ObjFWHID.
* ObjFWHID now uses more consistent names for game controller elements.
+ Adds game controller-specific profiles on Linux to ObjFWHID for the following
controllers: Switch Pro Controller, Nintendo Switch Online SNES gamepad,
8BitDo Ultimate 2C Wireless, 8BitDo NES30.
+ Adds game controller-specific profiles on macOS & iOS to ObjFWHID for the
following controllers: DualSense, DualShock 4, pair of Joy-Cons, Switch Pro
Controller, Nintendo Switch Online N64 controller, Nintendo Switch Online
SNES gamepad, Stadia gamepad, 8BitDo NES30.
* ObjFWHID now filters spurious extra buttons with the Xbox 360 Wireless
Receiver on Linux.
* ObjFWHID now assumes a single Joy-Con to be rotated and handles it
accordingly.
* ofarc now quarantines files before setting permissions, preventing an issue
where the permissions would no longer allow quarantining files.
ObjFW 1.2.3 -> ObjFW 1.2.4, 2025-02-20
* Fixes OFPlainConditionTimedWait(), which as a result fixes OFRunLoop
spinning in some situations.
* Fixes OFMutableUTF8Strings containing `\0`.
* Fixes OFHTTPServer using an IPv6 address as host.
ObjFW 1.2.2 -> ObjFW 1.2.3, 2024-12-15
* Fixes OFRunLoop not draining the autorelease pool after firing a timer.
* Adds -fno-constant-ns{number,array,dictionary}-literals to OBJCFLAGS, which
is required to have literals work with ObjFW with recent Xcode versions.
ObjFW 1.2.1 -> ObjFW 1.2.2, 2024-12-07
* Fixes OFTLSSocket not sending shutdown when using OpenSSL.
* Fixes OFTLSSocket initialization when using MbedTLS.
* Fixes imports in ObjFWTLS.h.
* OFINIFile now properly quotes ; and #.
* Ensures ofarc and ofhash link ObjFWTLS.
* Makes OFEmbeddedIRIHandler public, as it's required for objfw-embed.
* Fixes compiling on Haiku r1beta5.
* Adds compatibility with latest devkitARM.
ObjFW 1.2 -> ObjFW 1.2.1, 2024-11-09
* Fixes exceptions in ObjC++.
* Fixes compiling ObjC++ on Windows.
* Fixes compiling tests on Haiku.
* Properly hides private methods in ObjFWHID.
ObjFW 1.1.7 -> ObjFW 1.2, 2024-11-02
+ Adds a new framework for game controllers called ObjFWHID.
+ Adds support for tagged pointer strings.
+ Strings are now allowed to contain `\0`, while preventing such strings from
being passed to anything that expects a C string.
* `\u0000` and `\x??` are now allowed in JSON.
+ Adds a new option `OFJSONRepresentationOptionSorted` to create sorted,
reproducible JSON representations.
* Socket initialization is now delayed until sockets are used for the first
time to significantly speed up startup on some systems, in particular game
consoles.
+ Adds -[readString], -[tryReadString] and -[asyncReadString] to OFStream to
read until a `\0` is found.
+ Adds support for SCTP sockets.
+ Adds support for UNIX sequenced packet sockets.
+ Adds assembly lookup for the following platforms: ARM64/Win64, RISC-V 64/ELF,
LoongArch 64/ELF.
+ Adds -[forwardingTargetForSelector:] for the following platforms:
MIPS64-N64/ELF, RISC-V 64/ELF, LoongArch 64/ELF, PowerPC 64/ELF v1,
PowerPC 64/ELF v2, ARM64/Win64
+ Adds support for the following encodings: Windows-1250, Codepage 852.
+ Adds support for extended attributes on Solaris.
* OFPlugin now falls back to loading .dylibs on macOS/iOS when no .bundle was
found.
* OFINICategory was renamed to OFINISection.
* The API for async I/O handlers was changed to contain more arguments, which
results in new methods that take a handler instead of a block and deprecating
the old ones.
* -[attributesOfItemAtIRI:] now works for embedded files.
* `OF_APPLICATION_DELEGATE()` now works with `-mwindows`.
+ Adds man pages for all utilities.
* ofdns now defaults to query AAAA and A, not ALL.
* ofhash now accepts --rmd160 as an alias for --ripemd160.
ObjFW 1.1.6 -> ObjFW 1.1.7, 2024-08-25
* Fixes creating OFStrings from C strings with some encodings.
* Fixes creating an ASCII C string from an OFString that has been initialized
by passing an instance of a custom string class.
* Fixes OFINIFile not parsing `=` within `"` correctly.
* OFINIFile now allows comments and pairs before the first category.
* OFINIFile now allows # for comments.
* Hides some private symbols in the runtime library.
* Disables UNIX datagram sockets on Hurd as Hurd has incomplete support for
UNIX datagram sockets.
ObjFW 1.1.5 -> ObjFW 1.1.6, 2024-08-11
* Fixes ObjC++ with GCC.
* Adds handling of EINTR in OFKernelEventObserver.
* Fixes overriding / reusing stack arguments in super calls on x86.
* Makes headers compatible with -Wunused-parameter.
ObjFW 1.1.4 -> ObjFW 1.1.5, 2024-07-06
* Fixes MIPS32.
* Properly hides private symbols in the runtime so they can't be used
accidentally anymore.
ObjFW 1.1.3 -> ObjFW 1.1.4, 2024-05-22
* Fixes ofarc failing to extract from stdin on macOS.
* Fixes the workaround for missing blx on ARM.
* Avoids Clang's integrated assembler on MIPS64 for .S files (as it cannot
calcualte the offset between two labels).
* Fixes X32 being mistaken for AMD64.
ObjFW 1.1.2 -> ObjFW 1.1.3, 2024-05-12
* Fixes +[OFSystemInfo networkInterfaces] on NetBSD.
* Properly hides private symbols so they can't be used accidentally anymore.
* Adds missing documentation for various functions and macros.
* Uses RtlGenRandom to get proper randomness on Windows now.
* No longer uses _wutime64, which is buggy in some MinGW distributions.
* Only uses blx on ARM if it is available now.
* Adds a workaround for OFSubprocess tests on Windows 9x.
* Skips symlink tests if symlinks are unavailable.
ObjFW 1.1.1 -> ObjFW 1.1.2, 2024-04-20
* Fixes configure script on systems using BusyBox for tr.
* Fixes compiling for Haiku.
* Fixes -[contentsOfDirectoryAtIRI:] corrupting the stack on Solaris.
* Fixes compiling for Wii with newer SDK.
* Fixes missing endbr / bti.
* Minor optimizations to ARM64 assembly.
ObjFW 1.1 -> ObjFW 1.1.1, 2024-04-14
* Fixes missing ${DESTDIR} in some Makefiles.
ObjFW 1.0.12 -> ObjFW 1.1, 2024-04-14
* ObjFW is now licensed under LGPLv3.0-only.
+ Adds a new framework for writing tests called ObjFWTest.
* All tests were migrated to ObjFWTest.
+ The runtime now supports associated objects.
+ OFDNSResolver now caches responses.
+ OFDNSResolver now supports URI and LOC DNS resource records.
+ Adds methods to handle path extension to OFIRI.
+ Adds support for Mbed TLS.
+ Adds more methods to OFSystemInfo to check for CPU features.
* OFSystemInfo now only indicates CPU features as supported if the OS also
supports them.
+ OFLHAArchive now supports extracting and creating files > 4 GB.
+ OFLHAArchive now supports header level 3.
+ OFLHAArchive now supports extracting -lhx-, -lz4- and -pm0- files.
* OFLHAArchive no longer defaults to ISO 8859-1.
+ New class OFZooArchive for extracting and creating Zoo files.
* The schemes for archive IRI handlers have been renamed.
* The schemes for archive IRI handlers now look for the rightmost `!`,
which allows for chaining with less quoting.
* Fixes -[OFMutableArray replaceObjectIdenticalTo:withObject:] being
inconsistent with -[OFMutableArray replaceObject:withObject:].
* Fixes getting non-existent xattrs in OFFileManager.
* Objects on Windows, MS-DOS and 32 bit Solaris now get properly aligned so
that SIMD can be used on ivars.
* Fixes parsing of signed numbers in MessagePack.
* Fixes a memory leak in OFTarArchive.
+ Adds support for typed extended file attributes (only on Haiku).
+ Adds support for extended file attributes on Haiku, NetBSD and FreeBSD.
+ OFStdIOStream now supports cursor movement and colors on MS-DOS.
* All headers are now compatible with -masm=intel.
+ OFMatrix4x4 can now transform multiple vectors at once.
+ OFMatrix4x4 has a 3DNow! implementation for multiplication and vector
transformations now.
+ OFMatrix4x4 has an SSE implementation for vector transformations now.
* Updates Unicode support to 15.1.
* Fixes compatibility with LibreSSL.
* Fixes two linker warnings on macOS.
* Fixes compiling on QNX.
* OFLocale now supports automatic initialization.
+ ofarc now supports extracting and creating Zoo archives.
+ ofarc now has an --iri option to directly work on local and remote IRIs.
+ ofarc now prints the archive comment with -lv.
+ ofarc can now add an archive comment with --archive-comment=.
+ ofarc now propagates the quarantine xattr on macOS when extracting an
archive.
ObjFW 1.0.11 -> ObjFW 1.0.12, 2024-03-11
* Fixes a regression in OFZIPArchive that was introduced in 1.0.11 that
resulted in failing to extract archives and creating broken archives.
* Fixes a rare condition where OFInflateStream could end up in an endless
loop.
* Fixes OFTarArchiveEntry not having a default date, which could result in
messaging nil on a FP return, which yielded invalid results on 32-bit x86
with GCC.
ObjFW 1.0.10 -> ObjFW 1.0.11, 2024-03-09
* Fixes -[OFHTTPClientResponse isAtEndOfStream] and
-[OFGZIPStream isAtEndOfStream].
* Fixes how OFZIPArchive handles disk 0 vs. disk 1.
* OFLHAArchive and OFZIPArchive create more compatible archives now.
* OFLHAArchive ignores padding in level 2 headers now.
* ofarc correctly sets modification dates of directories now by delaying
setting those until after all files have been extracted.
* Fixes a linker warning on macOS/iOS.
* Several minor documentation fixes.
* OFFileIRIHandler correctly transforms exceptions now so that they use an IRI
and not a path.
ObjFW 1.0.9 -> ObjFW 1.0.10, 2024-02-24
* Fixes objc_getClassList() not releasing the global runtime mutex.
* Improves OFLHAArchive's compatibility with non-standard archives.
+ Adds endbr32 / endbr64 / bti instructions for compatibility with Control
Flow Integrity.
ObjFW 1.0.8 -> ObjFW 1.0.9, 2024-02-18
* Fixes OFGZIPStream reading the size and CRC32 incorrectly when either spans
multiple reads.
* Fixes a type mismatch in OFMapTable that could cause problems on big endian
systems when uint32_t and unsigned long have a different size.
* Fixes the default implementation of -[initWithKeys:arguments:] for custom
dictionaries.
* Improves detection of mutation during enumeration in
-[enumerateKeysAndObjectsUsingBlock:].
* Minor documentation fixes.
ObjFW 1.0.7 -> ObjFW 1.0.8, 2024-01-21
* Fixes compilation on NetBSD, OpenBSD, OpenIndiana etc. which was broken by
1.0.7.
ObjFW 1.0.6 -> ObjFW 1.0.7, 2024-01-21
* Fixes inheriting the environment in OFSubprocess.
* Fixes dealloc in OFSubprocess when -[closeForWriting] was called.
+ Adds tests for OFSubprocess.
* Changes the key for +[OFSystemInfo networkInterfaces] to the adapter name
on Windows XP and newer to avoid a possible collission on the adapter index.
* Fixes compilation with old MinGW versions.
* Fixes the documentation for OFSRVDNSResourceRecord.
ObjFW 1.0.5 -> ObjFW 1.0.6, 2024-01-15
* Fixes compatibility with autoconf 2.72.
* Fixes OFDNSResolver's handling of types, classes and lengths > 255.
ObjFW 1.0.4 -> ObjFW 1.0.5, 2023-11-05
* Fixes the calculation of the extra alignment in OFAllocObject()
* Fixes +[OFSystemInfo networkInterfaces] on OpenBSD and Windows 98
* Fixes OFSocketAddressString() for AppleTalk addresses
* Uses GetModuleHandle() instead of LoadLibrary() where possible on Windows
* Disables tests for global blocks on Win64 due to broken compilers
* Adds PGP keys to verify tarballs and commits in the code repository
ObjFW 1.0.3 -> ObjFW 1.0.4, 2023-10-08
* Fixes OFFile closing fd 0 when initialization fails
* Fixes -[stringByAppendingPathComponent:] on empty strings
* Fixes +[OFSystemInfo operatingSystemName] and
+[OFSystemInfo operatingSystemVersion] returning nil on some systems
* Adds a license for localizations
ObjFW 1.0.2 -> ObjFW 1.0.3, 2023-09-14
* Fixes -[OFConcreteData initWithItemSize:] not setting freeWhenDone to true,
which resulted in a memory leak
* Fixes -[OFData initWithContentsOfIRI:] freeing the buffer in @catch instead
of @finally, which resulted in a memory leak
ObjFW 1.0.1 -> ObjFW 1.0.2, 2023-09-11
* The build system has been updated to fix building .frameworks and to build
them differently for macOS and iOS
ObjFW 1.0 -> ObjFW 1.0.1, 2023-09-10
* Hanging connections with OFTLSStream have been fixed when using OpenSSL
* The same fix as for OpenSSL has been applied to GnuTLS and SecureTransport
out of caution, even though there have been no hangs in practice
* The build system has been updated to fix building .frameworks among other
minor changes
* Some headers have been changed to fix compatibility with ObjC++
* Warnings about empty .o files on x86_64 Darwin have been fixed
* The OFDate documentation has been improved to list supported formats
ObjFW 0.90.2 -> ObjFW 1.0, 2023-08-29
+ First stable release with stable API and ABI
* Too many changes to list, as it has been almost 6 years since the last
release. See commits in the repository for details.
ObjFW 0.90.1 -> ObjFW 0.90.2, 2017-10-23
* Fix shadowed variables which caused many bugs (e.g. using the wrong object)
* Many, many nullability fixes
* OFTCPSocket: Fix exception not being retained for async connect
* OFThread: Fix setting the name on the wrong thread
* OFMutableSet: Fix missing override for -[copy]
* configure: Fix posix_spawnp check
* Xcode project: Set the correct version for the bridge
* Better check for iOS
* tests: Fix testing the wrong OFKernelEventObserver
ObjFW 0.90 -> ObjFW 0.90.1, 2017-08-20
* OFData: Fix -[description]
* OFFileManager: Set errno to 0 before readdir()
* OFDate: Add -[localMinute]
* OFTarArchiveEntry: Fix prefix handling for ustar
* OFZIPArchive: Fix uncompressed + data descriptor
* OFArray: Fix MessagePack encoding
* of_asprintf: Don't require set up OFLocalization
* OFGZIPStream: Add missing documentation
* Fix a linker warning on OpenBSD/SPARC64
* Remove the OFFile b modes from MorphOS
(they were already removed for all other OSes)
ObjFW 0.8.1 -> ObjFW 0.90, 2017-08-01
+ New classes: OFFileManager, OFGZIPStream, OFTarArchive, OFTarArchiveEntry
OFHMAC, OFSandbox, OFHTTPCookie, OFHTTPCookieManager,
OFLocalization
+ New platforms: Nintendo 3DS, MorphOS
+ New lookup assembly for platforms: SPARC64/ELF, ARM64/ELF
+ New forwarding for: ARM64/ELF
+ New tools: objfw-new (to create boilerplate code)
+ New options: --disable-unicode-tables
* Required GCC version increased to 4.6
* OFDataArray was split into OFData and OFMutableData
* OFURL was split into OFURL and OFMutableURL
* Most properties are now nonatomic
(this changes from returned retained + autoreleased to +0 retained)
* Correct handling of encoding on Win32 console
(stream is read and written in UTF-8 and translated to UTF-16 on the fly)
* Runtime is now built as a separate library
+ More encodings for strings
* Reworked OFOptionsParser API
* Refactored OFKernelEventObserver
* Better randomization of HTTP header order
* Allow overriding all HTTP headers
* Definition of thread priorities changed
+ Key Value Coding
+ Exceptions in ObjC++
* OFHash was renamed to OFCryptoHash
+ PBKDF2
+ scrypt
+ Xcode project to build for iOS
+ String decomposition to NFD
* OFFile modes simplified ('b' removed)
ObjFW 0.8 -> ObjFW 0.8.1, 2015-10-04
* Adjust to __nullable / __nonnull being changed to _Nullable / _Nonnull in
Clang 3.7 (this fixes compilation with Clang 3.7)
* Blocks: Proper handling when called from a byref handler
* Fix compilation on Solaris
* Fix compilation for Wii, PSP and Nintendo DS
* OFProcess: Send SIGTERM on close instead of SIGKILL
* OFZIPArchive: Throw invalid format exception on failed seeks
* Make sure of_hash_seed is never initialized to 0
* Special cases for the Wii's weird network stack (fixes the tests)
* Better length checks for write / send calls
* Don't use -pedantic on platforms where it's broken by the system headers
* Documentation fixes
ObjFW 0.7.1 -> ObjFW 0.8, 2015-08-14
+ An insanely huge amount of new APIs
+ New classes: OFHTTPServer, OFINICategory, OFINIFile, OFInflate64Stream,
OFInflateStream, OFMapTable, OFRIPEMD160Hash, OFSHA224Hash, OFSHA256Hash,
OFSHA384Hash, OFSHA512Hash, OFSettings, OFStdIOStream, OFSystemInfo,
OFUDPSocket, OFZIPArchive, OFZIPArchiveEntry
+ New utils: ofzip, ofhash, ofhttp
+ Support for -[forwardingTargetForSelector:] on a lot of platforms
(see PLATFORMS.md)
* OFHTTPRequest: Split into OFHTTPRequest and OFHTTPClient
* Rename OFHTTPRequestReply to OFHTTPResponse
* OFDictionary now uses OFMapTable internally
+ Highly randomized, DoS-resistant hashtables (different seed per hashtable,
additionally rotated by a random number of bits)
* Reworked exceptions API that explicitly passes errno around
+ OFHTTPClient: Keep-alive and Basic Authorization support
+ Support for (and use of) ObjC generics, nullability and kindof
+ Fast path for resolving classes when using GCC (Clang doesn't need the fast
path, as it directly references classes)
* OFStreamObserver: Refactored and renamed to OFKernelEventObserver (as it is
no longer limited to streams)
+ Support for SjLj and SEH exceptions
+ Support for DOS/DJGPP, Nintendo Wii, Nintendo DS and PlayStation Portable
+ Support for bare metal (in other words: running without any OS; tested on
ARM)
+ Full support for ARM64 on iOS
+ Full MessagePack implementation (the new MessagePack version that supports
strings)
+ Backtraces for uncaught exceptions
+ Bridge to Cocoa now part of ObjFW
* Default depth limit for XML and JSON parser
+ Optional support for outputting JSON5 (default is JSON)
* 16 bit selector UIDs are now the default
* BOOL replaced with bool everywhere (except where required by the ABI)
* Fix for a nasty bug in -[replaceCharactersInRange:withString:]
* Fix for a nasty bug in atomic ops
* OFTLSKey replaced with +[OFThread threadDictionary]
* Documentation improvements (for example, imports should now be shown
correctly everywhere and many APIs have been documented in more detail)
+ Property introspection
* OFProcess: Use posix_spawnp if available
* OFProcess improvements for Win32
+ epoll support for OFKernelEventObserver
* Rewritten OFMD5Hash and OFSHA1Hash
* Reworked OFTLSSocket API (easier verification)
* Unicode support updated to Unicode 8.0
* OFURL: Proper escaping and unescaping
ObjFW 0.7 -> ObjFW 0.7.1, 2012-11-12
+ Support for Haiku
* Autorelease pools now work properly without __thread
* Incorrect framework version in Xcode project fixed
* Documentation fixes and improvements
* Blocks now only use 16 bits for the reference count in order to avoid
problems with newer Clang versions
* More use of OF_SENTINEL
ObjFW 0.6 -> ObjFW 0.7, 2012-10-27
Again, the differences are more than in any release before, thus listing them
all would be too much. The major differences are:
+ ObjFW now comes with its own runtime, which greatly increases performance
compared to the GNU runtime and is even faster than the Apple runtime
(using Clang >= 3.2 is recommended, but not necessary)
* Support for the GNU runtime has been dropped
+ New, much faster autorelease pool implementation (now inside the runtime)
+ Support for Automatic Reference Counting (requires Clang >= 3.2)
+ Forwarding has been implemented
+ Asynchronous stream handling
+ New classes: OFThreadPool, OFRecursiveMutex, OFSortedList, OFTimer, OFRunLoop
+ New protocols: OFLocking, OFTLSSocket
* Lots of API changes to make APIs more future-proof
+ Support for the new Objective-C literals
* OFHTTPRequest now implements HTTP/1.1
* OFObject's memory handling has been improved, leading to better performance
* Strings are allocated faster now
+ Support for JSON5
* All private methods use the prefix OF_ now instead of _, making it possible
to use the _ prefix in applications
* Most ObjC compiler feature checks are not part of configure anymore, making
it possible to use the same installation with different compilers
ObjFW 0.5.4 -> ObjFW 0.6, 2012-02-27
The differences between 0.5.4 and 0.6 are too big to list them all. However,
the major new features are:
* OFString, OFArray, OFDictionary, OFSet and OFCountedSet are now class
clusters
+ Serialization and deserialization of objects into/from XML and JSON
+ New class OFIntrospection for introspecting classes
+ New class OFProcess for working with and controlling child processes
* Lots of OFXMLParser and OFXMLElement improvements
+ OFHTTPRequests can have a delegate now for status updates and processing
data as soon as it arrives
+ There are several backends for OFStreamObserver now, including kqueue, poll
and select
+ SOCKS5 support for OFTCPSockets (client only)
* Several API changes
ObjFW 0.5.3 -> ObjFW 0.5.4, 2011-08-30
* The blocks runtime is now working correctly
* Documentation fixes
* -framework works with objfw-compile now
+ Support for QNX
* Various small fixes
ObjFW 0.5.2 -> ObjFW 0.5.3, 2011-07-01
* Lots of bugfixes, see Git log for details
ObjFW 0.5.1 -> ObjFW 0.5.2, 2011-04-25
* Fix double-retain in OFList
* Don't ignore the timeout in OFStreamObserver when using select()
* Do -[OFURL copy] in a try block to prevent a leak when an exception occurs
* Fix too big buffer in -[OFMutableString _applyTable:withSize:]
* Call madvise() on the correct length variable so it covers the whole string
* Fix a warning when sizeof(size_t) < sizeof(long long)
* Skip possible BOMs when appending strings
ObjFW 0.5 -> ObjFW 0.5.1, 2011-04-21
* Work around a wrong warning produced by Apple GCC 4.0.1 which would cause
the build to fail due to -Werror
* Call objc_thread_{add,remove} when using the GNU runtime to make sure the
runtime knows about our thread
* Detach a thread before restarting if it was never joined
* Release the old return value when restarting a thread
ObjFW 0.4-alpha1 -> 0.5, 2011-04-09
+ %@ is now allowed in format strings
+ Added of_log for easy logging
* Exceptions have one header per exception now
* Lots of exception improvements
* Huge improvements in XML handling
* Improvements in socket handling, including improved API
* OFStreamObserver is now thread-safe and stops the current observe call when
the set of streams to observe is modified
+ New class OFURL
+ New class OFHTTPRequest
+ New class OFCondition
* Improvements in objfw-compile
+ Blocks can be used together with Cocoa now
+ When linking ObjFW and Cocoa, OFAutoreleasePools are used by both now
+ Support for Base64
+ Use a real Xcode project instead of just calling make
+ Add Haiku to the list of supported platforms
* Lots of small bugfixes and countless small changes. Read the commits!
ObjFW 0.3.1 -> 0.4-alpha1, 2011-01-03
* ObjFW is now available under the terms of the QPL, GPLv2 and GPLv3
+ Support for blocks was added, including a blocks runtime
+ Added support for the new GNU runtime, introduced in GCC 4.6
* Objects returned from collections are no longer retained and autoreleased
+ Added new classes OFXMLParser, OFXMLElement, OFXMLAttribute and
OFXMLElementBuilder
+ Added new class OFStreamObserver to observe streams
+ Added new class OFDate for storing dates
+ Many new methods in almost all classes
* OFAutoreleasePool was optimized
* Handling of ASCII strings was optimized
* OFSocket was renamed to OFStreamSocket
* OFConstString was renamed to OFConstantString
* objfw-compile now has a new syntax
+ objfw-compile can now compile libraries and plugins
* Many small changes and new features that would be too much to list here
The diff between 0.3.1 and 0.4-alpha1 has almost 24000 lines!
ObjFW 0.3 -> 0.3.1, 2010-06-19
* Fix a typo in OFMutableDictionary that prevented termination in case
the last bucket is already used when the dictionary is resized
* The mutations pointer is now correctly initialized in enumerators for
immutable collections
* The objc_sync test was still using the old threads API and was
updated to use the new one now
* PLATFORMS has been updated to be more specific
ObjFW 0.2.1 -> 0.3, 2010-05-09
+ Many new methods were added to different classes
+ A huge amount of methods was added to OFStream, allowing easy binary
stream handling and even mixing string-based and binary operations
+ An optional write buffer was added to OFStream
+ OFSeekableStream was added for streams that allow seeking, for example
OFFiles
* OFNumber was completely reworked and got many new features now
* Large parts of OFDictionary were rewritten for better readability, better
memory usage and to fix a bug with removing objects
* OFThread has been greatly improved
* Many small optimizations
* Many documentation improvements
* Method replacing was reworked and the methods renamed
+ Tests for OFStream were added
* A bug with building ObjFW as a Universal Binary Framework was fixed
+ Support for ObjFW-RT, the ObjFW Objective C runtime, was added
* Sockets are now properly closed before an exception is thrown
* Error handling with sockets was improved
* OFFile now uses open(), read() and write(), thus allowing -[readLine] to be
used on of_stdin and fixing many other annoyances
* A few misc methods were renamed
+ OFApplication was added
* All tests and the table generator are now using OFApplication
+ It is now possible to get the remote address of an OFTCPSocket
+ OFString can now build paths in the OS-native format
+ It is now possible to create a string with the contents of a file
+ Many new file operations were added to OFFile
* The existing file operations in OFFile were improved
* Almost all functions that returned self before now return void
+ OFHash was added as a superclass for OFMD5Hash and OFSHA1Hash and OFHashes
renamed to OFHash
+ objfw-compile was added for easy compilation of ObjFW projects, which
includes dependency checking for headers etc.
* The instance variable naming convention was changed so that properties work
+ Properties were added to the interfaces and are used if they are supported
by the compiler
+ The library version is now included in the resulting dylib and libobjc is
reexported now. Additionally, objfw-config offers --reexport now to produce
libraries that link against ObjFW and reexport it
ObjFW 0.2 -> 0.2.1, 2010-03-14
* Fix for OFNumbers not doing calculations
* Improved -[hash] for OFNumbers with floats and doubles
+ Tests for OFNumber
* Small optimization for OFArray's -[componentsJoinedByString:]
* Documentation improvements
* Updated copyright
ObjFW 0.1.2 -> 0.2, 2010-02-01
+ Support for ObjC 2 Fast Enumerations on every platform which has
compiler support for fast enumerations
+ Support for ObjC 2 properties on every platform with compiler support
+ Fast Enumeration through arrays and dictionaries
* OFIterator has been removed
+ OFEnumerator was added to replace OFIterator, which is more general
and works with arrays and dictionaries
+ Portable implementation for atomic operations
+ Portable implementation for spinlocks. They use atomic operations if
available, if not they fall back to pthread spinlocks. If both are
unavailable, mutexes are used as a last fallback
* -[retain] and -[release] are now atomic. If no atomic operations are
available, spinlocks are used (which can fall back to mutexes, see
above)
* -[readLine] now handles \r\n without having the \r included in the
returned line
+ OFThread now has -[tryLock]
* Mutation methods have been removed from immutable interfaces, thus
already giving an error at compilation instead of at runtime
* Dependencies between headers have been reduced, leading to faster
compile times
* The interfaces of OFSocket and OFStream were cleaned up and some
methods were moved to OFTCPSocket, as they make sense only there
* File methods unavailable on Windows don't throw an exception at
runtime anymore, but instead are not even in the interface on
Windows. This way, it is a compile time error instead of a runtime
error
ObjFW 0.1.1 -> 0.1.2, 2010-01-15
* Fix a bug in OFMutableArray's -[removeObject:] and
-[removeObjectIdenticalTo:] that could lead to not removing all
occurrences of the object from the array and to out of bounds reads
* Change the URL in the framework plist to the homepage
ObjFW 0.1 -> 0.1.1, 2010-01-04
* Fix a missing out of range check for -[removeNItems:atIndex:] that
allowed the programmer to specify too big ranges so it would crash
instead of throwing an exception
* Fix missing calls to -[retain] and -[autorelease] when getting
objects from an OFArray or OFDictionary
* Safer and more fault-tolerant way to remove objects from an
OFMutableArray
* Calling +[dealloc] throws an exception now. If someone really calls
[SomeClass dealloc], this should be punished and not ignored, as
this is a serious programmer error
* -[readLineWithEncoding:] is more fault-tolerant now and does not
lose data when it stumbles upon invalid encoding. Instead, it allows
recalling with the correct encoding now
ObjFW 0.1, 2009-12-24
+ Initial release
objfw-1.3/Doxyfile 100644 001750 001750 00000003040 14767513633 013241 0 ustar 00js js 000000 000000 PROJECT_NAME = "ObjFW"
OUTPUT_DIRECTORY = docs/
INPUT = src src/exceptions src/runtime src/test src/bridge src/hid
FILE_PATTERNS = *.h *.m
HTML_OUTPUT = .
HAVE_DOT = NO
GENERATE_LATEX = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = YES
TYPEDEF_HIDES_STRUCT = YES
PREDEFINED = _Nonnull= \
_Nullable= \
DOXYGEN \
OF_BOXABLE= \
OF_CONSUMED= \
OF_DESIGNATED_INITIALIZER= \
OF_DEPRECATED(...)= \
OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES \
OF_FILE_MANAGER_SUPPORTS_LINKS \
OF_FILE_MANAGER_SUPPORTS_OWNER \
OF_FILE_MANAGER_SUPPORTS_PERMISSIONS \
OF_FILE_MANAGER_SUPPORTS_SYMLINKS \
OF_GENERIC(...)= \
OF_HAVE_APPLETALK \
OF_HAVE_BLOCKS \
OF_HAVE_FILES \
OF_HAVE_IPV6 \
OF_HAVE_IPX \
OF_HAVE_MODULES \
OF_HAVE_SANDBOX \
OF_HAVE_SOCKETS \
OF_HAVE_THREADS \
OF_HAVE_UNICODE_TABLES \
OF_KINDOF(...)= \
OF_NO_RETURN= \
OF_NO_RETURN_FUNC= \
OF_NULLABLE_PROPERTY(...)= \
OF_NULL_RESETTABLE_PROPERTY(...)= \
OF_REQUIRES_SUPER= \
OF_RETURNS_INNER_POINTER= \
OF_RETURNS_NOT_RETAINED= \
OF_RETURNS_RETAINED= \
OF_ROOT_CLASS= \
OF_SENTINEL= \
OF_WARN_UNUSED_RESULT= \
OF_WEAK_UNAVAILABLE= \
SIGHUP \
SIGUSR1 \
SIGUSR2
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
IGNORE_PREFIX = OF OF_ OH OT OT_
EXTRACT_STATIC = yes
objfw-1.3/Makefile 100644 001750 001750 00000002553 14767513633 013203 0 ustar 00js js 000000 000000 include extra.mk
SUBDIRS = src utils tests
DISTCLEAN = Info.plist \
aclocal.m4 \
autom4te.cache \
buildsys.mk \
config.h \
config.log \
config.status \
extra.mk
include buildsys.mk
.PHONY: check docs release
utils tests: src
check: tests
${MAKE} -C tests -s run
docs:
rm -fr docs
doxygen >/dev/null
release: docs
echo "Generating tarball for version ${PACKAGE_VERSION}..."
rm -fr objfw-${PACKAGE_VERSION} objfw-${PACKAGE_VERSION}.tar \
objfw-${PACKAGE_VERSION}.tar.gz
fossil tarball --name objfw-${PACKAGE_VERSION} current - \
--exclude '.fossil-settings*,.github*' | ofarc -ttgz -xq -
cp configure config.h.in objfw-${PACKAGE_VERSION}/
ofarc -cq objfw-${PACKAGE_VERSION}.tar objfw-${PACKAGE_VERSION}
rm -fr objfw-${PACKAGE_VERSION}
gzip -9 objfw-${PACKAGE_VERSION}.tar
rm -f objfw-${PACKAGE_VERSION}.tar
gpg -b objfw-${PACKAGE_VERSION}.tar.gz || true
rm -fr objfw-docs-${PACKAGE_VERSION} objfw-docs-${PACKAGE_VERSION}.tar \
objfw-docs-${PACKAGE_VERSION}.tar.gz
mv docs objfw-docs-${PACKAGE_VERSION}
echo "Generating docs tarball for version ${PACKAGE_VERSION}..."
ofarc -cq objfw-docs-${PACKAGE_VERSION}.tar \
objfw-docs-${PACKAGE_VERSION}
rm -fr objfw-docs-${PACKAGE_VERSION}
gzip -9 objfw-docs-${PACKAGE_VERSION}.tar
rm -f objfw-docs-${PACKAGE_VERSION}.tar
gpg -b objfw-docs-${PACKAGE_VERSION}.tar.gz || true
objfw-1.3/PLATFORMS.md 100644 001750 001750 00000013676 14767513633 013444 0 ustar 00js js 000000 000000 Platforms
=========
ObjFW is known to work on the following platforms, but should run on many
others as well.
AmigaOS
-------
* OS Versions: 3.1, 4.1 Final Edition Update 1
* Architectures: m68k, PowerPC
* Compilers: GCC 6.4.1b (amiga-gcc), GCC 8.3.0 (adtools)
* Runtimes: ObjFW
Android
-------
* OS Versions: 4.0.4, 4.1.2, 6.0.1
* Architectures: ARMv6, ARMv7, ARM64
* Compilers: Clang 3.3, Clang 3.8.0
* Runtimes: ObjFW
Bare metal ARM Cortex-M4
------------------------
* Architectures: ARMv7E-M
* Compilers: Clang 3.5
* Runtimes: ObjFW
* Notes: Bootloader, libc (newlib) and possibly external RAM required
DOS
---
* OS Versions: Windows XP DOS Emulation, DOSBox, MS-DOS 6.0, FreeDOS 1.2
* Architectures: x86
* Compilers: DJGPP GCC 4.7.3 (djdev204)
* Runtimes: ObjFW
DragonFlyBSD
------------
* OS Versions: 3.0, 3.3-DEVELOPMENT
* Architectures: AMD64, x86
* Compilers: GCC 4.4.7
* Runtimes: ObjFW
FreeBSD
-------
* OS Versions: 9.1-rc3, 10.0
* Architectures: AMD64
* Compilers: Clang 3.1, Clang 3.3
* Runtimes: ObjFW
GNU/Hurd
--------
* OS Versions: 0.9
* Architectures: i686
* Compilers: Clang 14.0.6
* Runtimes: ObjFW
Haiku
-----
* OS version: r1-alpha4
* Architectures: x86
* Compilers: Clang 3.2, GCC 4.6.3
* Runtimes: ObjFW
HP-UX
-----
* OS versions: 11i v1, 11i v3
* Architectures: Itanium, PA-RISC 2.0
* Compilers: GCC 4.7.2, GCC 7.5.0
* Runtimes: ObjFW
* Notes: Exception handling on Itanium in 32 bit mode is broken, you need to
use 64 bit mode by passing `OBJC="gcc -mlp64"` to `configure`.
iOS
---
* Architectures: ARMv7, ARM64
* Compilers: Clang
* Runtimes: Apple
Linux
-----
* Architectures: Alpha, AMD64, ARMv5, ARMv6, ARMv7, ARM64, Itanium,
LoongArch 64, m68k, MIPS (O32), MIPS64 (N64), RISC-V 64,
PA-RISC, PowerPC, PowerPC 64, S390x, SuperH-4, x86
* Compilers: Clang 3.0-18.1.1, GCC 4.6-14.1.1
* C libraries: glibc, musl
* Runtimes: ObjFW
macOS
-----
* OS Versions: 10.5, 10.7-10.15, Darling
* Architectures: AMD64, PowerPC, PowerPC64, x86
* Compilers: Clang 3.1-10.0, Apple GCC 4.0.1 & 4.2.1
* Runtimes: Apple, ObjFW
MiNT
----
* OS Versions: FreeMiNT 1.19
* Architectures: m68k
* Runtimes: ObjFW
* Compilers: GCC 4.6.4 (MiNT 20130415)
* Limitations: No shared libraries, no threads
MorphOS
-------
* OS Versions: 3.14
* Architectures: PowerPC
* Compilers: GCC 9.3.0
* Runtimes: ObjFW
NetBSD
------
* OS Versions: 5.1-9.0
* Architectures: AMD64, ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC,
SPARC, SPARC64, x86
* Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3 & 7.4.0
* Runtimes: ObjFW
Nintendo 3DS
------------
* OS Versions: 9.2.0-20E, 10.5.0-30E / Homebrew Channel 1.1.0
* Architectures: ARM (EABI)
* Compilers: GCC 5.3.0 (devkitARM release 45)
* Runtimes: ObjFW
* Limitations: No threads
Nintendo DS
-----------
* Architectures: ARM (EABI)
* Compilers: GCC 4.8.2 (devkitARM release 42)
* Runtimes: ObjFW
* Limitations: No threads, no sockets
* Notes: File support requires an argv-compatible launcher (such as HBMenu)
Nintendo Switch
---------------
* OS Versions: yuzu 1093
* Architectures: AArch64
* Compilers: GCC 12.1.0 (devkitA64 release 19)
* Runtimes: ObjFW
* Limitations: No sockets, no shared libraries, not tested on real hardware
OpenBSD
-------
* OS Versions: 5.2-6.7
* Architectures: AMD64, MIPS64, PA-RISC, PowerPC, SPARC64
* Compilers: GCC 6.3.0, Clang 4.0
* Runtimes: ObjFW
PlayStation Portable
--------------------
* OS Versions: 5.00 M33-4
* Architectures: MIPS (EABI)
* Compiler: GCC 4.6.2 (devkitPSP release 16)
* Runtimes: ObjFW
* Limitations: No threads, no sockets
QNX
---
* OS Versions: 6.5.0
* Architectures: x86
* Compilers: GCC 4.6.1
* Runtimes: ObjFW
Solaris
-------
* OS Versions: OpenIndiana 2015.03, OpenIndiana 2023.04, Oracle Solaris 11.4
* Architectures: AMD64, SPARC64, x86
* Compilers: Clang 3.4.2, Clang 11.0.0, Clang 13.0.1, GCC 4.8.3, GCC 10.4.0
* Runtimes: ObjFW
Wii
---
* OS Versions: 4.3E / Homebrew Channel 1.1.0
* Architectures: PowerPC
* Compilers: GCC 4.6.3 (devkitPPC release 26)
* Runtimes: ObjFW
* Limitations: No threads
Wii U
-----
* OS Versions: Cemu 12.26.2f
* Architectures: PowerPC
* Compilers: gcc version 12.1.0 (devkitPPC release 41)
* Runtimes: ObjFW
* Limitations: No files, no threads, no sockets, no shared libraries, not
tested on real hardware
Windows
-------
* OS Versions: 98 SE, NT 4.0, XP, 7, 8, 8.1, 10, 11, Wine
* Architectures: AArch64, AMD64, x86
* Compilers: GCC 5.3.0 & 6.2.0 from msys2 (AMD64 & x86),
Clang 3.9.0 from msys2 (x86),
Clang 10.0 from msys2 (AMD64 & x86),
Clang 14.0.4 from msys2 (AArch64)
* Runtimes: ObjFW
Others
------
Basically, it should run on any POSIX system to which GCC >= 4.6 or a recent
Clang version has been ported. If not, please send an e-mail with a bug report.
If you successfully ran ObjFW on a platform not listed here, please send an
e-mail to js@nil.im so it can be added here!
If you have a platform on which ObjFW does not work, please contact me as well!
Forwarding
==========
As forwarding needs hand-written assembly for each combination of CPU
architecture, executable format and calling convention, it is only available
for the following platforms (except resolveClassMethod: and
resolveInstanceMethod:, which are always available):
* AMD64 (SysV/ELF, Apple/Mach-O, Mach-O, Win64/PE)
* ARM (EABI/ELF, Apple/Mach-O)
* ARM64 (ARM64/ELF, Apple/Mach-O, Win64/PE)
* LoongArch 64 (ELF)
* MIPS (O32/ELF, EABI/ELF)
* MIPS64 (N64/ELF)
* PowerPC (SysV/ELF, EABI/ELF, Apple/Mach-O)
* PowerPC 64 (SysV/ELF, SysV/ELF v2)
* RISC-V 64 (ELF)
* SPARC (SysV/ELF)
* SPARC64 (SysV/ELF)
* x86 (SysV/ELF, Apple/Mach-O, Win32/PE)
Apple/Mach-O means both, the Apple ABI and runtime, while Mach-O means the
ObjFW runtime on Mach-O.
objfw-1.3/README.md 100644 001750 001750 00000001147 14767513633 013020 0 ustar 00js js 000000 000000 ObjFW is a portable, lightweight framework for the Objective-C language. It
enables you to write an application in Objective-C that will run on any
platform supported by ObjFW without having to worry about differences between
operating systems or various frameworks you would otherwise need if you want to
be portable.
It supports all modern Objective-C features when using Clang, but is also
compatible with GCC ≥ 4.6 to allow maximum portability.
ObjFW is intentionally incompatible with Foundation.
You can read more about ObjFW on its [homepage](https://objfw.nil.im),
including how to install and use it.
objfw-1.3/autogen.sh 100755 001750 001750 00000000354 14767513633 013541 0 ustar 00js js 000000 000000 #!/bin/sh
set -e
# Set a version for OpenBSD
if test x"$(uname -s)" = x"OpenBSD"; then
: ${AUTOCONF_VERSION:=2.72}
: ${AUTOMAKE_VERSION:=1.16}
export AUTOCONF_VERSION AUTOMAKE_VERSION
fi
aclocal -I build-aux/m4
autoconf
autoheader
objfw-1.3/build-aux 040755 001750 001750 00000000000 14767513633 013354 5 ustar 00js js 000000 000000 objfw-1.3/build-aux/config.guess 100644 001750 001750 00000142676 14767513633 015765 0 ustar 00js js 000000 000000 #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2023 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2023-08-22'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
#
# Please send patches to .
# The "shellcheck disable" line above the timestamp inhibits complaints
# about features and limitations of the classic Bourne shell that were
# superseded or lifted in POSIX. However, this script identifies a wide
# variety of pre-POSIX systems that do not have POSIX shells at all, and
# even some reasonably current systems (Solaris 10 as case-in-point) still
# have a pre-POSIX /bin/sh.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system '$me' is run on.
Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try '$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
# Just in case it came from the environment.
GUESS=
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
# use 'HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
tmp=
# shellcheck disable=SC2172
trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
set_cc_for_build() {
# prevent multiple calls if $tmp is already set
test "$tmp" && return 0
: "${TMPDIR=/tmp}"
# shellcheck disable=SC2039,SC3028
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
dummy=$tmp/dummy
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
,,) echo "int x;" > "$dummy.c"
for driver in cc gcc c89 c99 ; do
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD=$driver
break
fi
done
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac
}
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if test -f /.attbin/uname ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case $UNAME_SYSTEM in
Linux|GNU|GNU/*)
LIBC=unknown
set_cc_for_build
cat <<-EOF > "$dummy.c"
#if defined(__ANDROID__)
LIBC=android
#else
#include
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#elif defined(__GLIBC__)
LIBC=gnu
#else
#include
/* First heuristic to detect musl libc. */
#ifdef __DEFINED_va_list
LIBC=musl
#endif
#endif
#endif
EOF
cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
eval "$cc_set_libc"
# Second heuristic to detect musl libc.
if [ "$LIBC" = unknown ] &&
command -v ldd >/dev/null &&
ldd --version 2>&1 | grep -q ^musl; then
LIBC=musl
fi
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
if [ "$LIBC" = unknown ]; then
LIBC=gnu
fi
;;
esac
# Note: order is significant - the case branches are not exclusive.
case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
/usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
echo unknown)`
case $UNAME_MACHINE_ARCH in
aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
machine=${arch}${endian}-unknown
;;
*) machine=$UNAME_MACHINE_ARCH-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently (or will in the future) and ABI.
case $UNAME_MACHINE_ARCH in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# Determine ABI tags.
case $UNAME_MACHINE_ARCH in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case $UNAME_VERSION in
Debian*)
release='-gnu'
;;
*)
release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
GUESS=$machine-${os}${release}${abi-}
;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
;;
*:SecBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
;;
*:MidnightBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
;;
*:ekkoBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
;;
*:SolidBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
;;
*:OS108:*:*)
GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
;;
macppc:MirBSD:*:*)
GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
;;
*:MirBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
;;
*:Sortix:*:*)
GUESS=$UNAME_MACHINE-unknown-sortix
;;
*:Twizzler:*:*)
GUESS=$UNAME_MACHINE-unknown-twizzler
;;
*:Redox:*:*)
GUESS=$UNAME_MACHINE-unknown-redox
;;
mips:OSF1:*.*)
GUESS=mips-dec-osf1
;;
alpha:OSF1:*:*)
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
trap '' 0
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case $ALPHA_CPU_TYPE in
"EV4 (21064)")
UNAME_MACHINE=alpha ;;
"EV4.5 (21064)")
UNAME_MACHINE=alpha ;;
"LCA4 (21066/21068)")
UNAME_MACHINE=alpha ;;
"EV5 (21164)")
UNAME_MACHINE=alphaev5 ;;
"EV5.6 (21164A)")
UNAME_MACHINE=alphaev56 ;;
"EV5.6 (21164PC)")
UNAME_MACHINE=alphapca56 ;;
"EV5.7 (21164PC)")
UNAME_MACHINE=alphapca57 ;;
"EV6 (21264)")
UNAME_MACHINE=alphaev6 ;;
"EV6.7 (21264A)")
UNAME_MACHINE=alphaev67 ;;
"EV6.8CB (21264C)")
UNAME_MACHINE=alphaev68 ;;
"EV6.8AL (21264B)")
UNAME_MACHINE=alphaev68 ;;
"EV6.8CX (21264D)")
UNAME_MACHINE=alphaev68 ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE=alphaev69 ;;
"EV7 (21364)")
UNAME_MACHINE=alphaev7 ;;
"EV7.9 (21364A)")
UNAME_MACHINE=alphaev79 ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
;;
Amiga*:UNIX_System_V:4.0:*)
GUESS=m68k-unknown-sysv4
;;
*:[Aa]miga[Oo][Ss]:*:*)
GUESS=$UNAME_MACHINE-unknown-amigaos
;;
*:[Mm]orph[Oo][Ss]:*:*)
GUESS=$UNAME_MACHINE-unknown-morphos
;;
*:OS/390:*:*)
GUESS=i370-ibm-openedition
;;
*:z/VM:*:*)
GUESS=s390-ibm-zvmoe
;;
*:OS400:*:*)
GUESS=powerpc-ibm-os400
;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
GUESS=arm-acorn-riscix$UNAME_RELEASE
;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
GUESS=arm-unknown-riscos
;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
GUESS=hppa1.1-hitachi-hiuxmpp
;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
case `(/bin/universe) 2>/dev/null` in
att) GUESS=pyramid-pyramid-sysv3 ;;
*) GUESS=pyramid-pyramid-bsd ;;
esac
;;
NILE*:*:*:dcosx)
GUESS=pyramid-pyramid-svr4
;;
DRS?6000:unix:4.0:6*)
GUESS=sparc-icl-nx6
;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) GUESS=sparc-icl-nx7 ;;
esac
;;
s390x:SunOS:*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
;;
sun4H:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=sparc-hal-solaris2$SUN_REL
;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=sparc-sun-solaris2$SUN_REL
;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
GUESS=i386-pc-auroraux$UNAME_RELEASE
;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
set_cc_for_build
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH=x86_64
fi
fi
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=sparc-sun-solaris3$SUN_REL
;;
sun4*:SunOS:*:*)
case `/usr/bin/arch -k` in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like '4.1.3-JL'.
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
GUESS=sparc-sun-sunos$SUN_REL
;;
sun3*:SunOS:*:*)
GUESS=m68k-sun-sunos$UNAME_RELEASE
;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
case `/bin/arch` in
sun3)
GUESS=m68k-sun-sunos$UNAME_RELEASE
;;
sun4)
GUESS=sparc-sun-sunos$UNAME_RELEASE
;;
esac
;;
aushp:SunOS:*:*)
GUESS=sparc-auspex-sunos$UNAME_RELEASE
;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
GUESS=m68k-atari-mint$UNAME_RELEASE
;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
GUESS=m68k-atari-mint$UNAME_RELEASE
;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
GUESS=m68k-atari-mint$UNAME_RELEASE
;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
GUESS=m68k-milan-mint$UNAME_RELEASE
;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
GUESS=m68k-hades-mint$UNAME_RELEASE
;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
GUESS=m68k-unknown-mint$UNAME_RELEASE
;;
m68k:machten:*:*)
GUESS=m68k-apple-machten$UNAME_RELEASE
;;
powerpc:machten:*:*)
GUESS=powerpc-apple-machten$UNAME_RELEASE
;;
RISC*:Mach:*:*)
GUESS=mips-dec-mach_bsd4.3
;;
RISC*:ULTRIX:*:*)
GUESS=mips-dec-ultrix$UNAME_RELEASE
;;
VAX*:ULTRIX*:*:*)
GUESS=vax-dec-ultrix$UNAME_RELEASE
;;
2020:CLIX:*:* | 2430:CLIX:*:*)
GUESS=clipper-intergraph-clix$UNAME_RELEASE
;;
mips:*:*:UMIPS | mips:*:*:RISCos)
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
{ echo "$SYSTEM_NAME"; exit; }
GUESS=mips-mips-riscos$UNAME_RELEASE
;;
Motorola:PowerMAX_OS:*:*)
GUESS=powerpc-motorola-powermax
;;
Motorola:*:4.3:PL8-*)
GUESS=powerpc-harris-powermax
;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
GUESS=powerpc-harris-powermax
;;
Night_Hawk:Power_UNIX:*:*)
GUESS=powerpc-harris-powerunix
;;
m88k:CX/UX:7*:*)
GUESS=m88k-harris-cxux7
;;
m88k:*:4*:R4*)
GUESS=m88k-motorola-sysv4
;;
m88k:*:3*:R3*)
GUESS=m88k-motorola-sysv3
;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then
if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
test "$TARGET_BINARY_INTERFACE"x = x
then
GUESS=m88k-dg-dgux$UNAME_RELEASE
else
GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
fi
else
GUESS=i586-dg-dgux$UNAME_RELEASE
fi
;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
GUESS=m88k-dolphin-sysv3
;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
GUESS=m88k-motorola-sysv3
;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
GUESS=m88k-tektronix-sysv3
;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
GUESS=m68k-tektronix-bsd
;;
*:IRIX*:*:*)
IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
GUESS=mips-sgi-irix$IRIX_REL
;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id
;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
GUESS=i386-ibm-aix
;;
ia64:AIX:*:*)
if test -x /usr/bin/oslevel ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
then
GUESS=$SYSTEM_NAME
else
GUESS=rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
GUESS=rs6000-ibm-aix3.2.4
else
GUESS=rs6000-ibm-aix3.2
fi
;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if test -x /usr/bin/lslpp ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
GUESS=$IBM_ARCH-ibm-aix$IBM_REV
;;
*:AIX:*:*)
GUESS=rs6000-ibm-aix
;;
ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
GUESS=romp-ibm-bsd4.4
;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to
;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
GUESS=rs6000-bull-bosx
;;
DPX/2?00:B.O.S.:*:*)
GUESS=m68k-bull-sysv3
;;
9000/[34]??:4.3bsd:1.*:*)
GUESS=m68k-hp-bsd
;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
GUESS=m68k-hp-bsd4.4
;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
case $UNAME_MACHINE in
9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if test -x /usr/bin/getconf; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case $sc_cpu_version in
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case $sc_kernel_bits in
32) HP_ARCH=hppa2.0n ;;
64) HP_ARCH=hppa2.0w ;;
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
if test "$HP_ARCH" = ""; then
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if test "$HP_ARCH" = hppa2.0w
then
set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
# $ CC_FOR_BUILD=cc ./config.guess
# => hppa2.0w-hp-hpux11.23
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
grep -q __LP64__
then
HP_ARCH=hppa2.0w
else
HP_ARCH=hppa64
fi
fi
GUESS=$HP_ARCH-hp-hpux$HPUX_REV
;;
ia64:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
GUESS=ia64-hp-hpux$HPUX_REV
;;
3050*:HI-UX:*:*)
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
GUESS=unknown-hitachi-hiuxwe2
;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
GUESS=hppa1.1-hp-bsd
;;
9000/8??:4.3bsd:*:*)
GUESS=hppa1.0-hp-bsd
;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
GUESS=hppa1.0-hp-mpeix
;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
GUESS=hppa1.1-hp-osf
;;
hp8??:OSF1:*:*)
GUESS=hppa1.0-hp-osf
;;
i*86:OSF1:*:*)
if test -x /usr/sbin/sysversion ; then
GUESS=$UNAME_MACHINE-unknown-osf1mk
else
GUESS=$UNAME_MACHINE-unknown-osf1
fi
;;
parisc*:Lites*:*:*)
GUESS=hppa1.1-hp-lites
;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
GUESS=c1-convex-bsd
;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
GUESS=c34-convex-bsd
;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
GUESS=c38-convex-bsd
;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
GUESS=c4-convex-bsd
;;
CRAY*Y-MP:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=ymp-cray-unicos$CRAY_REL
;;
CRAY*[A-Z]90:*:*:*)
echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=t90-cray-unicos$CRAY_REL
;;
CRAY*T3E:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=alphaev5-cray-unicosmk$CRAY_REL
;;
CRAY*SV1:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=sv1-cray-unicos$CRAY_REL
;;
*:UNICOS/mp:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=craynv-cray-unicosmp$CRAY_REL
;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
;;
sparc*:BSD/OS:*:*)
GUESS=sparc-unknown-bsdi$UNAME_RELEASE
;;
*:BSD/OS:*:*)
GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
;;
arm:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p`
set_cc_for_build
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
else
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
fi
;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p`
case $UNAME_PROCESSOR in
amd64)
UNAME_PROCESSOR=x86_64 ;;
i386)
UNAME_PROCESSOR=i586 ;;
esac
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
;;
i*:CYGWIN*:*)
GUESS=$UNAME_MACHINE-pc-cygwin
;;
*:MINGW64*:*)
GUESS=$UNAME_MACHINE-pc-mingw64
;;
*:MINGW*:*)
GUESS=$UNAME_MACHINE-pc-mingw32
;;
*:MSYS*:*)
GUESS=$UNAME_MACHINE-pc-msys
;;
i*:PW*:*)
GUESS=$UNAME_MACHINE-pc-pw32
;;
*:SerenityOS:*:*)
GUESS=$UNAME_MACHINE-pc-serenity
;;
*:Interix*:*)
case $UNAME_MACHINE in
x86)
GUESS=i586-pc-interix$UNAME_RELEASE
;;
authenticamd | genuineintel | EM64T)
GUESS=x86_64-unknown-interix$UNAME_RELEASE
;;
IA64)
GUESS=ia64-unknown-interix$UNAME_RELEASE
;;
esac ;;
i*:UWIN*:*)
GUESS=$UNAME_MACHINE-pc-uwin
;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
GUESS=x86_64-pc-cygwin
;;
prep*:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=powerpcle-unknown-solaris2$SUN_REL
;;
*:GNU:*:*)
# the GNU system
GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
;;
x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
;;
*:[Mm]anagarm:*:*)
GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
;;
*:Minix:*:*)
GUESS=$UNAME_MACHINE-unknown-minix
;;
aarch64:Linux:*:*)
set_cc_for_build
CPU=$UNAME_MACHINE
LIBCABI=$LIBC
if test "$CC_FOR_BUILD" != no_compiler_found; then
ABI=64
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __ARM_EABI__
#ifdef __ARM_PCS_VFP
ABI=eabihf
#else
ABI=eabi
#endif
#endif
EOF
cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
eval "$cc_set_abi"
case $ABI in
eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
esac
fi
GUESS=$CPU-unknown-linux-$LIBCABI
;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
arm*:Linux:*:*)
set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
else
GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
fi
fi
;;
avr32*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
cris:Linux:*:*)
GUESS=$UNAME_MACHINE-axis-linux-$LIBC
;;
crisv32:Linux:*:*)
GUESS=$UNAME_MACHINE-axis-linux-$LIBC
;;
e2k:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
frv:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
hexagon:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
i*86:Linux:*:*)
GUESS=$UNAME_MACHINE-pc-linux-$LIBC
;;
ia64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
k1om:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:cos:*:*)
GUESS=$UNAME_MACHINE-unknown-cos
;;
kvx:mbr:*:*)
GUESS=$UNAME_MACHINE-unknown-mbr
;;
loongarch32:Linux:*:* | loongarch64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m32r*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m68*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
mips:Linux:*:* | mips64:Linux:*:*)
set_cc_for_build
IS_GLIBC=0
test x"${LIBC}" = xgnu && IS_GLIBC=1
sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef mips
#undef mipsel
#undef mips64
#undef mips64el
#if ${IS_GLIBC} && defined(_ABI64)
LIBCABI=gnuabi64
#else
#if ${IS_GLIBC} && defined(_ABIN32)
LIBCABI=gnuabin32
#else
LIBCABI=${LIBC}
#endif
#endif
#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
CPU=mipsisa64r6
#else
#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
CPU=mipsisa32r6
#else
#if defined(__mips64)
CPU=mips64
#else
CPU=mips
#endif
#endif
#endif
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
MIPS_ENDIAN=el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
MIPS_ENDIAN=
#else
MIPS_ENDIAN=
#endif
#endif
EOF
cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
eval "$cc_set_vars"
test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
;;
mips64el:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
openrisc*:Linux:*:*)
GUESS=or1k-unknown-linux-$LIBC
;;
or32:Linux:*:* | or1k*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
padre:Linux:*:*)
GUESS=sparc-unknown-linux-$LIBC
;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
GUESS=hppa64-unknown-linux-$LIBC
;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
*) GUESS=hppa-unknown-linux-$LIBC ;;
esac
;;
ppc64:Linux:*:*)
GUESS=powerpc64-unknown-linux-$LIBC
;;
ppc:Linux:*:*)
GUESS=powerpc-unknown-linux-$LIBC
;;
ppc64le:Linux:*:*)
GUESS=powerpc64le-unknown-linux-$LIBC
;;
ppcle:Linux:*:*)
GUESS=powerpcle-unknown-linux-$LIBC
;;
riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
s390:Linux:*:* | s390x:Linux:*:*)
GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
;;
sh64*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
sh*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
sparc:Linux:*:* | sparc64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
tile*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
vax:Linux:*:*)
GUESS=$UNAME_MACHINE-dec-linux-$LIBC
;;
x86_64:Linux:*:*)
set_cc_for_build
CPU=$UNAME_MACHINE
LIBCABI=$LIBC
if test "$CC_FOR_BUILD" != no_compiler_found; then
ABI=64
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __i386__
ABI=x86
#else
#ifdef __ILP32__
ABI=x32
#endif
#endif
EOF
cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
eval "$cc_set_abi"
case $ABI in
x86) CPU=i686 ;;
x32) LIBCABI=${LIBC}x32 ;;
esac
fi
GUESS=$CPU-pc-linux-$LIBCABI
;;
xtensa*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
GUESS=i386-sequent-sysv4
;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
;;
i*86:OS/2:*:*)
# If we were able to find 'uname', then EMX Unix compatibility
# is probably installed.
GUESS=$UNAME_MACHINE-pc-os2-emx
;;
i*86:XTS-300:*:STOP)
GUESS=$UNAME_MACHINE-unknown-stop
;;
i*86:atheos:*:*)
GUESS=$UNAME_MACHINE-unknown-atheos
;;
i*86:syllable:*:*)
GUESS=$UNAME_MACHINE-pc-syllable
;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
GUESS=i386-unknown-lynxos$UNAME_RELEASE
;;
i*86:*DOS:*:*)
GUESS=$UNAME_MACHINE-pc-msdosdjgpp
;;
i*86:*:4.*:*)
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
else
GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
fi
;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
else
GUESS=$UNAME_MACHINE-pc-sysv32
fi
;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configure will decide that
# this is a cross-build.
GUESS=i586-pc-msdosdjgpp
;;
Intel:Mach:3*:*)
GUESS=i386-pc-mach3
;;
paragon:*:*:*)
GUESS=i860-intel-osf1
;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
fi
;;
mini*:CTIX:SYS*5:*)
# "miniframe"
GUESS=m68010-convergent-sysv
;;
mc68k:UNIX:SYSTEM5:3.51m)
GUESS=m68k-convergent-sysv
;;
M680?0:D-NIX:5.3:*)
GUESS=m68k-diab-dnix
;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
GUESS=m68k-unknown-lynxos$UNAME_RELEASE
;;
mc68030:UNIX_System_V:4.*:*)
GUESS=m68k-atari-sysv4
;;
TSUNAMI:LynxOS:2.*:*)
GUESS=sparc-unknown-lynxos$UNAME_RELEASE
;;
rs6000:LynxOS:2.*:*)
GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
;;
SM[BE]S:UNIX_SV:*:*)
GUESS=mips-dde-sysv$UNAME_RELEASE
;;
RM*:ReliantUNIX-*:*:*)
GUESS=mips-sni-sysv4
;;
RM*:SINIX-*:*:*)
GUESS=mips-sni-sysv4
;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
GUESS=$UNAME_MACHINE-sni-sysv4
else
GUESS=ns32k-sni-sysv
fi
;;
PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
# says
GUESS=i586-unisys-sysv4
;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
GUESS=hppa1.1-stratus-sysv4
;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
GUESS=i860-stratus-sysv4
;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
GUESS=$UNAME_MACHINE-stratus-vos
;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
GUESS=hppa1.1-stratus-vos
;;
mc68*:A/UX:*:*)
GUESS=m68k-apple-aux$UNAME_RELEASE
;;
news*:NEWS-OS:6*:*)
GUESS=mips-sony-newsos6
;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if test -d /usr/nec; then
GUESS=mips-nec-sysv$UNAME_RELEASE
else
GUESS=mips-unknown-sysv$UNAME_RELEASE
fi
;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
GUESS=powerpc-be-beos
;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
GUESS=powerpc-apple-beos
;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
GUESS=i586-pc-beos
;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
GUESS=i586-pc-haiku
;;
ppc:Haiku:*:*) # Haiku running on Apple PowerPC
GUESS=powerpc-apple-haiku
;;
*:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
GUESS=$UNAME_MACHINE-unknown-haiku
;;
SX-4:SUPER-UX:*:*)
GUESS=sx4-nec-superux$UNAME_RELEASE
;;
SX-5:SUPER-UX:*:*)
GUESS=sx5-nec-superux$UNAME_RELEASE
;;
SX-6:SUPER-UX:*:*)
GUESS=sx6-nec-superux$UNAME_RELEASE
;;
SX-7:SUPER-UX:*:*)
GUESS=sx7-nec-superux$UNAME_RELEASE
;;
SX-8:SUPER-UX:*:*)
GUESS=sx8-nec-superux$UNAME_RELEASE
;;
SX-8R:SUPER-UX:*:*)
GUESS=sx8r-nec-superux$UNAME_RELEASE
;;
SX-ACE:SUPER-UX:*:*)
GUESS=sxace-nec-superux$UNAME_RELEASE
;;
Power*:Rhapsody:*:*)
GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
;;
*:Rhapsody:*:*)
GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
;;
arm64:Darwin:*:*)
GUESS=aarch64-apple-darwin$UNAME_RELEASE
;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p`
case $UNAME_PROCESSOR in
unknown) UNAME_PROCESSOR=powerpc ;;
esac
if command -v xcode-select > /dev/null 2> /dev/null && \
! xcode-select --print-path > /dev/null 2> /dev/null ; then
# Avoid executing cc if there is no toolchain installed as
# cc will be a stub that puts up a graphical alert
# prompting the user to install developer tools.
CC_FOR_BUILD=no_compiler_found
else
set_cc_for_build
fi
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_PPC >/dev/null
then
UNAME_PROCESSOR=powerpc
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# uname -m returns i386 or x86_64
UNAME_PROCESSOR=$UNAME_MACHINE
fi
GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
;;
*:QNX:*:4*)
GUESS=i386-pc-qnx
;;
NEO-*:NONSTOP_KERNEL:*:*)
GUESS=neo-tandem-nsk$UNAME_RELEASE
;;
NSE-*:NONSTOP_KERNEL:*:*)
GUESS=nse-tandem-nsk$UNAME_RELEASE
;;
NSR-*:NONSTOP_KERNEL:*:*)
GUESS=nsr-tandem-nsk$UNAME_RELEASE
;;
NSV-*:NONSTOP_KERNEL:*:*)
GUESS=nsv-tandem-nsk$UNAME_RELEASE
;;
NSX-*:NONSTOP_KERNEL:*:*)
GUESS=nsx-tandem-nsk$UNAME_RELEASE
;;
*:NonStop-UX:*:*)
GUESS=mips-compaq-nonstopux
;;
BS2000:POSIX*:*:*)
GUESS=bs2000-siemens-sysv
;;
DS/*:UNIX_System_V:*:*)
GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "${cputype-}" = 386; then
UNAME_MACHINE=i386
elif test "x${cputype-}" != x; then
UNAME_MACHINE=$cputype
fi
GUESS=$UNAME_MACHINE-unknown-plan9
;;
*:TOPS-10:*:*)
GUESS=pdp10-unknown-tops10
;;
*:TENEX:*:*)
GUESS=pdp10-unknown-tenex
;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
GUESS=pdp10-dec-tops20
;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
GUESS=pdp10-xkl-tops20
;;
*:TOPS-20:*:*)
GUESS=pdp10-unknown-tops20
;;
*:ITS:*:*)
GUESS=pdp10-unknown-its
;;
SEI:*:*:SEIUX)
GUESS=mips-sei-seiux$UNAME_RELEASE
;;
*:DragonFly:*:*)
DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case $UNAME_MACHINE in
A*) GUESS=alpha-dec-vms ;;
I*) GUESS=ia64-dec-vms ;;
V*) GUESS=vax-dec-vms ;;
esac ;;
*:XENIX:*:SysV)
GUESS=i386-pc-xenix
;;
i*86:skyos:*:*)
SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
;;
i*86:rdos:*:*)
GUESS=$UNAME_MACHINE-pc-rdos
;;
i*86:Fiwix:*:*)
GUESS=$UNAME_MACHINE-pc-fiwix
;;
*:AROS:*:*)
GUESS=$UNAME_MACHINE-unknown-aros
;;
x86_64:VMkernel:*:*)
GUESS=$UNAME_MACHINE-unknown-esx
;;
amd64:Isilon\ OneFS:*:*)
GUESS=x86_64-unknown-onefs
;;
*:Unleashed:*:*)
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
;;
esac
# Do we have a guess based on uname results?
if test "x$GUESS" != x; then
echo "$GUESS"
exit
fi
# No uname command or uname output not recognized.
set_cc_for_build
cat > "$dummy.c" <
#include
#endif
#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
#include
#if defined(_SIZE_T_) || defined(SIGLOST)
#include
#endif
#endif
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
#if !defined (ultrix)
#include
#if defined (BSD)
#if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
#else
#if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
#else
printf ("vax-dec-bsd\n"); exit (0);
#endif
#endif
#else
printf ("vax-dec-bsd\n"); exit (0);
#endif
#else
#if defined(_SIZE_T_) || defined(SIGLOST)
struct utsname un;
uname (&un);
printf ("vax-dec-ultrix%s\n", un.release); exit (0);
#else
printf ("vax-dec-ultrix\n"); exit (0);
#endif
#endif
#endif
#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
#if defined(_SIZE_T_) || defined(SIGLOST)
struct utsname *un;
uname (&un);
printf ("mips-dec-ultrix%s\n", un.release); exit (0);
#else
printf ("mips-dec-ultrix\n"); exit (0);
#endif
#endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
echo "$0: unable to guess system type" >&2
case $UNAME_MACHINE:$UNAME_SYSTEM in
mips:Linux | mips64:Linux)
# If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <&2 <&2 </dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = "$UNAME_MACHINE"
UNAME_RELEASE = "$UNAME_RELEASE"
UNAME_SYSTEM = "$UNAME_SYSTEM"
UNAME_VERSION = "$UNAME_VERSION"
EOF
fi
exit 1
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
objfw-1.3/build-aux/config.sub 100644 001750 001750 00000107202 14767513633 015412 0 ustar 00js js 000000 000000 #! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2023 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2023-09-19'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches to .
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
# The "shellcheck disable" line above the timestamp inhibits complaints
# about features and limitations of the classic Bourne shell that were
# superseded or lifted in POSIX. However, this script identifies a wide
# variety of pre-POSIX systems that do not have POSIX shells at all, and
# even some reasonably current systems (Solaris 10 as case-in-point) still
# have a pre-POSIX /bin/sh.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try '$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
*local*)
# First pass through any local machine types.
echo "$1"
exit ;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Split fields of configuration type
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read field1 field2 field3 field4 <&2
exit 1
;;
*-*-*-*)
basic_machine=$field1-$field2
basic_os=$field3-$field4
;;
*-*-*)
# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
# parts
maybe_os=$field2-$field3
case $maybe_os in
nto-qnx* | linux-* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
| windows-* )
basic_machine=$field1
basic_os=$maybe_os
;;
android-linux)
basic_machine=$field1-unknown
basic_os=linux-android
;;
*)
basic_machine=$field1-$field2
basic_os=$field3
;;
esac
;;
*-*)
# A lone config we happen to match not fitting any pattern
case $field1-$field2 in
decstation-3100)
basic_machine=mips-dec
basic_os=
;;
*-*)
# Second component is usually, but not always the OS
case $field2 in
# Prevent following clause from handling this valid os
sun*os*)
basic_machine=$field1
basic_os=$field2
;;
zephyr*)
basic_machine=$field1-unknown
basic_os=$field2
;;
# Manufacturers
dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
| unicom* | ibm* | next | hp | isi* | apollo | altos* \
| convergent* | ncr* | news | 32* | 3600* | 3100* \
| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
| ultra | tti* | harris | dolphin | highlevel | gould \
| cbm | ns | masscomp | apple | axis | knuth | cray \
| microblaze* | sim | cisco \
| oki | wec | wrs | winbond)
basic_machine=$field1-$field2
basic_os=
;;
*)
basic_machine=$field1
basic_os=$field2
;;
esac
;;
esac
;;
*)
# Convert single-component short-hands not valid as part of
# multi-component configurations.
case $field1 in
386bsd)
basic_machine=i386-pc
basic_os=bsd
;;
a29khif)
basic_machine=a29k-amd
basic_os=udi
;;
adobe68k)
basic_machine=m68010-adobe
basic_os=scout
;;
alliant)
basic_machine=fx80-alliant
basic_os=
;;
altos | altos3068)
basic_machine=m68k-altos
basic_os=
;;
am29k)
basic_machine=a29k-none
basic_os=bsd
;;
amdahl)
basic_machine=580-amdahl
basic_os=sysv
;;
amiga)
basic_machine=m68k-unknown
basic_os=
;;
amigaos | amigados)
basic_machine=m68k-unknown
basic_os=amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
basic_os=sysv4
;;
apollo68)
basic_machine=m68k-apollo
basic_os=sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
basic_os=bsd
;;
aros)
basic_machine=i386-pc
basic_os=aros
;;
aux)
basic_machine=m68k-apple
basic_os=aux
;;
balance)
basic_machine=ns32k-sequent
basic_os=dynix
;;
blackfin)
basic_machine=bfin-unknown
basic_os=linux
;;
cegcc)
basic_machine=arm-unknown
basic_os=cegcc
;;
convex-c1)
basic_machine=c1-convex
basic_os=bsd
;;
convex-c2)
basic_machine=c2-convex
basic_os=bsd
;;
convex-c32)
basic_machine=c32-convex
basic_os=bsd
;;
convex-c34)
basic_machine=c34-convex
basic_os=bsd
;;
convex-c38)
basic_machine=c38-convex
basic_os=bsd
;;
cray)
basic_machine=j90-cray
basic_os=unicos
;;
crds | unos)
basic_machine=m68k-crds
basic_os=
;;
da30)
basic_machine=m68k-da30
basic_os=
;;
decstation | pmax | pmin | dec3100 | decstatn)
basic_machine=mips-dec
basic_os=
;;
delta88)
basic_machine=m88k-motorola
basic_os=sysv3
;;
dicos)
basic_machine=i686-pc
basic_os=dicos
;;
djgpp)
basic_machine=i586-pc
basic_os=msdosdjgpp
;;
ebmon29k)
basic_machine=a29k-amd
basic_os=ebmon
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
basic_os=ose
;;
gmicro)
basic_machine=tron-gmicro
basic_os=sysv
;;
go32)
basic_machine=i386-pc
basic_os=go32
;;
h8300hms)
basic_machine=h8300-hitachi
basic_os=hms
;;
h8300xray)
basic_machine=h8300-hitachi
basic_os=xray
;;
h8500hms)
basic_machine=h8500-hitachi
basic_os=hms
;;
harris)
basic_machine=m88k-harris
basic_os=sysv3
;;
hp300 | hp300hpux)
basic_machine=m68k-hp
basic_os=hpux
;;
hp300bsd)
basic_machine=m68k-hp
basic_os=bsd
;;
hppaosf)
basic_machine=hppa1.1-hp
basic_os=osf
;;
hppro)
basic_machine=hppa1.1-hp
basic_os=proelf
;;
i386mach)
basic_machine=i386-mach
basic_os=mach
;;
isi68 | isi)
basic_machine=m68k-isi
basic_os=sysv
;;
m68knommu)
basic_machine=m68k-unknown
basic_os=linux
;;
magnum | m3230)
basic_machine=mips-mips
basic_os=sysv
;;
merlin)
basic_machine=ns32k-utek
basic_os=sysv
;;
mingw64)
basic_machine=x86_64-pc
basic_os=mingw64
;;
mingw32)
basic_machine=i686-pc
basic_os=mingw32
;;
mingw32ce)
basic_machine=arm-unknown
basic_os=mingw32ce
;;
monitor)
basic_machine=m68k-rom68k
basic_os=coff
;;
morphos)
basic_machine=powerpc-unknown
basic_os=morphos
;;
moxiebox)
basic_machine=moxie-unknown
basic_os=moxiebox
;;
msdos)
basic_machine=i386-pc
basic_os=msdos
;;
msys)
basic_machine=i686-pc
basic_os=msys
;;
mvs)
basic_machine=i370-ibm
basic_os=mvs
;;
nacl)
basic_machine=le32-unknown
basic_os=nacl
;;
ncr3000)
basic_machine=i486-ncr
basic_os=sysv4
;;
netbsd386)
basic_machine=i386-pc
basic_os=netbsd
;;
netwinder)
basic_machine=armv4l-rebel
basic_os=linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
basic_os=newsos
;;
news1000)
basic_machine=m68030-sony
basic_os=newsos
;;
necv70)
basic_machine=v70-nec
basic_os=sysv
;;
nh3000)
basic_machine=m68k-harris
basic_os=cxux
;;
nh[45]000)
basic_machine=m88k-harris
basic_os=cxux
;;
nindy960)
basic_machine=i960-intel
basic_os=nindy
;;
mon960)
basic_machine=i960-intel
basic_os=mon960
;;
nonstopux)
basic_machine=mips-compaq
basic_os=nonstopux
;;
os400)
basic_machine=powerpc-ibm
basic_os=os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
basic_os=ose
;;
os68k)
basic_machine=m68k-none
basic_os=os68k
;;
paragon)
basic_machine=i860-intel
basic_os=osf
;;
parisc)
basic_machine=hppa-unknown
basic_os=linux
;;
psp)
basic_machine=mipsallegrexel-sony
basic_os=psp
;;
pw32)
basic_machine=i586-unknown
basic_os=pw32
;;
rdos | rdos64)
basic_machine=x86_64-pc
basic_os=rdos
;;
rdos32)
basic_machine=i386-pc
basic_os=rdos
;;
rom68k)
basic_machine=m68k-rom68k
basic_os=coff
;;
sa29200)
basic_machine=a29k-amd
basic_os=udi
;;
sei)
basic_machine=mips-sei
basic_os=seiux
;;
sequent)
basic_machine=i386-sequent
basic_os=
;;
sps7)
basic_machine=m68k-bull
basic_os=sysv2
;;
st2000)
basic_machine=m68k-tandem
basic_os=
;;
stratus)
basic_machine=i860-stratus
basic_os=sysv4
;;
sun2)
basic_machine=m68000-sun
basic_os=
;;
sun2os3)
basic_machine=m68000-sun
basic_os=sunos3
;;
sun2os4)
basic_machine=m68000-sun
basic_os=sunos4
;;
sun3)
basic_machine=m68k-sun
basic_os=
;;
sun3os3)
basic_machine=m68k-sun
basic_os=sunos3
;;
sun3os4)
basic_machine=m68k-sun
basic_os=sunos4
;;
sun4)
basic_machine=sparc-sun
basic_os=
;;
sun4os3)
basic_machine=sparc-sun
basic_os=sunos3
;;
sun4os4)
basic_machine=sparc-sun
basic_os=sunos4
;;
sun4sol2)
basic_machine=sparc-sun
basic_os=solaris2
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
basic_os=
;;
sv1)
basic_machine=sv1-cray
basic_os=unicos
;;
symmetry)
basic_machine=i386-sequent
basic_os=dynix
;;
t3e)
basic_machine=alphaev5-cray
basic_os=unicos
;;
t90)
basic_machine=t90-cray
basic_os=unicos
;;
toad1)
basic_machine=pdp10-xkl
basic_os=tops20
;;
tpf)
basic_machine=s390x-ibm
basic_os=tpf
;;
udi29k)
basic_machine=a29k-amd
basic_os=udi
;;
ultra3)
basic_machine=a29k-nyu
basic_os=sym1
;;
v810 | necv810)
basic_machine=v810-nec
basic_os=none
;;
vaxv)
basic_machine=vax-dec
basic_os=sysv
;;
vms)
basic_machine=vax-dec
basic_os=vms
;;
vsta)
basic_machine=i386-pc
basic_os=vsta
;;
vxworks960)
basic_machine=i960-wrs
basic_os=vxworks
;;
vxworks68)
basic_machine=m68k-wrs
basic_os=vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
basic_os=vxworks
;;
xbox)
basic_machine=i686-pc
basic_os=mingw32
;;
ymp)
basic_machine=ymp-cray
basic_os=unicos
;;
*)
basic_machine=$1
basic_os=
;;
esac
;;
esac
# Decode 1-component or ad-hoc basic machines
case $basic_machine in
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
cpu=hppa1.1
vendor=winbond
;;
op50n)
cpu=hppa1.1
vendor=oki
;;
op60c)
cpu=hppa1.1
vendor=oki
;;
ibm*)
cpu=i370
vendor=ibm
;;
orion105)
cpu=clipper
vendor=highlevel
;;
mac | mpw | mac-mpw)
cpu=m68k
vendor=apple
;;
pmac | pmac-mpw)
cpu=powerpc
vendor=apple
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
cpu=m68000
vendor=att
;;
3b*)
cpu=we32k
vendor=att
;;
bluegene*)
cpu=powerpc
vendor=ibm
basic_os=cnk
;;
decsystem10* | dec10*)
cpu=pdp10
vendor=dec
basic_os=tops10
;;
decsystem20* | dec20*)
cpu=pdp10
vendor=dec
basic_os=tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
cpu=m68k
vendor=motorola
;;
dpx2*)
cpu=m68k
vendor=bull
basic_os=sysv3
;;
encore | umax | mmax)
cpu=ns32k
vendor=encore
;;
elxsi)
cpu=elxsi
vendor=elxsi
basic_os=${basic_os:-bsd}
;;
fx2800)
cpu=i860
vendor=alliant
;;
genix)
cpu=ns32k
vendor=ns
;;
h3050r* | hiux*)
cpu=hppa1.1
vendor=hitachi
basic_os=hiuxwe2
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
cpu=hppa1.0
vendor=hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
cpu=m68000
vendor=hp
;;
hp9k3[2-9][0-9])
cpu=m68k
vendor=hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
cpu=hppa1.0
vendor=hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
cpu=hppa1.1
vendor=hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
cpu=hppa1.1
vendor=hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
cpu=hppa1.1
vendor=hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
cpu=hppa1.1
vendor=hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
cpu=hppa1.0
vendor=hp
;;
i*86v32)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
basic_os=sysv32
;;
i*86v4*)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
basic_os=sysv4
;;
i*86v)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
basic_os=sysv
;;
i*86sol2)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
basic_os=solaris2
;;
j90 | j90-cray)
cpu=j90
vendor=cray
basic_os=${basic_os:-unicos}
;;
iris | iris4d)
cpu=mips
vendor=sgi
case $basic_os in
irix*)
;;
*)
basic_os=irix4
;;
esac
;;
miniframe)
cpu=m68000
vendor=convergent
;;
*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
cpu=m68k
vendor=atari
basic_os=mint
;;
news-3600 | risc-news)
cpu=mips
vendor=sony
basic_os=newsos
;;
next | m*-next)
cpu=m68k
vendor=next
case $basic_os in
openstep*)
;;
nextstep*)
;;
ns2*)
basic_os=nextstep2
;;
*)
basic_os=nextstep3
;;
esac
;;
np1)
cpu=np1
vendor=gould
;;
op50n-* | op60c-*)
cpu=hppa1.1
vendor=oki
basic_os=proelf
;;
pa-hitachi)
cpu=hppa1.1
vendor=hitachi
basic_os=hiuxwe2
;;
pbd)
cpu=sparc
vendor=tti
;;
pbb)
cpu=m68k
vendor=tti
;;
pc532)
cpu=ns32k
vendor=pc532
;;
pn)
cpu=pn
vendor=gould
;;
power)
cpu=power
vendor=ibm
;;
ps2)
cpu=i386
vendor=ibm
;;
rm[46]00)
cpu=mips
vendor=siemens
;;
rtpc | rtpc-*)
cpu=romp
vendor=ibm
;;
sde)
cpu=mipsisa32
vendor=sde
basic_os=${basic_os:-elf}
;;
simso-wrs)
cpu=sparclite
vendor=wrs
basic_os=vxworks
;;
tower | tower-32)
cpu=m68k
vendor=ncr
;;
vpp*|vx|vx-*)
cpu=f301
vendor=fujitsu
;;
w65)
cpu=w65
vendor=wdc
;;
w89k-*)
cpu=hppa1.1
vendor=winbond
basic_os=proelf
;;
none)
cpu=none
vendor=none
;;
leon|leon[3-9])
cpu=sparc
vendor=$basic_machine
;;
leon-*|leon[3-9]-*)
cpu=sparc
vendor=`echo "$basic_machine" | sed 's/-.*//'`
;;
*-*)
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read cpu vendor <&2
exit 1
;;
esac
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $vendor in
digital*)
vendor=dec
;;
commodore*)
vendor=cbm
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if test x"$basic_os" != x
then
# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
# set os.
obj=
case $basic_os in
gnu/linux*)
kernel=linux
os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
;;
os2-emx)
kernel=os2
os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
;;
nto-qnx*)
kernel=nto
os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
;;
*-*)
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read kernel os <&2
fi
;;
*)
echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
exit 1
;;
esac
case $obj in
aout* | coff* | elf* | pe*)
;;
'')
# empty is fine
;;
*)
echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
exit 1
;;
esac
# Here we handle the constraint that a (synthetic) cpu and os are
# valid only in combination with each other and nowhere else.
case $cpu-$os in
# The "javascript-unknown-ghcjs" triple is used by GHC; we
# accept it here in order to tolerate that, but reject any
# variations.
javascript-ghcjs)
;;
javascript-* | *-ghcjs)
echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
exit 1
;;
esac
# As a final step for OS-related things, validate the OS-kernel combination
# (given a valid OS), if there is a kernel.
case $kernel-$os-$obj in
linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \
| linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- )
;;
uclinux-uclibc*- )
;;
managarm-mlibc*- | managarm-kernel*- )
;;
windows*-msvc*-)
;;
-dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- )
# These are just libc implementations, not actual OSes, and thus
# require a kernel.
echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
exit 1
;;
-kernel*- )
echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
exit 1
;;
*-kernel*- )
echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
exit 1
;;
*-msvc*- )
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
exit 1
;;
kfreebsd*-gnu*- | kopensolaris*-gnu*-)
;;
vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
;;
nto-qnx*-)
;;
os2-emx-)
;;
*-eabi*- | *-gnueabi*-)
;;
none--*)
# None (no kernel, i.e. freestanding / bare metal),
# can be paired with an machine code file format
;;
-*-)
# Blank kernel with real OS is always fine.
;;
--*)
# Blank kernel and OS with real machine code file format is always fine.
;;
*-*-*)
echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
exit 1
;;
esac
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
case $vendor in
unknown)
case $cpu-$os in
*-riscix*)
vendor=acorn
;;
*-sunos*)
vendor=sun
;;
*-cnk* | *-aix*)
vendor=ibm
;;
*-beos*)
vendor=be
;;
*-hpux*)
vendor=hp
;;
*-mpeix*)
vendor=hp
;;
*-hiux*)
vendor=hitachi
;;
*-unos*)
vendor=crds
;;
*-dgux*)
vendor=dg
;;
*-luna*)
vendor=omron
;;
*-genix*)
vendor=ns
;;
*-clix*)
vendor=intergraph
;;
*-mvs* | *-opened*)
vendor=ibm
;;
*-os400*)
vendor=ibm
;;
s390-* | s390x-*)
vendor=ibm
;;
*-ptx*)
vendor=sequent
;;
*-tpf*)
vendor=ibm
;;
*-vxsim* | *-vxworks* | *-windiss*)
vendor=wrs
;;
*-aux*)
vendor=apple
;;
*-hms*)
vendor=hitachi
;;
*-mpw* | *-macos*)
vendor=apple
;;
*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
vendor=atari
;;
*-vos*)
vendor=stratus
;;
esac
;;
esac
echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
exit
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
objfw-1.3/build-aux/install-sh 100755 001750 001750 00000036101 14767513633 015435 0 ustar 00js js 000000 000000 #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2023-11-23.18; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22
backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Report bugs to .
GNU Automake home page: .
General help using GNU software: ."
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-p) cpprog="$cpprog -p";;
-s) stripcmd=$stripprog;;
-S) backupsuffix="$2"
shift;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
# The $RANDOM variable is not portable (e.g., dash). Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=${dstdirslash}_inst.$$_
rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask &&
{ test -z "$stripcmd" || {
# Create $dsttmp read-write so that cp doesn't create it read-only,
# which would cause strip to fail.
if test -z "$doit"; then
: >"$dsttmp" # No need to fork-exec 'touch'.
else
$doit touch "$dsttmp"
fi
}
} &&
$doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
objfw-1.3/build-aux/m4 040755 001750 001750 00000000000 14767513633 013674 5 ustar 00js js 000000 000000 objfw-1.3/build-aux/m4/ax_check_compiler_flags.m4 100644 001750 001750 00000006361 14767513633 021033 0 ustar 00js js 000000 000000 # ===========================================================================
# http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
#
# DESCRIPTION
#
# Check whether the given compiler FLAGS work with the current language's
# compiler, or whether they give an error. (Warnings, however, are
# ignored.)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# LAST MODIFICATION
#
# 2008-04-12
#
# COPYLEFT
#
# Copyright (c) 2008 Steven G. Johnson
# Copyright (c) 2008 Matteo Frigo
#
# 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 .
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Macro Archive. When you make and
# distribute a modified version of the Autoconf Macro, you may extend this
# special exception to the GPL to apply to your modified version as well.
AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
AS_LITERAL_IF([$1],
[AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
[ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
AC_MSG_RESULT($ax_check_compiler_flags)
if test "x$ax_check_compiler_flags" = xyes; then
m4_default([$2], :)
else
m4_default([$3], :)
fi
])dnl AX_CHECK_COMPILER_FLAGS
objfw-1.3/build-aux/m4/buildsys.m4 100644 001750 001750 00000032213 14767513633 016051 0 ustar 00js js 000000 000000 dnl
dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017,
dnl 2018, 2020, 2021, 2022, 2023, 2024, 2025
dnl Jonathan Schleifer
dnl
dnl https://fl.nil.im/buildsys
dnl
dnl Permission to use, copy, modify, and/or distribute this software for any
dnl purpose with or without fee is hereby granted, provided that the above
dnl copyright notice and this permission notice appear in all copies.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dnl REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dnl AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dnl INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dnl LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dnl OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dnl PERFORMANCE OF THIS SOFTWARE.
dnl
AC_DEFUN([BUILDSYS_INIT], [
AC_REQUIRE([AC_CANONICAL_BUILD])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_ARG_ENABLE(rpath,
AS_HELP_STRING([--disable-rpath], [do not use rpath]))
AC_ARG_ENABLE(silent-rules,
AS_HELP_STRING([--disable-silent-rules],
[print executed commands during build]))
case "$build_os" in
darwin*)
case "$host_os" in
darwin*)
AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes)
;;
esac
;;
esac
AC_PROG_INSTALL
case "$INSTALL" in
./build-aux/install-sh*)
INSTALL="$PWD/$INSTALL"
;;
esac
AC_CONFIG_COMMANDS_PRE([
AS_IF([test x"$GCC" = x"yes"],
[AC_SUBST(DEP_CFLAGS, '-MD -MF $${out%.o}.dep')])
AS_IF([test x"$GXX" = x"yes"],
[AC_SUBST(DEP_CXXFLAGS, '-MD -MF $${out%.o}.dep')])
AS_IF([test x"$GOBJC" = x"yes"],
[AC_SUBST(DEP_OBJCFLAGS, '-MD -MF $${out%.o}.dep')])
AS_IF([test x"$GOBJCXX" = x"yes"],
[AC_SUBST(DEP_OBJCXXFLAGS, '-MD -MF $${out%.o}.dep')])
AC_SUBST(AMIGA_LIB_CFLAGS)
AC_SUBST(AMIGA_LIB_LDFLAGS)
case "$build_os" in
morphos*)
dnl Don't use tput on MorphOS: The colored output is
dnl quite unreadable and in some MorphOS versions the
dnl output from tput is not 8-bit safe, with awk (for
dnl AC_SUBST) failing as a result.
;;
*)
AC_PATH_PROG(TPUT, tput)
;;
esac
AS_IF([test x"$TPUT" != x""], [
if x=$($TPUT el 2>/dev/null); then
AC_SUBST(TERM_EL, "$x")
else
AC_SUBST(TERM_EL, "$($TPUT ce 2>/dev/null)")
fi
if x=$($TPUT sgr0 2>/dev/null); then
AC_SUBST(TERM_SGR0, "$x")
else
AC_SUBST(TERM_SGR0, "$($TPUT me 2>/dev/null)")
fi
if x=$($TPUT bold 2>/dev/null); then
AC_SUBST(TERM_BOLD, "$x")
else
AC_SUBST(TERM_BOLD, "$($TPUT md 2>/dev/null)")
fi
if x=$($TPUT setaf 1 2>/dev/null); then
AC_SUBST(TERM_SETAF1, "$x")
AC_SUBST(TERM_SETAF2,
"$($TPUT setaf 2 2>/dev/null)")
AC_SUBST(TERM_SETAF3,
"$($TPUT setaf 3 2>/dev/null)")
AC_SUBST(TERM_SETAF4,
"$($TPUT setaf 4 2>/dev/null)")
AC_SUBST(TERM_SETAF6,
"$($TPUT setaf 6 2>/dev/null)")
AC_SUBST(TERM_SETAF9,
"$($TPUT setaf 9 2>/dev/null)")
AC_SUBST(TERM_SETAF10,
"$($TPUT setaf 10 2>/dev/null)")
AC_SUBST(TERM_SETAF11,
"$($TPUT setaf 11 2>/dev/null)")
AC_SUBST(TERM_SETAF12,
"$($TPUT setaf 12 2>/dev/null)")
AC_SUBST(TERM_SETAF14,
"$($TPUT setaf 14 2>/dev/null)")
dnl OpenBSD seems to want 3 parameters for terminals
dnl ending in -256color, but the additional two
dnl parameters don't seem to do anything, so we set
dnl them to 0.
elif x=$($TPUT setaf 1 0 0 2>/dev/null); then
AC_SUBST(TERM_SETAF1, "$x")
AC_SUBST(TERM_SETAF2,
"$($TPUT setaf 2 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF3,
"$($TPUT setaf 3 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF4,
"$($TPUT setaf 4 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF6,
"$($TPUT setaf 6 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF9,
"$($TPUT setaf 9 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF10,
"$($TPUT setaf 10 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF11,
"$($TPUT setaf 11 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF12,
"$($TPUT setaf 12 0 0 2>/dev/null)")
AC_SUBST(TERM_SETAF14,
"$($TPUT setaf 14 0 0 2>/dev/null)")
else
AC_SUBST(TERM_SETAF1,
"$($TPUT AF 1 2>/dev/null)")
AC_SUBST(TERM_SETAF2,
"$($TPUT AF 2 2>/dev/null)")
AC_SUBST(TERM_SETAF3,
"$($TPUT AF 3 2>/dev/null)")
AC_SUBST(TERM_SETAF4,
"$($TPUT AF 4 2>/dev/null)")
AC_SUBST(TERM_SETAF6,
"$($TPUT AF 6 2>/dev/null)")
AC_SUBST(TERM_SETAF9,
"$($TPUT AF 9 2>/dev/null)")
AC_SUBST(TERM_SETAF10,
"$($TPUT AF 10 2>/dev/null)")
AC_SUBST(TERM_SETAF11,
"$($TPUT AF 11 2>/dev/null)")
AC_SUBST(TERM_SETAF12,
"$($TPUT AF 12 2>/dev/null)")
AC_SUBST(TERM_SETAF14,
"$($TPUT AF 14 2>/dev/null)")
fi
])
AS_IF([test x"$enable_silent_rules" != x"no"], [
AC_SUBST(SILENT, '.SILENT:')
AC_SUBST(MAKEFLAGS_SILENT, '-s')
])
])
])
AC_DEFUN([BUILDSYS_CHECK_IOS], [
case "$host_os" in
darwin*)
AC_MSG_CHECKING(whether host is iOS)
AC_EGREP_CPP(yes, [
#include
#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
(defined(TARGET_OS_SIMULATOR) && \
TARGET_OS_SIMULATOR)
yes
#endif
], [
host_is_ios="yes"
AC_SUBST(HOST_IS_IOS, yes)
], [
host_is_ios="no"
])
AC_MSG_RESULT($host_is_ios)
AC_CHECK_TOOL(CODESIGN, codesign)
;;
esac
])
AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_MSG_CHECKING(whether we need an implib)
case "$host_os" in
cygwin* | mingw*)
AC_MSG_RESULT(yes)
PROG_IMPLIB_NEEDED='yes'
PROG_IMPLIB_LDFLAGS='-Wl,--export-all-symbols,--out-implib,lib${PROG}.a'
;;
*)
AC_MSG_RESULT(no)
PROG_IMPLIB_NEEDED='no'
PROG_IMPLIB_LDFLAGS=''
;;
esac
AC_SUBST(PROG_IMPLIB_NEEDED)
AC_SUBST(PROG_IMPLIB_LDFLAGS)
])
AC_DEFUN([BUILDSYS_SHARED_LIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_MSG_CHECKING(for shared library type)
case "$host" in
*-*-darwin*)
AC_MSG_RESULT(Darwin)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib'
LIB_PREFIX='lib'
LIB_SUFFIX='.dylib'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
CLEAN_LIB=''
;;
*-*-mingw* | *-*-cygwin*)
AC_MSG_RESULT(MinGW / Cygwin)
LIB_CFLAGS=''
LIB_LDFLAGS='-shared -Wl,--export-all-symbols'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX=''
LIB_SUFFIX='${LIB_MAJOR}.dll'
LINK_LIB='&& rm -f lib$${out%${LIB_SUFFIX}}.dll.a && ${LN_S} $$out lib$${out%${LIB_SUFFIX}}.dll.a'
INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$${i%${LIB_SUFFIX}}.dll.a ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
CLEAN_LIB='${SHARED_LIB}.a ${SHARED_LIB_NOINST}.a'
;;
*-*-openbsd* | *-*-mirbsd*)
AC_MSG_RESULT(OpenBSD)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
CLEAN_LIB=''
;;
*-*-solaris*)
AC_MSG_RESULT(Solaris)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}.${LIB_MINOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
CLEAN_LIB=''
;;
*-*-android*)
AC_MSG_RESULT(Android)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH}'
CLEAN_LIB=''
;;
hppa*-*-hpux*)
AC_MSG_RESULT([HP-UX (PA-RISC)])
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,+h,$$out'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,+b,${libdir}'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
CLEAN_LIB=''
;;
ia64*-*-hpux*)
AC_MSG_RESULT([HP-UX (Itanium)])
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,+h,$$out'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,+b,${libdir}'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.so'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.so'
CLEAN_LIB=''
;;
*)
AC_MSG_RESULT(ELF)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH}'
CLEAN_LIB=''
;;
esac
AC_SUBST(LIB_CFLAGS)
AC_SUBST(LIB_LDFLAGS)
AC_SUBST(LIB_LDFLAGS_INSTALL_NAME)
AC_SUBST(LIB_PREFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(LINK_LIB)
AC_SUBST(LDFLAGS_RPATH)
AC_SUBST(INSTALL_LIB)
AC_SUBST(UNINSTALL_LIB)
AC_SUBST(CLEAN_LIB)
])
AC_DEFUN([BUILDSYS_FRAMEWORK], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_REQUIRE([BUILDSYS_SHARED_LIB])
case "$host_os" in
darwin*)
FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
AS_IF([test x"$host_is_ios" = x"yes"], [
FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}'
], [
FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}'
])
AC_SUBST(FRAMEWORK_LDFLAGS)
AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME)
AC_SUBST(FRAMEWORK_LIBS)
$1
;;
*)
$2
;;
esac
])
AC_DEFUN([BUILDSYS_PLUGIN], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_MSG_CHECKING(for plugin type)
case "$host" in
*-*-darwin*)
AC_MSG_RESULT(Darwin)
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-bundle'
PLUGIN_SUFFIX='.dylib'
;;
*-*-mingw* | *-*-cygwin*)
AC_MSG_RESULT(MinGW / Cygwin)
PLUGIN_CFLAGS=''
PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols'
PLUGIN_SUFFIX='.dll'
;;
hppa*-*-hpux*)
AC_MSG_RESULT([HP-UX (PA-RISC)])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.sl'
;;
*)
AC_MSG_RESULT(ELF)
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
;;
esac
AC_SUBST(PLUGIN_CFLAGS)
AC_SUBST(PLUGIN_LDFLAGS)
AC_SUBST(PLUGIN_SUFFIX)
])
AC_DEFUN([BUILDSYS_BUNDLE], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_REQUIRE([BUILDSYS_PLUGIN])
case "$host_os" in
darwin*)
AS_IF([test x"$host_is_ios" = x"yes"], [
LINK_BUNDLE='${MKDIR_P} $$out && ${INSTALL} -m 644 Info.plist $$out/Info.plist && ${LD} -o $$out/$${out%.bundle} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
], [
LINK_BUNDLE='${MKDIR_P} $$out/Contents/MacOS && ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist && ${LD} -o $$out/Contents/MacOS/$${out%.bundle} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
])
AC_SUBST(LINK_BUNDLE)
$1
;;
*)
$2
;;
esac
])
objfw-1.3/build-aux/m4/pkg.m4 100644 001750 001750 00000030576 14767513633 015006 0 ustar 00js js 000000 000000 # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 11 (pkg-config-0.29.1)
dnl Copyright © 2004 Scott James Remnant .
dnl Copyright © 2012-2015 Dan Nicholson
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if you
dnl distribute this file as part of a program that contains a
dnl configuration script generated by Autoconf, you may include it under
dnl the same distribution terms that you use for the rest of that
dnl program.
dnl PKG_PREREQ(MIN-VERSION)
dnl -----------------------
dnl Since: 0.29
dnl
dnl Verify that the version of the pkg-config macros are at least
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
dnl installed version of pkg-config, this checks the developer's version
dnl of pkg.m4 when generating configure.
dnl
dnl To ensure that this macro is defined, also add:
dnl m4_ifndef([PKG_PREREQ],
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.1])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
dnl ----------------------------------
dnl Since: 0.16
dnl
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
dnl first found in the path. Checks that the version of pkg-config found
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
dnl used since that's the first version where most current features of
dnl pkg-config existed.
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
])dnl PKG_PROG_PKG_CONFIG
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------------------------------
dnl Since: 0.18
dnl
dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
dnl
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
dnl only at the first occurence in configure.ac, so if the first place
dnl it's called might be skipped (such as if it is within an "if", you
dnl 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])
dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
dnl ---------------------------------------------
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
dnl pkg_failed based on the result.
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
])dnl _PKG_CONFIG
dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl ---------------------------
dnl Internal check to see if pkg-config supports short errors.
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
])dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------
dnl Since: 0.4.0
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
dnl 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
])dnl PKG_CHECK_MODULES
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl ---------------------------------------------------------------------
dnl Since: 0.29
dnl
dnl Checks for existence of MODULES and gathers its build flags with
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
dnl and VARIABLE-PREFIX_LIBS from --libs.
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
dnl configure.ac.
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
_save_PKG_CONFIG=$PKG_CONFIG
PKG_CONFIG="$PKG_CONFIG --static"
PKG_CHECK_MODULES($@)
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
])dnl PKG_CHECK_MODULES_STATIC
dnl PKG_INSTALLDIR([DIRECTORY])
dnl -------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable pkgconfigdir as the location where a module
dnl should install pkg-config .pc files. By default the directory is
dnl $libdir/pkgconfig, but the default can be changed by passing
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
dnl 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
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
dnl --------------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
dnl module should install arch-independent pkg-config .pc files. By
dnl default the directory is $datadir/pkgconfig, but the default can be
dnl changed by passing DIRECTORY. The user can override through the
dnl --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
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------
dnl Since: 0.28
dnl
dnl 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
])dnl PKG_CHECK_VAR
dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
dnl [DESCRIPTION], [DEFAULT])
dnl ------------------------------------------
dnl
dnl Prepare a "--with-" configure option using the lowercase
dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
dnl PKG_CHECK_MODULES in a single macro.
AC_DEFUN([PKG_WITH_MODULES],
[
m4_pushdef([with_arg], m4_tolower([$1]))
m4_pushdef([description],
[m4_default([$5], [build with ]with_arg[ support])])
m4_pushdef([def_arg], [m4_default([$6], [auto])])
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
m4_case(def_arg,
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
[m4_pushdef([with_without],[--with-]with_arg)])
AC_ARG_WITH(with_arg,
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
[AS_TR_SH([with_]with_arg)=def_arg])
AS_CASE([$AS_TR_SH([with_]with_arg)],
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
[auto],[PKG_CHECK_MODULES([$1],[$2],
[m4_n([def_action_if_found]) $3],
[m4_n([def_action_if_not_found]) $4])])
m4_popdef([with_arg])
m4_popdef([description])
m4_popdef([def_arg])
])dnl PKG_WITH_MODULES
dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
dnl [DESCRIPTION], [DEFAULT])
dnl -----------------------------------------------
dnl
dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
dnl check._[VARIABLE-PREFIX] is exported as make variable.
AC_DEFUN([PKG_HAVE_WITH_MODULES],
[
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
AM_CONDITIONAL([HAVE_][$1],
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
])dnl PKG_HAVE_WITH_MODULES
dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
dnl [DESCRIPTION], [DEFAULT])
dnl ------------------------------------------------------
dnl
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
dnl and preprocessor variable.
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
[
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
])dnl PKG_HAVE_DEFINE_WITH_MODULES
objfw-1.3/buildsys.mk.in 100644 001750 001750 00000073677 14767513633 014356 0 ustar 00js js 000000 000000 #
# Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
# 2017, 2018, 2020, 2021, 2022, 2023, 2024, 2025
# Jonathan Schleifer
#
# https://fl.nil.im/buildsys
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
AS = @AS@
CC = @CC@
CXX = @CXX@
CPP = @CPP@
DC = @DC@
ERLC = @ERLC@
OBJC = @OBJC@
OBJCXX = @OBJCXX@
AR = @AR@
LD = ${CC}
RANLIB = @RANLIB@
PYTHON = @PYTHON@
ASFLAGS = @ASFLAGS@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
CPPFLAGS = @CPPFLAGS@
DFLAGS = @DFLAGS@
ERLCFLAGS = @ERLCFLAGS@
OBJCFLAGS = @OBJCFLAGS@
OBJCXXFLAGS = @OBJCXXFLAGS@
LDFLAGS = @LDFLAGS@
LDFLAGS_RPATH = @LDFLAGS_RPATH@
LIBS = @LIBS@
PYTHON_FLAGS = @PYTHON_FLAGS@
PROG_IMPLIB_NEEDED = @PROG_IMPLIB_NEEDED@
PROG_IMPLIB_LDFLAGS = @PROG_IMPLIB_LDFLAGS@
PROG_SUFFIX = @EXEEXT@
LIB_CFLAGS = @LIB_CFLAGS@
LIB_LDFLAGS = @LIB_LDFLAGS@
LIB_LDFLAGS_INSTALL_NAME = @LIB_LDFLAGS_INSTALL_NAME@
LIB_PREFIX = @LIB_PREFIX@
LIB_SUFFIX = @LIB_SUFFIX@
LINK_LIB = @LINK_LIB@
AMIGA_LIB_CFLAGS = @AMIGA_LIB_CFLAGS@
AMIGA_LIB_LDFLAGS = @AMIGA_LIB_LDFLAGS@
PLUGIN_CFLAGS = @PLUGIN_CFLAGS@
PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@
PLUGIN_SUFFIX = @PLUGIN_SUFFIX@
FRAMEWORK_LDFLAGS = @FRAMEWORK_LDFLAGS@
FRAMEWORK_LDFLAGS_INSTALL_NAME = @FRAMEWORK_LDFLAGS_INSTALL_NAME@
FRAMEWORK_LIBS = @FRAMEWORK_LIBS@
CODESIGN = @CODESIGN@
CODESIGN_IDENTITY ?= -
CLEAN_LIB = @CLEAN_LIB@
DEP_ASFLAGS = @DEP_ASFLAGS@
DEP_CFLAGS = @DEP_CFLAGS@
DEP_CXXFLAGS = @DEP_CXXFLAGS@
DEP_OBJCFLAGS = @DEP_OBJCFLAGS@
DEP_OBJCXXFLAGS = @DEP_OBJCXXFLAGS@
LN_S = @LN_S@
MKDIR_P = mkdir -p
INSTALL = @INSTALL@
SHELL = @SHELL@
MSGFMT = @MSGFMT@
JAVAC = @JAVAC@
JAVACFLAGS = @JAVACFLAGS@
JAR = @JAR@
RC = @RC@
BUILD_AND_HOST_ARE_DARWIN = @BUILD_AND_HOST_ARE_DARWIN@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
amigalibdir ?= ${prefix}/libs
plugindir ?= ${libdir}/${PACKAGE_NAME}
bundledir ?= ${prefix}/Library/PlugIns/${PACKAGE_NAME}
datarootdir = @datarootdir@
datadir = @datadir@
includedir = @includedir@
includesubdir ?= ${PACKAGE_NAME}
INSTALL_INCLUDES ?= yes
localedir = @localedir@
localename ?= ${PACKAGE_NAME}
mandir = @mandir@
mansubdir ?= man1
OBJS1 = ${SRCS:.c=.o}
OBJS2 = ${OBJS1:.cc=.o}
OBJS3 = ${OBJS2:.cxx=.o}
OBJS4 = ${OBJS3:.d=.o}
OBJS5 = ${OBJS4:.erl=.beam}
OBJS6 = ${OBJS5:.java=.class}
OBJS7 = ${OBJS6:.m=.o}
OBJS8 = ${OBJS7:.mm=.o}
OBJS9 = ${OBJS8:.py=.pyc}
OBJS10 = ${OBJS9:.rc=.o}
OBJS11 = ${OBJS10:.S=.o}
OBJS += ${OBJS11:.xpm=.o}
LIB_OBJS = ${OBJS:.o=.lib.o}
AMIGA_LIB_OBJS = ${OBJS:.o=.amigalib.o}
PLUGIN_OBJS = ${OBJS:.o=.plugin.o}
DEPS = ${OBJS:.o=.dep} \
${LIB_OBJS:.o=.dep} \
${AMIGA_LIB_OBJS:.o=.dep} \
${PLUGIN_OBJS:.o=.dep}
MO_FILES = ${LOCALES:.po=.mo}
@SILENT@
.SUFFIXES:
.SUFFIXES: .amigalib.o .beam .c .cc .class .cxx .d .erl .lib.o .java \
.mo .m .mm .o .plugin.o .po .py .pyc .rc .S .xpm
.PHONY: all subdirs subdirs-after pre-depend depend install \
install-extra uninstall uninstall-extra clean distclean locales \
copy-headers-into-framework ${SUBDIRS} ${SUBDIRS_AFTER}
all:
${MAKE} @MAKEFLAGS_SILENT@ pre-all
${MAKE} @MAKEFLAGS_SILENT@ subdirs
${MAKE} @MAKEFLAGS_SILENT@ depend
${MAKE} @MAKEFLAGS_SILENT@ \
${STATIC_LIB} ${STATIC_LIB_NOINST} \
${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} \
${STATIC_AMIGA_LIB}${STATIC_AMIGA_LIB_NOINST} \
${SHARED_LIB} ${SHARED_LIB_NOINST} \
${FRAMEWORK} ${FRAMEWORK_NOINST} \
${AMIGA_LIB} ${AMIGA_LIB_NOINST} \
${PLUGIN} ${PLUGIN_NOINST} \
${BUNDLE} ${BUNDLE_NOINST} \
${PROG} ${PROG_NOINST} \
${JARFILE} locales
${MAKE} @MAKEFLAGS_SILENT@ subdirs-after
${MAKE} @MAKEFLAGS_SILENT@ post-all
pre-all post-all:
subdirs: ${SUBDIRS}
subdirs-after: ${SUBDIRS_AFTER}
${SUBDIRS} ${SUBDIRS_AFTER}:
for i in $@; do \
${DIR_ENTER}; \
${MAKE} @MAKEFLAGS_SILENT@ || exit $$?; \
${DIR_LEAVE}; \
done
depend: pre-depend
: >.deps
for i in "" ${DEPS}; do \
test x"$$i" = x"" && continue; \
echo "-include \$${.CURDIR}/$$i" >>.deps; \
done
pre-depend:
${PROG} ${PROG_NOINST}: ${EXT_DEPS} ${OBJS} ${OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
if ${LD} -o $@ ${OBJS} ${OBJS_EXTRA} ${LDFLAGS} ${LIBS}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi
${JARFILE}: ${EXT_DEPS} ${JAR_MANIFEST} ${OBJS} ${OBJS_EXTRA}
${LINK_STATUS}
if test x"${JAR_MANIFEST}" != x""; then \
if ${JAR} cfm ${JARFILE} ${JAR_MANIFEST} ${OBJS} \
${OBJS_EXTRA}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi \
else \
if ${JAR} cf ${JARFILE} ${OBJS} ${OBJS_EXTRA}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi \
fi
${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
if ${LD} -o $@ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LIB_LDFLAGS} \
${LIB_LDFLAGS_INSTALL_NAME} ${LDFLAGS} ${LIBS} ${LINK_LIB}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi
${FRAMEWORK} ${FRAMEWORK_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
if test x"@HOST_IS_IOS@" = x"yes"; then \
if rm -fr $@ && \
${MAKE} @MAKEFLAGS_SILENT@ \
COPY_HEADERS_IF_SUBDIR=${includesubdir} \
COPY_HEADERS_DESTINATION=$$PWD/$@/Headers \
copy-headers-into-framework && \
${INSTALL} -m 644 Info.plist $@/Info.plist && \
if test -f module.modulemap; then \
${MKDIR_P} $@/Modules && \
${INSTALL} -m 644 module.modulemap \
$@/Modules/module.modulemap; \
fi && \
${LD} -o $@/$${out%.framework} \
${LIB_OBJS} ${LIB_OBJS_EXTRA} ${FRAMEWORK_LDFLAGS} \
${FRAMEWORK_LDFLAGS_INSTALL_NAME} ${LDFLAGS} \
${FRAMEWORK_LIBS} && \
${CODESIGN} -fs ${CODESIGN_IDENTITY} $@; then \
${LINK_OK}; \
else \
rm -fr $$out; false; \
${LINK_FAILED}; \
fi; \
else \
versiondir="$@/Versions/${LIB_MAJOR}"; \
if rm -fr $@ && \
${MKDIR_P} $$versiondir && \
${LN_S} ${LIB_MAJOR} $@/Versions/Current && \
${MAKE} @MAKEFLAGS_SILENT@ \
COPY_HEADERS_IF_SUBDIR=${includesubdir} \
COPY_HEADERS_DESTINATION=$$PWD/$$versiondir/Headers \
copy-headers-into-framework && \
${LN_S} Versions/Current/Headers $@/Headers && \
if test -f Info.plist; then \
${MKDIR_P} $$versiondir/Resources && \
${INSTALL} -m 644 Info.plist \
$$versiondir/Resources/Info.plist && \
${LN_S} Versions/Current/Resources $@/Resources; \
fi && \
if test -f module.modulemap; then \
${MKDIR_P} $$versiondir/Modules && \
${INSTALL} -m 644 module.modulemap \
$$versiondir/Modules/module.modulemap && \
${LN_S} Versions/Current/Modules $@/Modules; \
fi && \
${LD} -o $$versiondir/$${out%.framework} \
${LIB_OBJS} ${LIB_OBJS_EXTRA} ${FRAMEWORK_LDFLAGS} \
${FRAMEWORK_LDFLAGS_INSTALL_NAME} ${LDFLAGS} \
${FRAMEWORK_LIBS} && \
${LN_S} Versions/Current/$${out%.framework} \
$@/$${out%.framework} && \
${CODESIGN} -fs ${CODESIGN_IDENTITY} $@; then \
${LINK_OK}; \
else \
rm -fr $$out; false; \
${LINK_FAILED}; \
fi; \
fi
copy-headers-into-framework:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
cd $$i || exit 1; \
${MAKE} @MAKEFLAGS_SILENT@ copy-headers-into-framework || \
exit $$?; \
cd .. || exit 1; \
done
if test x"${includesubdir}" = x"${COPY_HEADERS_IF_SUBDIR}"; then \
for i in "" ${INCLUDES}; do \
test x"$$i" = x"" && continue; \
${MKDIR_P} \
$$(dirname ${COPY_HEADERS_DESTINATION}/$$i) || \
exit $$?; \
${INSTALL} -m 644 $$i \
${COPY_HEADERS_DESTINATION}/$$i || exit $$?; \
done \
fi
${AMIGA_LIB} ${AMIGA_LIB_NOINST}: ${EXT_DEPS} ${AMIGA_LIB_OBJS_START} \
${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA}
${LINK_STATUS}
if ${LD} -o $@ ${AMIGA_LIB_OBJS_START} ${AMIGA_LIB_OBJS} \
${AMIGA_LIB_OBJS_EXTRA} ${AMIGA_LIB_LDFLAGS} \
${AMIGA_LIB_LIBS}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi
${PLUGIN} ${PLUGIN_NOINST}: ${EXT_DEPS} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
if ${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}; then \
${LINK_OK}; \
else \
rm -fr $$out; false; \
${LINK_FAILED}; \
fi
${BUNDLE} ${BUNDLE_NOINST}: ${EXT_DEPS} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
if rm -fr $$out && @LINK_BUNDLE@ && ${CODESIGN} -fs ${CODESIGN_IDENTITY} $$out; then \
${LINK_OK}; \
else \
rm -fr $$out; false; \
${LINK_FAILED}; \
fi
${STATIC_LIB} ${STATIC_LIB_NOINST}: ${EXT_DEPS} ${OBJS} ${OBJS_EXTRA}
${LINK_STATUS}
rm -f $@
if test x"${BUILD_AND_HOST_ARE_DARWIN}" = x"yes"; then \
if /usr/bin/libtool -static -o $@ ${OBJS} ${OBJS_EXTRA}; then \
${LINK_OK}; \
else \
rm -f $@; false; \
${LINK_FAILED}; \
fi; \
else \
out="$@"; \
objs=""; \
ars=""; \
for i in ${OBJS} ${OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
mkdir -p $$dir; \
cd $$dir; \
${AR} x ../$$i; \
for j in *.o; do \
objs="$$objs $$dir/$$j"; \
done; \
cd ..; \
done; \
if ${AR} cr $@ $$objs && ${RANLIB} $@; then \
${LINK_OK}; \
else \
rm -f $@; false; \
${LINK_FAILED}; \
fi; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
done; \
fi
${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} \
${LIB_OBJS_EXTRA}
${LINK_STATUS}
rm -f $@
if test x"${BUILD_AND_HOST_ARE_DARWIN}" = x"yes"; then \
if /usr/bin/libtool -static -o $@ ${LIB_OBJS} \
${LIB_OBJS_EXTRA}; then \
${LINK_OK}; \
else \
rm -f $@; false; \
${LINK_FAILED}; \
fi; \
else \
out="$@"; \
objs=""; \
ars=""; \
for i in ${LIB_OBJS} ${LIB_OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
mkdir -p $$dir; \
cd $$dir; \
${AR} x ../$$i; \
for j in *.o; do \
objs="$$objs $$dir/$$j"; \
done; \
cd ..; \
done; \
if ${AR} cr $@ $$objs && ${RANLIB} $@; then \
${LINK_OK}; \
else \
rm -f $@; false; \
${LINK_FAILED}; \
fi; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
done; \
fi
${STATIC_AMIGA_LIB} ${STATIC_AMIGA_LIB_NOINST}: ${EXT_DEPS} ${AMIGA_LIB_OBJS} \
${AMIGA_LIB_OBJS_EXTRA}
${LINK_STATUS}
rm -f $@
out="$@"; \
objs=""; \
ars=""; \
for i in ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
mkdir -p $$dir; \
cd $$dir; \
${AR} x ../$$i; \
for j in *.o; do \
objs="$$objs $$dir/$$j"; \
done; \
cd ..; \
done; \
if ${AR} cr $@ $$objs && ${RANLIB} $@; then \
${LINK_OK}; \
else \
rm -f $@; false; \
${LINK_FAILED}; \
fi; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
done
locales: ${MO_FILES}
.c.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} ${DEP_CFLAGS} \
-c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.c.lib.o:
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} \
${DEP_CFLAGS} -c -o $@ $<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.c.amigalib.o:
${COMPILE_AMIGA_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${AMIGA_LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \
${CFLAGS_$@} ${DEP_CFLAGS} -c -o $@ $<; then \
${COMPILE_AMIGA_LIB_OK}; \
else \
${COMPILE_AMIGA_LIB_FAILED}; \
fi
.c.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${PLUGIN_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \
${CFLAGS_$@} ${DEP_CFLAGS} -c -o $@ $<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
fi
.cc.o .cxx.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} ${CXXFLAGS_$@} \
${DEP_CXXFLAGS} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.cc.lib.o .cxx.lib.o:
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${CXX} ${LIB_CFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} \
${CXXFLAGS_$@} ${DEP_CXXFLAGS} -c -o $@ $<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.cc.amigalib.o .cxx.amigalib.o:
${COMPILE_AMIGA_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${CXX} ${AMIGA_LIB_CFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} \
${CXXFLAGS_$@} ${DEP_CXXFLAGS} -c -o $@ $<; then \
${COMPILE_AMIGA_LIB_OK}; \
else \
${COMPILE_AMIGA_LIB_FAILED}; \
fi
.cc.plugin.o .cxx.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${CXX} ${PLUGIN_CFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} \
${CXXFLAGS_$@} ${DEP_CXXFLAGS} -c -o $@ $<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
fi
.d.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if test x"$(basename ${DC})" = x"dmd"; then \
if ${DC} ${DFLAGS} -c -of$@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi \
else \
if ${DC} ${DFLAGS} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi \
fi
.erl.beam:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${ERLC} ${ERLCFLAGS} -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.java.class:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${JAVAC} ${JAVACFLAGS} $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.m.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$<} ${OBJCFLAGS_$@} \
${DEP_OBJCFLAGS} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.m.lib.o:
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJC} ${LIB_CFLAGS} ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$<} \
${OBJCFLAGS_$@} ${DEP_OBJCFLAGS} -c -o $@ $<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.m.amigalib.o:
${COMPILE_AMIGA_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJC} ${AMIGA_LIB_CFLAGS} ${OBJCFLAGS} ${CPPFLAGS} \
${OBJCFLAGS_$<} ${OBJCFLAGS_$@} ${DEP_OBJCFLAGS} -c -o $@ $<; then \
${COMPILE_AMIGA_LIB_OK}; \
else \
${COMPILE_AMIGA_LIB_FAILED}; \
fi
.m.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${OBJC} ${PLUGIN_CFLAGS} ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$<} \
${OBJCFLAGS_$@} ${DEP_OBJCFLAGS} -c -o $@ $<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
fi
.mm.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${OBJCXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$<} \
${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.mm.lib.o:
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${LIB_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} \
${OBJCXXFLAGS_$<} ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ \
$<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.mm.amigalib.o:
${COMPILE_AMIGA_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${AMIGA_LIB_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} \
${OBJCXXFLAGS_$<} ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ \
$<; then \
${COMPILE_AMIGA_LIB_OK}; \
else \
${COMPILE_AMIGA_LIB_FAILED}; \
fi
.mm.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${OBJCXX} ${PLUGIN_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} \
${OBJCXXFLAGS_$<} ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ \
$<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
fi
.po.mo:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${MSGFMT} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.py.pyc:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${PYTHON} ${PYTHON_FLAGS} -c \
"import py_compile; py_compile.compile('$<')"; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.rc.o .rc.lib.o .rc.plugin.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${RC} ${RCFLAGS} ${CPPFLAGS} -J rc -O coff -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.S.o .S.amigalib.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${AS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$<} ${ASFLAGS_$@} \
${DEP_ASFLAGS} -c -o $@ $<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.S.lib.o:
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${AS} ${LIB_CFLAGS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$<} \
${ASFLAGS_$@} ${DEP_ASFLAGS} -c -o $@ $<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.S.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${AS} ${PLUGIN_CFLAGS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$<} \
${ASFLAGS_$@} ${DEP_ASFLAGS} -c -o $@ $<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
fi
.xpm.o:
${COMPILE_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} -x c -c -o $@ \
$<; then \
${COMPILE_OK}; \
else \
${COMPILE_FAILED}; \
fi
.xpm.lib.o:
${COMPILE_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} \
-x c -c -o $@ $<; then \
${COMPILE_LIB_OK}; \
else \
${COMPILE_LIB_FAILED}; \
fi
.xpm.amigalib.o:
${COMPILE_AMIGA_LIB_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${AMIGA_LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \
${CFLAGS_$@} -x c -c -o $@ $<; then \
${COMPILE_AMIGA_LIB_OK}; \
else \
${COMPILE_AMIGA_LIB_FAILED}; \
fi
.xpm.plugin.o:
${COMPILE_PLUGIN_STATUS}
in="$<"; \
out="$@"; \
if ${CC} ${PLUGIN_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \
${CFLAGS_$@} -x c -c -o $@ $<; then \
${COMPILE_PLUGIN_OK}; \
else \
${COMPILE_PLUGIN_FAILED}; \
fi
install: all install-extra
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
${MAKE} @MAKEFLAGS_SILENT@ install || exit $$?; \
${DIR_LEAVE}; \
done
for i in "" ${SHARED_LIB}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} ${DESTDIR}${libdir} @INSTALL_LIB@; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${FRAMEWORK}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
rm -fr ${DESTDIR}${prefix}/Library/Frameworks/$$i; \
if ${MKDIR_P} ${DESTDIR}${prefix}/Library/Frameworks && \
cp -R $$i ${DESTDIR}${prefix}/Library/Frameworks/; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${AMIGA_LIB}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} ${DESTDIR}${amigalibdir} && \
${INSTALL} -m 755 $$i ${DESTDIR}${amigalibdir}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${STATIC_LIB} ${STATIC_PIC_LIB} ${STATIC_AMIGA_LIB}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} ${DESTDIR}${libdir} && \
${INSTALL} -m 644 $$i ${DESTDIR}${libdir}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${PLUGIN}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} ${DESTDIR}${plugindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${BUNDLE}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
rm -fr ${DESTDIR}${bundledir}/$$i; \
if ${MKDIR_P} ${DESTDIR}${bundledir} && \
cp -R $$i ${DESTDIR}${bundledir}/; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${DATA}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} $$(dirname \
${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i) && \
${INSTALL} -m 644 $$i \
${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${PROG}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} ${DESTDIR}${bindir} && \
${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
if test x"${INSTALL_INCLUDES}" = x"yes"; then \
for i in "" ${INCLUDES}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
if ${MKDIR_P} $$(dirname \
${DESTDIR}${includedir}/${includesubdir}/$$i) && \
${INSTALL} -m 644 $$i \
${DESTDIR}${includedir}/${includesubdir}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done \
fi
for i in "" ${MO_FILES}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
dest="${localedir}/$${i%.mo}/LC_MESSAGES/${localename}.mo"; \
dest="${DESTDIR}$$dest"; \
if ${MKDIR_P} ${DESTDIR}${localedir}/$${i%.mo}/LC_MESSAGES && \
${INSTALL} -m 644 $$i $$dest; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in "" ${MAN}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
dest="${DESTDIR}${mandir}/${mansubdir}/$$i"; \
if ${MKDIR_P} ${DESTDIR}${mandir}/${mansubdir} && \
${INSTALL} -m 644 $$i $$dest; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
install-extra:
uninstall:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
${MAKE} @MAKEFLAGS_SILENT@ uninstall || exit $$?; \
${DIR_LEAVE}; \
done
for i in "" ${SHARED_LIB}; do \
test x"$$i" = x"" && continue; \
if test -f ${DESTDIR}${libdir}/$$i \
-o -f ${DESTDIR}${bindir}/$$i; then \
if : @UNINSTALL_LIB@; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi; \
done
for i in "" ${FRAMEWORK}; do \
test x"$$i" = x"" && continue; \
if test -d ${DESTDIR}${prefix}/Library/Frameworks/$$i; then \
if rm -fr ${DESTDIR}${prefix}/Library/Frameworks/$$i; \
then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
rmdir ${DESTDIR}${prefix}/Library/Frameworks >/dev/null 2>&1 || true
rmdir ${DESTDIR}${prefix}/Library >/dev/null 2>&1 || true
for i in "" ${STATIC_LIB} ${STATIC_PIC_LIB} ${STATIC_AMIGA_LIB}; do \
test x"$$i" = x"" && continue; \
if test -f ${DESTDIR}${libdir}/$$i; then \
if rm -f ${DESTDIR}${libdir}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
for i in "" ${PLUGIN}; do \
test x"$$i" = x"" && continue; \
if test -e ${DESTDIR}${plugindir}/$$i; then \
if rm -f ${DESTDIR}${plugindir}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
rmdir ${DESTDIR}${plugindir} >/dev/null 2>&1 || true
for i in "" ${BUNDLE}; do \
test x"$$i" = x"" && continue; \
if test -d ${DESTDIR}${bundledir}/$$i; then \
if rm -fr ${DESTDIR}${bundledir}/$$i; \
then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
rmdir ${DESTDIR}${bundledir} >/dev/null 2>&1 || true
rmdir ${DESTDIR}${prefix}/Library >/dev/null 2>&1 || true
for i in "" ${DATA}; do \
test x"$$i" = x"" && continue; \
if test -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \
if rm -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; \
then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi; \
rmdir "$$(dirname ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i)" \
>/dev/null 2>&1 || true; \
done
rmdir ${DESTDIR}${datadir}/${PACKAGE_NAME} >/dev/null 2>&1 || true
for i in "" ${PROG}; do \
test x"$$i" = x"" && continue; \
if test -f ${DESTDIR}${bindir}/$$i; then \
if rm -f ${DESTDIR}${bindir}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
for i in "" ${INCLUDES}; do \
test x"$$i" = x"" && continue; \
if test -f ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
if rm -f ${DESTDIR}${includedir}/${includesubdir}/$$i; \
then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
rmdir ${DESTDIR}${includedir}/${includesubdir} >/dev/null 2>&1 || true
for i in "" ${MO_FILES}; do \
test x"$$i" = x"" && continue; \
mo="${localedir}/$${i%.mo}/LC_MESSAGES/${localename}.mo"; \
mo="${DESTDIR}$$mo"; \
if test -f $$mo; then \
if rm -f $$mo; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
for i in "" ${MAN}; do \
test x"$$i" = x"" && continue; \
if test -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
if rm -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
${MAKE} @MAKEFLAGS_SILENT@ uninstall-extra
uninstall-extra:
clean:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
${MAKE} @MAKEFLAGS_SILENT@ clean || exit $$?; \
${DIR_LEAVE}; \
done
: >.deps
for i in "" ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} \
${LIB_OBJS_EXTRA} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_START} \
${AMIGA_LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} \
${SHARED_LIB} ${SHARED_LIB_NOINST} ${AMIGA_LIB} \
${AMIGA_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} \
${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${STATIC_AMIGA_LIB} \
${STATIC_AMIGA_LIB_NOINST} ${FRAMEWORK} ${FRAMEWORK_NOINST} \
${PLUGIN} ${PLUGIN_NOINST} ${BUNDLE} ${BUNDLE_NOINST} \
${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \
test x"$$i" = x"" && continue; \
if test -f $$i -o -d $$i; then \
if rm -fr $$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
distclean: clean
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
${MAKE} @MAKEFLAGS_SILENT@ distclean || exit $$?; \
${DIR_LEAVE}; \
done
for i in "" ${DISTCLEAN} .deps *~; do \
test x"$$i" = x"" && continue; \
if test -f $$i -o -d $$i; then \
if rm -fr $$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
print-hierarchy:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
echo ${PRINT_HIERARCHY_PREFIX}$$i; \
cd $$i || exit $$?; \
${MAKE} @MAKEFLAGS_SILENT@ PRINT_HIERARCHY_PREFIX=$$i/ \
print-hierarchy || exit $$?; \
cd .. || exit $$?; \
done
print-var:
printf '%s\n' '${${VAR}}'
DIR_ENTER = printf "@TERM_EL@@TERM_SETAF6@Entering directory @TERM_SETAF14@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF6@.@TERM_SGR0@\n" "$$i"; cd $$i || exit $$?
DIR_LEAVE = printf "@TERM_EL@@TERM_SETAF6@Leaving directory @TERM_SETAF14@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF6@.@TERM_SGR0@\n" "$$i"; cd .. || exit $$?
COMPILE_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_SETAF11@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@...@TERM_SGR0@\r" "$<"
COMPILE_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_SETAF10@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@.@TERM_SGR0@\n" "$<"
COMPILE_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_SETAF9@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@!@TERM_SGR0@\n" "$<"; exit $$err
COMPILE_LIB_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_SETAF11@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@ (lib)...@TERM_SGR0@\r" "$<"
COMPILE_LIB_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_SETAF10@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@ (lib).@TERM_SGR0@\n" "$<"
COMPILE_LIB_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_SETAF9@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@ (lib)!@TERM_SGR0@\n" "$<"; exit $$err
COMPILE_AMIGA_LIB_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_SETAF11@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@ (Amiga lib)...@TERM_SGR0@\r" "$<"
COMPILE_AMIGA_LIB_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_SETAF10@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@ (Amiga lib).@TERM_SGR0@\n" "$<"
COMPILE_AMIGA_LIB_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_SETAF9@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@ (Amiga lib)!@TERM_SGR0@\n" "$<"; exit $$err
COMPILE_PLUGIN_STATUS = printf "@TERM_EL@@TERM_SETAF3@Compiling @TERM_SETAF11@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@ (plugin)...@TERM_SGR0@\r" "$<"
COMPILE_PLUGIN_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully compiled @TERM_SETAF10@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@ (plugin).@TERM_SGR0@\n" "$<"
COMPILE_PLUGIN_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to compile @TERM_SETAF9@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@ (plugin)!@TERM_SGR0@\n" "$<"; exit $$err
LINK_STATUS = printf "@TERM_EL@@TERM_SETAF3@Linking @TERM_SETAF11@@TERM_BOLD@$@@TERM_SGR0@@TERM_SETAF3@...@TERM_SGR0@\r"
LINK_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully linked @TERM_SETAF10@@TERM_BOLD@$@@TERM_SGR0@@TERM_SETAF2@.@TERM_SGR0@\n"
LINK_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to link @TERM_SETAF9@@TERM_BOLD@$@@TERM_SGR0@@TERM_SETAF1@!@TERM_SGR0@\n"; exit $$err
INSTALL_STATUS = printf "@TERM_EL@@TERM_SETAF3@Installing @TERM_SETAF11@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF3@...@TERM_SGR0@\r" "$$i"
INSTALL_OK = printf "@TERM_EL@@TERM_SETAF2@Successfully installed @TERM_SETAF10@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF2@.@TERM_SGR0@\n" "$$i"
INSTALL_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to install @TERM_SETAF9@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@!@TERM_SGR0@\n" "$$i"; exit $$err
DELETE_OK = printf "@TERM_EL@@TERM_SETAF4@Deleted @TERM_SETAF12@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF4@.@TERM_SGR0@\n" "$$i"
DELETE_FAILED = err=$$?; printf "@TERM_EL@@TERM_SETAF1@Failed to delete @TERM_SETAF9@@TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF1@!@TERM_SGR0@\n" "$$i"; exit $$err
.CURDIR ?= .
-include ${.CURDIR}/.deps
objfw-1.3/configure.ac 100644 001750 001750 00000201751 14767513633 014032 0 ustar 00js js 000000 000000 AC_INIT(ObjFW, 1.3, js@nil.im, objfw, https://objfw.nil.im/)
AC_CONFIG_SRCDIR(src)
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_MACRO_DIR(build-aux/m4)
objfw_version_major=1
objfw_version_minor=3
AC_DEFINE_UNQUOTED(OBJFW_VERSION_MAJOR, $objfw_version_major,
[The major version of ObjFW])
AC_DEFINE_UNQUOTED(OBJFW_VERSION_MINOR, $objfw_version_minor,
[The minor version of ObjFW])
dnl This may only be set to 1.4 once 1.4 is released
AC_SUBST(BUNDLE_VERSION, 1.3.0)
AC_SUBST(BUNDLE_SHORT_VERSION, 1.3)
for i in configure.ac build-aux/m4/*; do
AS_IF([test $i -nt configure], [
AC_MSG_ERROR([$i is newer than configure! Run ./autogen.sh!])
])
done
BUILDSYS_INIT
AC_CANONICAL_HOST
dnl Used to disable checking for -pedantic on some platforms where it's broken
check_pedantic="yes"
case "$host" in
arm-*-riscos*)
AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"])
flags="-mfloat-abi=softfp -mfpu=vfp -mlibscl"
ASFLAGS="$ASFLAGS -mfloat-abi=softfp -mfpu=vfp"
OBJCFLAGS="$OBJCFLAGS $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
LDFLAGS="$LDFLAGS $flags"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS $flags"
enable_shared="no"
enable_threads="no"
enable_sockets="no"
enable_files="no"
;;
m68k-*-amigaos*)
AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O0 -g"])
OBJCFLAGS="$OBJCFLAGS -noixemul"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
CPPFLAGS="$CPPFLAGS -D__NO_NET_API"
LDFLAGS="$LDFLAGS -noixemul"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -noixemul"
LIBS="$LIBS -ldebug"
OBJFW_LIBS="$OBJFW_LIBS -ldebug"
enable_files="yes" # Required for reading ENV:
enable_shared="no"
with_tls="no"
AC_SUBST(LIBBASES_M, libbases.m)
;;
powerpc-*-amigaos*)
CPPFLAGS="$CPPFLAGS -D__USE_INLINE__"
enable_files="yes" # Required for reading ENV:
enable_shared="no"
with_tls="no"
AC_SUBST(LIBBASES_M, libbases.m)
;;
*-morphos*)
AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"])
OBJCFLAGS="$OBJCFLAGS -noixemul"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
LDFLAGS="$LDFLAGS -noixemul"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -noixemul"
LIBS="$LIBS -ldebug"
OBJFW_LIBS="$OBJFW_LIBS -ldebug"
enable_files="yes" # Required for reading ENV:
enable_shared="no"
AC_SUBST(LIBBASES_M, libbases.m)
;;
*-msdosdjgpp*)
enable_shared="no"
enable_threads="no"
enable_sockets="no"
;;
*-*-mingw*)
LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -Wl,--allow-multiple-definition"
LIBS="$LIBS -lversion"
OBJFW_LIBS="$OBJFW_LIBS -lversion"
AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}')
;;
*-psp-*)
AS_IF([test x"$DEVKITPSP" = x""], [
AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.])
])
AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"])
OBJCFLAGS="$OBJCFLAGS -G0"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -G0"
CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include"
LDFLAGS="$LDFLAGS -G0"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -G0"
tmp="-L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay -lpspge -lpspctrl"
tmp="$tmp -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl"
tmp="$tmp -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lgcc"
tmp="$tmp -lpsplibc"
LIBS="$LIBS $tmp"
OBJFW_LIBS="$OBJFW_LIBS $tmp"
enable_shared="no"
enable_threads="no" # TODO
enable_sockets="no" # TODO
check_pedantic="no"
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
;;
hppa*-*-hpux*)
dnl Don't default to -g: It creates errors from the assembler and breaks
dnl exceptions.
AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"])
dnl HP-UX 11.11's inttypes.h defines UINTPTR_MAX etc. to nothing. GCC's
dnl stdint.h defines those correctly, but if inttypes.h gets included
dnl after something included stdint.h, it gets broken again. Therefore,
dnl always include inttypes.h as the very first thing.
dnl We need to put this into OBJCFLAGS and not CPPFLAGS as CPPFLAGS are
dnl also used for .S files.
OBJCFLAGS="$OBJCFLAGS -include inttypes.h"
dnl We need -latomic for GCC's atomics to work.
LIBS="$LIBS -latomic"
OBJFW_LIBS="$OBJFW_LIBS -latomic"
;;
*-*-mint*)
enable_shared="no"
enable_threads="no" # TODO
with_tls="no"
;;
*-apple-macos*)
enable_shared="no"
enable_threads="no" # TODO
enable_sockets="no" # TODO
AC_DEFINE(OF_CLASSIC_MACOS, 1,
[Whether we are compiling for classic macOS])
;;
esac
AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [
dnl Hack to make configure find these on DOS.
: ${AR:=ar.exe}
: ${GREP:=grep.exe}
: ${RANLIB:=ranlib.exe}
])
AC_LANG([Objective C])
case "$host_os" in
morphos*)
dnl Don't use clang on MorphOS - it does not support baserel, which is
dnl required for the .library.
potential_compilers="gcc"
;;
*)
potential_compilers="clang egcc gcc"
;;
esac
AC_PROG_OBJC($potential_compilers)
AC_PROG_OBJCPP
AC_PROG_EGREP
AC_PROG_SED
AC_PROG_LN_S
BUILDSYS_CHECK_IOS
AC_ARG_WITH(wii,
AS_HELP_STRING([--with-wii], [build for Wii]))
AS_IF([test x"$with_wii" = x"yes"], [
AS_IF([test x"$DEVKITPRO" = x""], [
AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.])
])
flags="-mrvl -mcpu=750 -meabi -mhard-float"
OBJCFLAGS="$OBJCFLAGS $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
CPPFLAGS="$CPPFLAGS -DGEKKO -I$DEVKITPRO/libogc/include"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include"
LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
OBJFW_LIBS="$OBJFW_LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
HID_STATIC_LIBS="-lwiiuse -lbte $HID_LIBS"
HID_LIBS="-lwiiuse -lbte $HID_LIBS"
enable_shared="no"
enable_threads="no" # TODO
with_tls="no"
AC_DEFINE(OF_WII, 1, [Whether we are compiling for Wii])
AC_SUBST(USE_SRCS_WII, '${SRCS_WII}')
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])
AC_ARG_WITH(wii-u,
AS_HELP_STRING([--with-wii-u], [build for Wii U]))
AS_IF([test x"$with_wii_u" = x"yes"], [
AS_IF([test x"$DEVKITPRO" = x""], [
AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.])
])
flags="-mcpu=750 -meabi -mhard-float"
OBJCFLAGS="$OBJCFLAGS $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
CPPFLAGS="-isystem $DEVKITPRO/wut/include -D__WIIU__ -D__WUT__"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -isystem \$DEVKITPRO/wut/include"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__WIIU__ -D__WUT__"
LDFLAGS="$LDFLAGS -specs=$DEVKITPRO/wut/share/wut.specs"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -specs=$DEVKITPRO/wut/share/wut.specs"
tmp="-L$DEVKITPRO/wut/lib -L$DEVKITPRO/wut/lib/stubs -lwut"
LIBS="$LIBS $tmp"
OBJFW_LIBS="$OBJFW_LIBS $tmp"
enable_files="no" # TODO
enable_shared="no" # TODO
enable_threads="no" # TODO
enable_sockets="no" # TODO
AC_DEFINE(OF_WII_U, 1, [Whether we are compiling for Wii U])
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
# Repetition of libraries is required for Wii U, as otherwise it cannot
# find main. Just moving -lobjfwtest later doesn't work either, as then
# the linker cannot find ObjFW symbols. So the only solution is to list
# everything twice, but hide it behind a variable because listing it
# twice causes a warning on macOS.
AC_SUBST(WII_U_TESTS_LIBS, '-lobjfwtest ${TESTS_LIBS} ${LIBS}')
])
AC_ARG_WITH(nds,
AS_HELP_STRING([--with-nds], [build for Nintendo DS]))
AS_IF([test x"$with_nds" = x"yes"], [
AS_IF([test x"$DEVKITPRO" = x""], [
AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.])
])
flags="-march=armv5te -mtune=arm946e-s -mthumb -mthumb-interwork"
OBJCFLAGS="$OBJCFLAGS $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
CPPFLAGS="$CPPFLAGS -DARM9 -D__NDS__ -I$DEVKITPRO/libnds/include"
CPPFLAGS="$CPPFLAGS -I$DEVKITPRO/calico/include"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM9 -D__NDS__"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -I\$DEVKITPRO/libnds/include"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -I\$DEVKITPRO/calico/include"
ASFLAGS="$ASFLAGS -march=armv5te"
LDFLAGS="$LDFLAGS -specs=$DEVKITPRO/calico/share/ds9.specs"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -specs=\$DEVKITPRO/calico/share/ds9.specs"
LIBS="$LIBS -L$DEVKITPRO/libnds/lib -L$DEVKITPRO/calico/lib"
LIBS="$LIBS -lfilesystem -lfat -lnds9 -lcalico_ds9"
OBJFW_LIBS="$OBJFW_LIBS -L\$DEVKITPRO/libnds/lib"
OBJFW_LIBS="$OBJFW_LIBS -L\$DEVKITPRO/calico/lib"
OBJFW_LIBS="$OBJFW_LIBS -lfilesystem -lfat -lnds9 -lcalico_ds9"
enable_shared="no"
enable_threads="no" # TODO
enable_sockets="no" # TODO
check_pedantic="no"
AC_DEFINE(OF_NINTENDO_DS, 1, [Whether we are compiling for Nintendo DS])
AC_SUBST(USE_SRCS_NINTENDO_DS, '${SRCS_NINTENDO_DS}')
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])
AC_ARG_WITH(3ds,
AS_HELP_STRING([--with-3ds], [build for Nintendo 3DS]))
AS_IF([test x"$with_3ds" = x"yes"], [
AS_IF([test x"$DEVKITPRO" = x""], [
AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.])
])
flags="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft"
flags="$flags -mword-relocations"
OBJCFLAGS="$OBJCFLAGS $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
CPPFLAGS="$CPPFLAGS -DARM11 -I$DEVKITPRO/libctru/include"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM11 -I\$DEVKITPRO/libctru/include"
ASFLAGS="$ASFLAGS -march=armv6k"
tmp="-specs=3dsx.specs -march=armv6k -mtune=mpcore -mfloat-abi=hard"
tmp="$tmp -mtp=soft -mword-relocations"
LDFLAGS="$LDFLAGS $tmp"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS $tmp"
LIBS="$LIBS -L$DEVKITPRO/libctru/lib -lctru"
OBJFW_LIBS="$OBJFW_LIBS -L$DEVKITPRO/libctru/lib -lctru"
enable_shared="no"
enable_threads="no" # TODO
with_tls="no"
check_pedantic="no"
AC_DEFINE(OF_NINTENDO_3DS, 1,
[Whether we are compiling for Nintendo 3DS])
AC_SUBST(USE_SRCS_NINTENDO_3DS, '${SRCS_NINTENDO_3DS}')
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])
AC_ARG_WITH(nintendo-switch,
AS_HELP_STRING([--with-nintendo-switch], [build for Nintendo Switch]))
AS_IF([test x"$with_nintendo_switch" = x"yes"], [
AS_IF([test x"$DEVKITPRO" = x""], [
AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.])
])
flags="-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE"
OBJCFLAGS="$OBJCFLAGS $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
CPPFLAGS="$CPPFLAGS -D__SWITCH__ -I$DEVKITPRO/libnx/include"
OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__SWITCH__ -I$DEVKITPRO/libnx/include"
ASFLAGS="$ASFLAGS $flags"
LDFLAGS="$LDFLAGS -specs=$DEVKITPRO/libnx/switch.specs $flags"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -specs=$DEVKITPRO/libnx/switch.specs"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS $flags"
LIBS="$LIBS -L$DEVKITPRO/libnx/lib -lnx"
OBJFW_LIBS="$OBJFW_LIBS -L$DEVKITPRO/libnx/lib -lnx"
enable_shared="no"
enable_threads="yes"
enable_sockets="no" # TODO
check_pedantic="no"
AC_DEFINE(OF_NINTENDO_SWITCH, 1,
[Whether we are compiling for Nintendo Switch])
AC_SUBST(USE_SRCS_NINTENDO_SWITCH, '${SRCS_NINTENDO_SWITCH}')
])
CPP="$OBJCPP"
CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS -DOF_COMPILING_OBJFW"
flags="-fexceptions -fobjc-exceptions -funwind-tables"
flags="$flags -fconstant-string-class=OFConstantString"
OBJCFLAGS="$OBJCFLAGS -Wall $flags"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
dnl amiga-gcc requires -fexceptions in LDFLAGS in order to link in the glue code
dnl for registering the frames.
LDFLAGS="$LDFLAGS -fexceptions"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -fexceptions"
case "$OBJC" in
*clang*)
case "$host" in
mips*-*-*)
dnl Clang generates MIPS assembly not accepted by GNU as,
dnl however, Clang's integrated assembler doesn't accept
dnl everything used in ObjFW's assembly files. Therefore, use
dnl the integrated assembler for ObjC files, but not for
dnl assembly files.
ASFLAGS="$ASFLAGS -no-integrated-as"
OBJCFLAGS="$OBJCFLAGS -integrated-as"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -integrated-as"
;;
i?86-*-darwin* | x86_64-*-darwin*)
dnl Don't use -no-integrated-as on Darwin. It breaks building
dnl for the iOS simulator.
;;
sparc64-*-*openbsd*)
dnl Clang generates assembly output on SPARC64 that OpenBSD's
dnl assembler does not accept.
flag="-integrated-as"
OBJCFLAGS="$OBJCFLAGS $flag"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
;;
esac
;;
esac
AX_CHECK_COMPILER_FLAGS(-std=gnu11, [
OBJCFLAGS="$OBJCFLAGS -std=gnu11"
], [
AX_CHECK_COMPILER_FLAGS(-std=gnu1x, [
OBJCFLAGS="$OBJCFLAGS -std=gnu1x"
], [
AX_CHECK_COMPILER_FLAGS(-std=gnu99,
[OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
])
])
AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-cfstrings, [
flag="-Xclang -fno-constant-cfstrings"
OBJCFLAGS="$OBJCFLAGS $flag"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
])
AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-nsnumber-literals, [
flag="-Xclang -fno-constant-nsnumber-literals"
OBJCFLAGS="$OBJCFLAGS $flag"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
])
AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-nsarray-literals, [
flag="-Xclang -fno-constant-nsarray-literals"
OBJCFLAGS="$OBJCFLAGS $flag"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
])
AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-nsdictionary-literals, [
flag="-Xclang -fno-constant-nsdictionary-literals"
OBJCFLAGS="$OBJCFLAGS $flag"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
])
AX_CHECK_COMPILER_FLAGS([-Wsign-compare -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wsign-compare"])
AS_IF([test x"$with_nds" != x"yes"], [
AX_CHECK_COMPILER_FLAGS([-Wshadow -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wshadow"])
])
AX_CHECK_COMPILER_FLAGS([-Wshorten-64-to-32 -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wshorten-64-to-32"])
AX_CHECK_COMPILER_FLAGS([-Wundeclared-selector -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wundeclared-selector"])
AX_CHECK_COMPILER_FLAGS([-Wsemicolon-before-method-body -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wsemicolon-before-method-body"])
AX_CHECK_COMPILER_FLAGS([-Wobjc-missing-property-synthesis -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wobjc-missing-property-synthesis"])
AX_CHECK_COMPILER_FLAGS([-Wmissing-method-return-type -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wmissing-method-return-type"])
AS_IF([test x"$host_cpu" = x"powerpc64"], [
dnl Buggy warning in both GCC and Clang on PowerPC 64!
dnl But only in big endian mode.
AX_CHECK_COMPILER_FLAGS([-Wno-overlength-strings -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wno-overlength-strings"])
])
case "$host" in
m68k-*-amigaos*)
dnl The inline headers generate code that triggers -Wpointer-sign.
OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign"
;;
esac
AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Foo
{
id bar;
}
@property (nonatomic, retain) id bar;
@end
], [[
Foo *foo = (id)0;
[foo setBar: (id)0];
foo = [foo bar];
]])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR(Compiler does not support properties!)
])
AC_CHECK_TOOL(AR, ar)
AC_PROG_RANLIB
case "$host_os" in
mingw*)
AC_CHECK_TOOL(RC, windres)
;;
esac
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
BUILDSYS_PLUGIN
AC_SUBST(OBJFW_SHARED_LIB, '${LIB_PREFIX}objfw${LIB_SUFFIX}')
AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a")
AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a")
AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a")
AC_SUBST(OBJFWHID_SHARED_LIB, '${LIB_PREFIX}objfwhid${LIB_SUFFIX}')
BUILDSYS_FRAMEWORK([
AC_SUBST(OBJFW_FRAMEWORK, "ObjFW.framework")
AC_SUBST(OBJFWHID_FRAMEWORK, "ObjFWHID.framework")
build_framework="yes"
])
BUILDSYS_BUNDLE([
AC_SUBST(TESTPLUGIN_BUNDLE, "TestPlugin.bundle")
], [
AC_SUBST(TESTPLUGIN_PLUGIN, 'TestPlugin${PLUGIN_SUFFIX}')
])
], [
AC_DEFINE(OF_NO_SHARED, 1, [Whether no shared library was built])
AC_SUBST(LIBOBJFW_DEP, "../src/libobjfw.a")
AC_SUBST(LIBOBJFW_DEP_LVL2, "../../src/libobjfw.a")
AC_SUBST(LIBOBJFWHID_DEP, "../src/hid/libobjfwhid.a")
AC_SUBST(LIBOBJFWHID_DEP_LVL2, "../../src/hid/libobjfwhid.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
TESTS_LIBS="-framework ObjFW \${RUNTIME_FRAMEWORK_LIBS} $TESTS_LIBS"
TESTS_LIBS="-framework ObjFWHID \${HID_FRAMEWORK_LIBS} $TESTS_LIBS"
TESTS_LIBS="-F../src/hid -F../src/bridge $TESTS_LIBS"
TESTS_LIBS="-F../src -F../src/runtime $TESTS_LIBS"
], [
TESTS_LIBS="-lobjfw \${RUNTIME_LIBS} $TESTS_LIBS"
TESTS_LIBS="-lobjfwhid \${HID_LIBS} $TESTS_LIBS"
TESTS_LIBS="-L../src/hid -L../src/bridge $TESTS_LIBS"
TESTS_LIBS="-L../src -L../src/runtime $TESTS_LIBS"
])
AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library]))
AS_IF([test x"$enable_shared" = x"no"], [
enable_static="yes"
])
AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
AC_SUBST(EXCEPTIONS_A, "exceptions.a")
AC_SUBST(FORWARDING_A, "forwarding.a")
AC_SUBST(LOOKUP_ASM_A, "lookup-asm.a")
AC_SUBST(OBJFWHID_STATIC_LIB, "libobjfwhid.a")
])
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
AS_IF([test x"$enable_files" != x"no" -a x"$PLUGIN_SUFFIX" != x""], [
AC_SUBST(USE_SRCS_MODULES, '${SRCS_MODULES}')
AC_SUBST(TESTPLUGIN, "plugin")
AC_DEFINE(OF_HAVE_MODULES, 1, [Whether we have support for modules])
dnl Deprecated
AC_DEFINE(OF_HAVE_PLUGINS, 1, [Whether we have plugin support])
AC_CONFIG_FILES(tests/plugin/Info.plist)
AS_IF([test x"$build_framework" = x"yes"], [
TESTPLUGIN_LIBS="-F../../src -F../../src/runtime"
TESTPLUGIN_LIBS="$TESTPLUGIN_LIBS -framework ObjFW"
TESTPLUGIN_LIBS="$TESTPLUGIN_LIBS \${RUNTIME_FRAMEWORK_LIBS}"
], [
TESTPLUGIN_LIBS="-L../../src -L../../src/runtime"
TESTPLUGIN_LIBS="$TESTPLUGIN_LIBS -lobjfw \${RUNTIME_LIBS}"
])
AC_SUBST(TESTPLUGIN_LIBS)
])
AC_MSG_CHECKING(whether we need -D_GNU_SOURCE)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#if defined(__GLIBC__) || defined(__MINGW32__) || \
defined(__NEWLIB__) || defined(__MORPHOS__) || defined(__MINT__)
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 $CPPFLAGS"
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
gnu_source="yes"
], [
AC_MSG_RESULT(no)
])
case "$host_os" in
solaris*)
CPPFLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS"
;;
esac
objc_runtime="ObjFW runtime"
AC_CHECK_HEADER(objc/objc.h)
AC_MSG_CHECKING(which Objective C runtime to use)
AC_ARG_ENABLE(runtime,
AS_HELP_STRING([--enable-runtime], [use the included runtime]))
AC_ARG_ENABLE(seluid24,
AS_HELP_STRING([--enable-seluid24],
[use 24 bit instead of 16 bit for selector UIDs]))
AS_IF([test x"$enable_runtime" != x"yes"], [
AS_IF([test x"$ac_cv_header_objc_objc_h" = x"yes"], [
AC_EGREP_CPP(egrep_cpp_yes, [
#import
#ifdef OBJC_BOOL_DEFINED
egrep_cpp_yes
#endif
], [
objc_runtime="Apple runtime"
], [
dnl We don't want the GNU runtime
:
])
])
])
AC_MSG_RESULT($objc_runtime)
case "$objc_runtime" in
"ObjFW runtime")
AC_DEFINE(OF_OBJFW_RUNTIME, 1, [Whether we use the ObjFW runtime])
AC_SUBST(USE_SRCS_TAGGED_POINTERS, '${SRCS_TAGGED_POINTERS}')
runtime_name="objfw-${objfw_version_major}.${objfw_version_minor}"
runtime_flag="-fobjc-runtime=$runtime_name"
AC_MSG_CHECKING([whether $runtime_flag is supported])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Xclang $runtime_flag"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Test
+ (void)test;
@end
@implementation Test
+ (void)test
{
}
@end
void *
objc_msg_lookup(void *obj, void *sel)
{
return (void *)0;
}
void
__objc_exec_class(void *module)
{
}
], [[
[Test test];
]])
], [
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang $runtime_flag"
AC_MSG_RESULT(yes)
], [
OBJCFLAGS="$old_OBJCFLAGS -fgnu-runtime"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -fgnu-runtime"
AC_MSG_RESULT(no)
old_compiler="yes"
])
AC_SUBST(RUNTIME, "runtime")
AC_CONFIG_FILES(src/runtime/Info.plist)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWRT_SHARED_LIB,
'${LIB_PREFIX}objfwrt${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework")
AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT")
])
AC_SUBST(RUNTIME_LIBS, "-lobjfwrt")
AC_SUBST(RUNTIME_STATIC_LIBS, '${libdir}/libobjfwrt.a')
AS_IF([test x"$enable_shared" = x"no"], [
AC_SUBST(LIBOBJFWRT_DEP, "../src/runtime/libobjfwrt.a")
AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../../src/runtime/libobjfwrt.a")
])
AS_IF([test x"$enable_seluid24" = x"yes"], [
AC_DEFINE(OF_SELUID24, 1, [Whether to use 24 bit selector UIDs])
])
AC_MSG_CHECKING(for exception type)
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef __SEH__
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(SEH)
exception_type="SEH"
raise_exception="_Unwind_RaiseException"
], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef __USING_SJLJ_EXCEPTIONS__
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(SjLj)
exception_type="SjLj"
raise_exception="_Unwind_SjLj_RaiseException"
], [
AC_MSG_RESULT(DWARF)
exception_type="DWARF"
raise_exception="_Unwind_RaiseException"
])
])
AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc unwind], [
dnl c++abi requires pthread on OpenBSD
AS_IF([test x"$ac_lib" = x"c++abi"], [
LIBS="$LIBS -lpthread"
OBJFW_LIBS="$OBJFW_LIBS -lpthread"
])
], [
AC_MSG_ERROR([$raise_exception missing!])
], [-lpthread])
AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase)
;;
"Apple runtime")
AC_DEFINE(OF_APPLE_RUNTIME, 1, [Whether we use the Apple ObjC runtime])
AC_CHECK_LIB(objc, objc_msgSend, [
AC_SUBST(RUNTIME_LIBS, "-lobjc")
AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-lobjc")
AC_SUBST(RUNTIME_STATIC_LIBS, "-lobjc")
], [
AC_MSG_ERROR([libobjc not found!])
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -lobjc"
AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
dnl If we're using the Apple runtime and it doesn't have
dnl autorelease pools, we need to use the implementation from
dnl Foundation to make ObjFWBridge work. We can't use the
dnl ObjFWRT implementation as that would result in two parallel
dnl autorelease pool chains.
AC_SUBST(AUTORELEASE_FOUNDATION_M, "autorelease-foundation.m")
LIBS="-framework Foundation"
FRAMEWORK_LIBS="-framework Foundation"
])
AC_CHECK_FUNC(objc_constructInstance, [], [
AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m")
AC_DEFINE(OF_DECLARE_CONSTRUCT_INSTANCE, 1,
[Whether to declare objc_constructInstance])
])
AC_CHECK_FUNCS(objc_setAssociatedObject, [], [
AC_SUBST(RUNTIME_ASSOCIATION_M, "runtime/association.m")
AC_DEFINE(OF_DECLARE_SET_ASSOCIATED_OBJECT, 1,
[Whether to declare objc_setAssociatedObject])
])
OBJCFLAGS="$old_OBJCFLAGS"
;;
esac
case "$host_os" in
mint*)
dnl _Unwind_Backtrace crashes on MiNT
;;
hpux*)
dnl _Unwind_Backtrace() returns complete garbage on HP-UX.
;;
*)
AC_CHECK_FUNCS(_Unwind_Backtrace)
;;
esac
case "$host_os" in
darwin*)
AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjc"])
AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, ["-Wl,-reexport-lobjc"])
LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
])
AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [
AS_IF([test x"$exception_type" = x"DWARF"], [
tmp="-Wl,-U,___gxx_personality_v0"
LDFLAGS="$LDFLAGS $tmp"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS $tmp"
])
AS_IF([test x"$exception_type" = x"SjLj"], [
tmp="-Wl,-U,___gxx_personality_sj0"
LDFLAGS="$LDFLAGS $tmp"
OBJFW_LDFLAGS="$OBJFW_LDFLAGS $tmp"
])
AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjfwrt"])
AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK,
["-Wl,-reexport_framework,ObjFWRT"])
])
AC_CHECK_HEADERS(sysdir.h)
AC_CHECK_FUNCS(sysdir_start_search_path_enumeration)
AS_IF([test x"$host_is_ios" = x"yes"], [
AC_SUBST(TESTS_STATIC_LIB, tests.a)
TESTS_LIBS="$TESTS_LIBS -framework CoreFoundation"
])
;;
esac
AC_MSG_CHECKING(whether Objective C compiler supports ARC)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fobjc-arc -fobjc-arc-exceptions"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Foo
{
struct objc_class *_isa;
}
+ (id)alloc;
@end
@implementation Foo
+ (id)alloc
{
return (id)0;
}
@end
], [[
__weak id foo = [Foo alloc];
(void)foo;
]])
], [
AC_MSG_RESULT(yes)
AC_SUBST(RUNTIME_ARC_TESTS_M, RuntimeARCTests.m)
], [
AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"
AC_C_BIGENDIAN([
AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])
])
AS_IF([test x"$ac_cv_c_bigendian" = x"universal"], [
AC_DEFINE(OF_UNIVERSAL, 1, [Whether we are building a universal binary])
])
AC_MSG_CHECKING(for SSIZE_MAX)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#include
#ifdef SSIZE_MAX
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_DEFINE(SSIZE_MAX, [(SIZE_MAX / 2)], [Maximum value for ssize_t])
])
AC_MSG_CHECKING(for UINTPTR_MAX)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#include
#ifdef UINTPTR_MAX
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_CHECK_SIZEOF(uintptr_t)
AC_DEFINE(UINTPTR_MAX,
[(SIZEOF_UINTPTR_T * CHAR_BIT)], [Maximum value for uintptr_t])
])
AC_CHECK_HEADER(inttypes.h,
[AC_DEFINE(OF_HAVE_INTTYPES_H, 1, [Whether we have inttypes.h])])
AC_CHECK_HEADER(sys/types.h,
[AC_DEFINE(OF_HAVE_SYS_TYPES_H, 1, [Whether we have sys/types.h])])
AC_CHECK_HEADER(stdnoreturn.h,
[AC_DEFINE(OF_HAVE_STDNORETURN_H, 1, [Whether we have stdnoreturn.h])])
AC_CHECK_TYPE(wchar_t)
AC_CHECK_HEADER(wchar.h)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AS_IF([test x"$ac_cv_sizeof_float" != x"4" -o x"$ac_cv_sizeof_double" != x"8"],
[AC_MSG_ERROR(
[Floating point implementation does not conform to IEEE 754!])])
AC_MSG_CHECKING(for floating point endianess)
fp_endianess="unknown"
AS_IF([test x"$ac_cv_c_bigendian" != x"universal"], [
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259;
])
], [
AS_IF([$SED 's/[[^[:print:]]]//g' /dev/null], [
AC_DEFINE(OF_FLOAT_BIG_ENDIAN, 1,
[Whether floats are big endian])
fp_endianess="big endian"
], [
AS_IF([$SED 's/[[^[:print:]]]//g' \
/dev/null], [
fp_endianess="little endian"
])
])
])
], [
fp_endianess="universal"
])
AC_MSG_RESULT($fp_endianess)
AS_IF([test x"$fp_endianess" = x"unknown"], [
AC_MSG_ERROR(
[Floating point implementation does not conform to IEEE 754!])])
case "$host_cpu" in
arm* | earm*)
AC_MSG_CHECKING(for blx)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [
#if !defined(__arm64__) && !defined(__arch64__) && \
!defined(__ARM64_ARCH_8__)
__asm__ __volatile__ (
"blx r12"
);
#endif
])
], [
AC_DEFINE(HAVE_BLX, 1, [Whether we have blx])
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for VFP2 or above)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [
#if !defined(__arm64__) && !defined(__aarch64__) && \
!defined(__ARM64_ARCH_8__)
__asm__ __volatile__ (
"vstmdb sp!, {d0-d7}"
);
#endif
])
], [
AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above])
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
;;
aarch64* | arm64*)
AC_MSG_CHECKING(for bti)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [
__asm__ __volatile__ ("bti c");
])
], [
AC_DEFINE(HAVE_BTI, 1, [Whether we have bti])
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
;;
i?86 | x86_64)
AC_CHECK_HEADERS(cet.h)
;;
esac
AC_CHECK_LIB(m, fmod, [
LIBS="$LIBS -lm"
OBJFW_LIBS="$OBJFW_LIBS -lm"
])
AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex")
AC_CHECK_FUNCS(strtof truncf)
AC_CHECK_FUNC(asprintf, [
case "$host" in
*-*-mint*)
dnl asprintf is not in headers
have_asprintf="no"
;;
*-*-mingw*)
dnl asprintf from MinGW is broken on older Windows versions
have_asprintf="no"
;;
*-psp-*)
dnl asprintf is broken on the PSP
have_asprintf="no"
;;
*)
have_asprintf="yes"
AC_DEFINE(HAVE_ASPRINTF, 1, [Whether we have asprintf()])
;;
esac
], [
have_asprintf="no"
])
AC_ARG_ENABLE(unicode-tables,
AS_HELP_STRING([--disable-unicode-tables], [Disable Unicode tables]))
AS_IF([test x"$enable_unicode_tables" != x"no"], [
AC_DEFINE(OF_HAVE_UNICODE_TABLES, 1,
[Whether to build with Unicode tables])
AC_SUBST(UNICODE_M, "unicode.m")
])
ENCODINGS_SRCS=""
AC_DEFUN([ENCODING_FLAG], [
AC_ARG_ENABLE($1,
AS_HELP_STRING([--disable-$1],
[Disables support for $3]))
AS_IF([test x"$enable_$2" != x"no"], [
AC_DEFINE($4, 1, [Whether we have support for $3])
ENCODINGS_SRCS="$ENCODINGS_SRCS $1.m"
])
])
ENCODING_FLAG(codepage-437, codepage_437, [Codepage 437], HAVE_CODEPAGE_437)
ENCODING_FLAG(codepage-850, codepage_850, [Codepage 850], HAVE_CODEPAGE_850)
ENCODING_FLAG(codepage-852, codepage_852, [Codepage 852], HAVE_CODEPAGE_852)
ENCODING_FLAG(codepage-858, codepage_858, [Codepage 858], HAVE_CODEPAGE_858)
ENCODING_FLAG(iso-8859-2, iso_8859_2, [ISO 8859-2], HAVE_ISO_8859_2)
ENCODING_FLAG(iso-8859-3, iso_8859_3, [ISO 8859-3], HAVE_ISO_8859_3)
ENCODING_FLAG(iso-8859-15, iso_8859_15, [ISO 8859-15], HAVE_ISO_8859_15)
ENCODING_FLAG(koi8-r, koi8_r, [KOI8-R], HAVE_KOI8_R)
ENCODING_FLAG(koi8-u, koi8_u, [KOI8-U], HAVE_KOI8_U)
ENCODING_FLAG(mac-roman, mac_roman, [Mac Roman encoding], HAVE_MAC_ROMAN)
ENCODING_FLAG(windows-1250, windows_1250, [Windows-1250], HAVE_WINDOWS_1250)
ENCODING_FLAG(windows-1251, windows_1251, [Windows-1251], HAVE_WINDOWS_1251)
ENCODING_FLAG(windows-1252, windows_1252, [Windows-1252], HAVE_WINDOWS_1252)
AS_IF([test x"$ENCODINGS_SRCS" = x""], [
ENCODINGS_SRCS="dummy.m"
])
AC_SUBST(ENCODINGS_SRCS)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a")
])
AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
AC_SUBST(ENCODINGS_A, "encodings.a")
])
AC_CHECK_FUNCS(arc4random arc4random_buf getrandom random, break)
AS_IF([test x"$host_os" != x"morphos"], [
AC_CHECK_LIB(dl, dlopen, [
LIBS="$LIBS -ldl"
OBJFW_LIBS="$OBJFW_LIBS -ldl"
])
])
AC_CHECK_HEADERS_ONCE(dlfcn.h)
case "$host_os" in
netbsd*)
dnl dladdr exists on NetBSD, but it is completely broken.
dnl When using it with code that uses __thread, it freezes the process
dnl so that it has to be killed using SIGKILL.
dnl When disabling __thread, it doesn't freeze, but all symbols are
dnl wrong.
;;
*)
AC_CHECK_FUNCS(dladdr)
;;
esac
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_FUNCS(mmap mlock)
AC_ARG_ENABLE(threads,
AS_HELP_STRING([--disable-threads], [disable thread support]))
AS_IF([test x"$enable_threads" != x"no"], [
AC_MSG_CHECKING(for threads)
case "$host_os" in
amigaos* | morphos*)
AC_MSG_RESULT(Amiga)
have_amiga_threads="yes"
;;
mingw*)
AC_MSG_RESULT(WinAPI)
;;
*)
AC_MSG_RESULT(POSIX)
dnl Use -Wp, as we only use it for the preprocessor.
AX_CHECK_COMPILER_FLAGS([-Wp,-pthread], [
CPPFLAGS="$CPPFLAGS -Wp,-pthread"
], [
CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
])
AC_CHECK_LIB(pthread, main, [
LIBS="$LIBS -lpthread"
OBJFW_LIBS="$OBJFW_LIBS -lpthread"
])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include
], [
pthread_create(NULL, NULL, NULL, NULL);
])
], [], [
AC_MSG_ERROR(No supported threads found!)
])
AC_DEFINE(OF_HAVE_PTHREADS, 1, [Whether we have pthreads])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include
], [
pthread_mutexattr_t attr;
pthread_mutexattr_settype(&attr,
PTHREAD_MUTEX_RECURSIVE);
])
], [
AC_DEFINE(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES, 1,
[If pthread mutexes can be recursive])
])
AC_CHECK_FUNC(pthread_spin_lock, [
have_spinlocks="yes"
AC_DEFINE(OF_HAVE_PTHREAD_SPINLOCKS, 1,
[Whether we have pthread spinlocks])
])
AC_CHECK_FUNC(sched_yield, [
AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
[Whether we have sched_yield()])
])
AC_CHECK_FUNCS(pthread_attr_getschedpolicy)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(for pthread_attr_setinheritsched)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include
], [
pthread_attr_setinheritsched(
(pthread_attr_t *)-1, 0);
])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREAD_ATTR_SETINHERITSCHED, 1,
[Whether we have pthread_attr_setinheritsched])
], [
AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"
AC_CHECK_HEADERS(pthread_np.h, [], [], [#include ])
AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break)
;;
esac
AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads])
AC_SUBST(USE_SRCS_THREADS, '${SRCS_THREADS}')
AC_SUBST(OBJC_SYNC, objc_sync)
AC_ARG_ENABLE(compiler-tls,
AS_HELP_STRING([--disable-compiler-tls],
[disable compiler thread local storage]))
case "$host" in
aarch64*-*-android*)
dnl Compiler TLS is broken on AArch64 Android with Clang
enable_compiler_tls="no"
;;
m68k-*-amigaos* | powerpc-*-amigaos*)
dnl Compiler TLS is broken on AmigaOS
enable_compiler_tls="no"
;;
*-*-mingw*)
dnl Causes emutls to be pulled in, which pulls in winpthread.
enable_compiler_tls="no"
;;
*-*-morphos*)
dnl Compiler TLS needs helpers that we don't want in the
dnl .library
enable_compiler_tls="no"
;;
esac
AS_IF([test x"$enable_compiler_tls" != x"no"], [
AC_CHECK_HEADER(threads.h, [
AC_DEFINE(OF_HAVE_THREADS_H, 1,
[Whether we have threads.h])
])
AC_MSG_CHECKING(whether _Thread_local works)
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
static _Thread_local int x = 0;
], [
x++;
])
], [
AS_IF([test x"$enable_shared" != x"no"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fPIC"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
static _Thread_local int x = 0;
], [
x++;
])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE__THREAD_LOCAL, 1,
[Whether _Thread_local works])
have_thread_local="yes"
], [
AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE__THREAD_LOCAL, 1,
[Whether _Thread_local works])
have_thread_local="yes"
])
], [
AC_MSG_RESULT(no)
])
AS_IF([test x"$have_thread_local" != x"yes"], [
AC_MSG_CHECKING(whether __thread works)
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
/*
* It seems __thread is buggy with
* GCC 4.1 */
#if __GNUC__ == 4 && __GNUC_MINOR__ < 2
# error buggy
#endif
__thread int x = 0;
], [
x++;
])
], [
AS_IF([test x"$enable_shared" != x"no"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fPIC"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
__thread int x = 0;
], [
x++;
])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE___THREAD, 1,
[Whether __thread works]
)
], [
AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE___THREAD, 1,
[Whether __thread works])
])
], [
AC_MSG_RESULT(no)
])
])
])
atomic_ops="none"
AC_MSG_CHECKING(whether we have an atomic ops assembly implementation)
AC_EGREP_CPP(egrep_cpp_yes, [
#if defined(__GNUC__) && (defined(__i386__) || \
defined(__x86_64__) || defined(__amd64__)) || \
((defined(__ppc__) || defined(__PPC__) || \
defined(__powerpc__)) && !defined(__APPLE_CC__))
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
atomic_ops="assembly implementation"
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __atomic_* works)
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include
#include
], [
int32_t i, j;
if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED))
j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED);
while (!__atomic_compare_exchange_n(&i, &j, 1, false,
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
__atomic_thread_fence(__ATOMIC_SEQ_CST);
])
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && \
atomic_ops="__atomic_* builtins"
AC_DEFINE(OF_HAVE_ATOMIC_BUILTINS, 1,
[Whether __atomic_* builtins are available])
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __sync_* works)
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include
], [
int32_t i, j;
if (__sync_add_and_fetch(&i, 1))
j = __sync_sub_and_fetch(&i, 1);
while (!__sync_bool_compare_and_swap(&i, 0, 1));
])
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && \
atomic_ops="__sync_* builtins"
AC_DEFINE(OF_HAVE_SYNC_BUILTINS, 1,
[Whether __sync_* builtins are available])
], [
AC_MSG_RESULT(no)
])
AC_CHECK_HEADER(libkern/OSAtomic.h, [
test x"$atomic_ops" = x"none" && atomic_ops="libkern/OSAtomic.h"
AC_DEFINE(OF_HAVE_OSATOMIC, 1,
[Whether we have libkern/OSAtomic.h])
])
], [
dnl We can only have one thread - therefore everything is atomic
atomic_ops="not needed"
])
AC_MSG_CHECKING(for atomic operations)
AS_IF([test x"$atomic_ops" != x"none"], [
AC_DEFINE(OF_HAVE_ATOMIC_OPS, 1, [Whether we have atomic operations])
AC_SUBST(USE_INCLUDES_ATOMIC, '${INCLUDES_ATOMIC}')
])
AC_MSG_RESULT($atomic_ops)
AC_ARG_ENABLE(files,
AS_HELP_STRING([--disable-files], [disable file support]))
AS_IF([test x"$enable_files" != x"no"], [
AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files])
AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}')
AC_SUBST(OBJFW_NEW, "objfw-new")
AC_SUBST(OFARC, "ofarc")
AC_SUBST(OFHASH, "ofhash")
case "$host_os" in
msdosdjgpp*)
dnl DJGPP has the type, but it's not really usable.
;;
*)
AC_CHECK_TYPE(off64_t, [
AC_DEFINE(OF_HAVE_OFF64_T, 1, [Whether we have off64_t])
AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64])
])
;;
esac
AC_CHECK_HEADERS([pwd.h grp.h])
AC_CHECK_FUNC(chmod, [
AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()])
])
AC_CHECK_FUNC(chown, [
AC_DEFINE(OF_HAVE_CHOWN, 1, [Whether we have chown()])
])
AC_CHECK_FUNC(link, [
AC_DEFINE(OF_HAVE_LINK, 1, [Whether we have link()])
])
AC_CHECK_FUNC(symlink, [
AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()])
])
AC_CHECK_FUNCS([lstat lutimes utimensat])
AC_CHECK_MEMBERS([struct stat.st_birthtime], [], [], [
#include
])
])
AC_CHECK_HEADERS(dirent.h)
AC_CHECK_FUNCS([sysconf clock_gettime gmtime_r localtime_r])
case "$host_os" in
amigaos* | morphos*)
dnl We don't want fcntl() or nanosleep() on AmigaOS / MorphOS, despite
dnl a symbol existing. The reason is that we cannot use fcntl() for
dnl sockets and that nanosleep() is yet another function that uses
dnl errno, so would need to be passed from the linklib.
;;
*)
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_FUNCS([fcntl nanosleep])
;;
esac
AC_CHECK_HEADERS(xlocale.h)
AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l uselocale])
AS_IF([test x"$gnu_source" != x"yes" -a \( \
x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \
x"$ac_cv_func_asprintf_l" = x"yes" \)], [
AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include
#include
#include
#ifdef HAVE_XLOCALE_H
# include
#endif
], [
#ifdef HAVE_STRTOD_L
(void)strtod_l;
#endif
#ifdef HAVE_STRTOF_L
(void)strtof_l;
#endif
#ifdef HAVE_ASPRINTF_L
(void)asprintf_l;
#endif
])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
])
])
dnl This check needs to happen after the above, as _GNU_SOURCE can change the
dnl return type.
AC_CHECK_FUNCS(strerror_r, [
AC_MSG_CHECKING(for return type of strerror_r)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include
#include
], [
switch (strerror_r(0, NULL, 0)) {
case 0:;
}
])
], [
AC_MSG_RESULT(int)
], [
AC_MSG_RESULT(char *)
AC_DEFINE(STRERROR_R_RETURNS_CHARP, 1,
[Whether strerror_r returns char *])
])
])
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_FUNCS(uname)
AC_CHECK_FUNC(pipe, [
AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])
])
AC_ARG_ENABLE(sockets,
AS_HELP_STRING([--disable-sockets], [disable socket support]))
AS_IF([test x"$enable_sockets" != x"no"], [
AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets])
AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}')
case "$host_os" in
amigaos* | morphos*)
;;
haiku*)
LIBS="-lnetwork $LIBS"
OBJFW_LIBS="-lnetwork $OBJFW_LIBS"
;;
mingw*)
LIBS="-lws2_32 -liphlpapi $LIBS"
OBJFW_LIBS="-lws2_32 -liphlpapi $OBJFW_LIBS"
;;
*)
AC_CHECK_LIB(socket, socket, [
LIBS="-lsocket $LIBt"
OBJFW_LIBS="-lsocket $OBJFW_LIBS"
])
;;
esac
AC_CHECK_HEADER(sys/socket.h, [
AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1,
[Whether we have sys/socket.h])
])
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
#ifdef _WIN32
# include
#endif
])
AC_CHECK_TYPE([struct sockaddr_storage], [
AC_DEFINE(OF_HAVE_SOCKADDR_STORAGE, 1,
[Whether we have struct sockaddr_storage])
], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
#ifdef _WIN32
# include
#endif
])
AC_CHECK_HEADER(netinet/in.h, [
AC_DEFINE(OF_HAVE_NETINET_IN_H, 1,
[Whether we have netinet/in.h])
])
AC_CHECK_HEADER(netinet/tcp.h, [
AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
[Whether we have netinet/tcp.h])
])
AC_CHECK_HEADER(netinet/sctp.h, [
AC_DEFINE(OF_HAVE_SCTP, 1, [Whether we have SCTP])
AC_DEFINE(OF_HAVE_NETINET_SCTP_H, 1,
[Whether we have netinet/sctp.h])
AC_SUBST(USE_SRCS_SCTP, '${SRCS_SCTP}')
], [], [
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
])
AC_CHECK_HEADERS([arpa/inet.h netdb.h sys/sockio.h])
AC_CHECK_HEADERS([net/if.h], [], [], [
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
])
AC_CHECK_HEADERS([net/if_arp.h net/if_dl.h net/if_types.h])
AC_CHECK_FUNCS([if_indextoname if_nametoindex if_nameindex])
AC_CHECK_TYPES([struct sockaddr_dl], [], [], [
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef HAVE_NET_IF_DL_H
# include
#endif
])
AC_CHECK_TYPES([struct lifconf], [], [], [
#ifdef HAVE_NET_IF_H
# include
#endif
])
AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr], [], [], [
#ifdef HAVE_NET_IF_H
# include
#endif
])
AC_CHECK_HEADER(sys/un.h, [
AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h])
])
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
#ifdef AF_INET6
egrep_cpp_yes
#endif
], [
AC_DEFINE(OF_HAVE_IPV6, 1, [Whether we have IPv6])
])
], [
dnl Work around a bug in autoconf 2.61 that creates a broken
dnl configure if this branch is empty.
:
], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_NETINET_IN_H
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
])
AC_CHECK_HEADERS(afunix.h, [
AC_DEFINE(OF_HAVE_AFUNIX_H, 1, [Whether we have afunix.h])
], [], [
#ifdef _WIN32
# include
#endif
])
AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [
AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1,
[Whether we have UNIX sockets])
AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}')
AC_CHECK_MEMBERS(struct sockaddr_un.sun_len, [], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_SYS_UN_H
# include
#endif
#ifdef _WIN32
# include
#endif
#ifdef HAVE_AFUNIX_H
# include
#endif
])
AC_CHECK_FUNCS(getpeereid)
], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_SYS_UN_H
# include
#endif
#ifdef _WIN32
# include
#endif
#ifdef HAVE_AFUNIX_H
# include
#endif
#ifdef __morphos__
# error MorphOS has the struct but does not support it
#endif
#ifdef __MINT__
# error Gives invalid argument at runtime
#endif
])
AC_CHECK_HEADER(netipx/ipx.h, [
AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
[Whether we have netipx/ipx.h])
])
AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [
AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [
AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_addr.x_port,
[], [], [
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include
#endif
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
])
AS_IF([test x"$ac_cv_member_struct_sockaddr_ipx_sipx_network" = x"yes" \
-o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes" -o \
x"$ac_cv_member_struct_sockaddr_ipx_sipx_addr_x_port" = x"yes"], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
#ifdef AF_IPX
egrep_cpp_yes
#endif
], [
AC_DEFINE(OF_HAVE_IPX, 1, [Whether we have IPX/SPX])
AC_SUBST(USE_SRCS_IPX, '${SRCS_IPX}')
])
])
AC_CHECK_HEADER(netat/appletalk.h, [
AC_DEFINE(OF_HAVE_NETAT_APPLETALK_H, 1,
[Whether we have netat/appletalk.h])
])
AC_CHECK_HEADER(netatalk/at.h, [
AC_DEFINE(OF_HAVE_NETATALK_AT_H, 1,
[Whether we have netatalk/at.h])
])
AC_CHECK_MEMBER(struct sockaddr_at.sat_addr, [], [
AC_CHECK_MEMBER(struct sockaddr_at.sat_net, [], [], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#if defined(OF_HAVE_NETAT_APPLETALK_H)
# include
#elif defined(OF_HAVE_NETATALK_AT_H)
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#if defined(OF_HAVE_NETAT_APPLETALK_H)
# include
#elif defined(OF_HAVE_NETATALK_AT_H)
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
])
AS_IF([test x"$ac_cv_member_struct_sockaddr_at_sat_addr" = x"yes" \
-o x"$ac_cv_member_struct_sockaddr_at_sat_net" = x"yes"], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include
# endif
# endif
# include
# include
#endif
#ifdef AF_APPLETALK
egrep_cpp_yes
#endif
], [
AC_DEFINE(OF_HAVE_APPLETALK, 1,
[Whether we have AppleTalk])
AC_SUBST(USE_SRCS_APPLETALK, '${SRCS_APPLETALK}')
])
])
AC_CHECK_FUNCS(paccept accept4, break)
AC_CHECK_FUNCS(kqueue1 kqueue, [
AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue])
AC_SUBST(OF_KQUEUE_KERNEL_EVENT_OBSERVER_M,
"OFKqueueKernelEventObserver.m")
break
])
AC_CHECK_FUNCS(epoll_create1 epoll_create, [
AC_DEFINE(HAVE_EPOLL, 1, [Whether we have epoll])
AC_SUBST(OF_EPOLL_KERNEL_EVENT_OBSERVER_M,
"OFEpollKernelEventObserver.m")
break
])
AS_IF([test x"$with_wii" = x"yes"], [
AC_DEFINE(HAVE_POLL, 1, [Whether we have poll()])
AC_SUBST(OF_POLL_KERNEL_EVENT_OBSERVER_M,
"OFPollKernelEventObserver.m")
], [
AC_CHECK_HEADERS(poll.h)
AC_CHECK_FUNC(poll, [
AC_DEFINE(HAVE_POLL, 1, [Whether we have poll()])
AC_SUBST(OF_POLL_KERNEL_EVENT_OBSERVER_M,
"OFPollKernelEventObserver.m")
])
])
case "$host_os" in
amigaos* | mingw* | morphos*)
AC_DEFINE(HAVE_SELECT, 1, [Whether we have select() or similar])
AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M,
"OFSelectKernelEventObserver.m")
;;
*)
AC_CHECK_HEADERS(sys/select.h)
AC_CHECK_FUNC(select, [
AC_DEFINE(HAVE_SELECT, 1,
[Whether we have select() or similar])
AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M,
"OFSelectKernelEventObserver.m")
])
;;
esac
AC_ARG_WITH(tls,
AS_HELP_STRING([--with-tls], [
enable TLS support using the specified library
(yes, openssl, gnutls, securetransport, mbedtls or
no)]))
AS_IF([test x"$with_tls" = x""], [with_tls="yes"])
tls_support="no"
AS_IF([test x"$with_tls" = x"securetransport" \
-o x"$with_tls" = x"yes"], [
AC_CHECK_HEADERS(Security/SecureTransport.h, [
old_LIBS="$LIBS"
LIBS="-framework Security -framework Foundation $LIBS"
AC_CHECK_FUNC(SSLHandshake, [
tls_support="Secure Transport"
tmp="-framework Security -framework Foundation"
TLS_LIBS="-lobjfwbridge $tmp $TLS_LIBS"
tmp="-framework ObjFWBridge $tmp"
TLS_FRAMEWORK_LIBS="$tmp $TLS_FRAMEWORK_LIBS"
AC_SUBST(USE_SRCS_SECURETRANSPORT,
'${SRCS_SECURETRANSPORT}')
AC_CHECK_FUNCS(SSLCreateContext)
], [])
LIBS="$old_LIBS"
])
])
AS_IF([test x"$with_tls" = x"openssl" \
-o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
case "$host_os" in
morphos*)
ssl="ssl_shared"
crypto="crypto_shared"
z="z_shared"
;;
mingw*)
ssl="ssl"
crypto="crypto"
z="z"
TLS_LIBS="-lcrypt32 -lpathcch $TLS_LIBS"
;;
*)
ssl="ssl"
crypto="crypto"
z="z"
;;
esac
AC_CHECK_LIB($ssl, SSL_set1_host, [
AC_CHECK_HEADER(openssl/ssl.h, [
tls_support="OpenSSL"
tmp="-l$ssl -l$crypto -l$z"
TLS_LIBS="$tmp $TLS_LIBS"
TLS_FRAMEWORK_LIBS="$tmp $TLS_FRAMEWORK_LIBS"
AC_SUBST(USE_SRCS_OPENSSL, '${SRCS_OPENSSL}')
old_LIBS="$LIBS"
LIBS="$TLS_LIBS $LIBS"
AC_CHECK_FUNCS(SSL_has_pending)
LIBS="$old_LIBS"
])
], [], [-l$crypto -l$z $TLS_LIBS])
])
AS_IF([test x"$with_tls" = x"gnutls" \
-o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [
tls_support="GnuTLS"
TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS"
TLS_LIBS="$gnutls_LIBS $TLS_LIBS"
TLS_FRAMEWORK_LIBS="$gnutls_LIBS $TLS_FRAMEWORK_LIBS"
AC_SUBST(USE_SRCS_GNUTLS, '${SRCS_GNUTLS}')
], [
dnl Disable default action-if-not-found, which exits
dnl configure with an error.
:
])
])
AS_IF([test x"$with_tls" = x"mbedtls"], [
AC_CHECK_LIB(mbedtls, mbedtls_net_init, [
AC_CHECK_HEADER(mbedtls/ssl.h, [
tls_support="Mbed TLS"
tmp="-lmbedtls -lmbedx509 -lmbedcrypto"
TLS_LIBS="$tmp $TLS_LIBS"
TLS_FRAMEWORK_LIBS="$tmp $TLS_FRAMEWORK_LIBS"
AC_SUBST(USE_SRCS_MBEDTLS, '${SRCS_MBEDTLS}')
])
], [], [-lmbedx509 -lmbedcrypto])
])
AS_IF([test x"$tls_support" != x"no"], [
AC_SUBST(TLS, "tls")
AC_SUBST(TLS_CPPFLAGS)
AC_SUBST(TLS_LIBS)
AC_SUBST(TLS_FRAMEWORK_LIBS)
AC_SUBST(TLS_STATIC_LIBS)
AC_DEFINE(HAVE_TLS_SUPPORT, 1,
[Whether we have an implementation for TLS])
AC_CONFIG_FILES([src/tls/ObjFWTLS.oc src/tls/Info.plist])
OFARC_LIBS="-lobjfwtls $TLS_LIBS $OFARC_LIBS"
OFHASH_LIBS="-lobjfwtls $TLS_LIBS $OFHASH_LIBS"
OFHTTP_LIBS="-lobjfwtls $TLS_LIBS $OFHTTP_LIBS"
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWTLS_SHARED_LIB,
'${LIB_PREFIX}objfwtls${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
AC_SUBST(OBJFWTLS_FRAMEWORK, "ObjFWTLS.framework")
])
])
AS_IF([test x"$with_tls" != x"no" -a x"$tls_support" = x"no"], [
AC_MSG_ERROR(m4_normalize([
No TLS implementation was found. Please install OpenSSL,
GnuTLS, Mbed TLS or use --without-tls.
]))
])
AS_IF([test x"$enable_threads" != x"no"], [
AC_SUBST(OF_HTTP_CLIENT_TESTS_M, "OFHTTPClientTests.m")
])
AC_SUBST(OFDNS, "ofdns")
AS_IF([test x"$enable_files" != x"no"], [
AC_SUBST(OFHTTP, "ofhttp")
AC_SUBST(OFHTTP_LIBS)
])
])
AC_DEFUN([CHECK_BUILTIN_BSWAP], [
AC_MSG_CHECKING(for __builtin_bswap$1)
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include
#include
#include
], [
uint$1_t i = errno;
printf("%d", (int)__builtin_bswap$1(i));
])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE_BUILTIN_BSWAP$1, 1,
[Whether we have __builtin_bswap$1])
], [
AC_MSG_RESULT(no)
])
])
CHECK_BUILTIN_BSWAP(16)
CHECK_BUILTIN_BSWAP(32)
CHECK_BUILTIN_BSWAP(64)
case "$host_os" in
darwin*)
AC_MSG_CHECKING(whether we are compiling for macOS)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#if (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \
(!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR)
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
have_subprocesses="no"
])
;;
mingw*)
have_subprocesses="yes"
;;
msdosdjgpp*)
have_subprocesses="no"
;;
esac
AS_IF([test x"$have_subprocesses" = x""], [
AC_HEADER_SYS_WAIT
AC_CHECK_FUNCS(kill)
AC_CHECK_FUNCS(posix_spawnp, [
AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
AC_CHECK_HEADERS(spawn.h, [have_subprocesses="yes"])
])
])
AS_IF([test x"$have_subprocesses" = x""], [
AC_CHECK_FUNCS([vfork dup2 execvp _exit], [
AS_IF([test x"$ac_cv_func_vfork" = x"yes" \
-a x"$ac_cv_func_pipe" = x"yes" \
-a x"$ac_cv_func_dup2" = x"yes" \
-a x"$ac_cv_func_execvp" = x"yes" \
-a x"$ac_cv_func_kill" = x"yes" \
-a x"$ac_cv_func__exit" = x"yes"], [
have_subprocesses="yes"
])
], [
break
])
])
])
AS_IF([test x"$have_subprocesses" = x"yes"], [
AC_SUBST(USE_SRCS_SUBPROCESSES, '${SRCS_SUBPROCESSES}')
AC_SUBST(SUBPROCESS, "subprocess")
AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses])
])
AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h])
AC_CHECK_FUNCS(ioctl isatty)
AC_CHECK_FUNC(pledge, [
AC_DEFINE(OF_HAVE_PLEDGE, 1, [Whether we have pledge()])
])
AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
AC_CHECK_HEADER(Foundation/NSObject.h, [
AC_SUBST(BRIDGE, "bridge")
AC_CONFIG_FILES(src/bridge/Info.plist)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWBRIDGE_SHARED_LIB,
'${LIB_PREFIX}objfwbridge${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFWBRIDGE_STATIC_LIB, "libobjfwbridge.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
AC_SUBST(OBJFWBRIDGE_FRAMEWORK,
"ObjFWBridge.framework")
])
])
])
dnl This needs to be after all other header checks, as they include unistd.h,
dnl which in old glibc versions uses __block. This is worked around in the code
dnl by providing a wrapper for unistd.h which takes care of this.
AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Xclang -fblocks"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [
int (^foo)(int bar);
foo = ^ (int bar) { return 0; }
])
], [
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fblocks"
AC_SUBST(OF_BLOCK_TESTS_M, "OFBlockTests.m")
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
AS_IF([test x"$GOBJC" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith"
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror], [build with -Werror]))
AS_IF([test x"$enable_werror" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Werror"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Foo
{
struct objc_class *_isa;
}
@end
static struct {
struct objc_class *_isa;
} object;
], [
Foo *test = (Foo *)&object;
(void)test; /* Get rid of unused variable warning */
])
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS -Wno-strict-aliasing"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(
whether we need -Wno-unused-property-ivar due to Clang bugs)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Foo
{
struct objc_class *_isa;
Foo *_foo;
}
@property (readonly, nonatomic) Foo *foo;
+ (Foo *)foo;
@end
@implementation Foo
@synthesize foo = _foo;
+ (Foo *)foo
{
return (Foo *)0;
}
@end
])
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS -Wno-unused-property-ivar"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wcast-align -Werror"
AC_MSG_CHECKING(whether -Wcast-align is buggy)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Foo
{
struct objc_class *_isa;
}
@end
@implementation Foo
- (void)foo
{
struct objc_class *c = _isa;
(void)c;
}
@end
])
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS -Wcast-align"
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wunreachable-code -Werror"
AC_MSG_CHECKING(whether -Wunreachable-code can be used)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
#include
struct objc_selector;
typedef const struct objc_selector *SEL;
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Object
- (void)doesNotRecognizeSelector: (SEL)selector
#ifdef __clang__
__attribute__((__noreturn__))
#endif
;
- (void)dealloc;
@end
@interface Foo: Object
@end
void
test(void)
{
if (sizeof(int) == 4)
__asm__ ("");
else if (sizeof(int) == 8)
__asm__ ("");
else
abort();
}
/*
* Unfortunately, this cannot be shorter, as it only
* works when it is used inside a macro.
*/
#ifdef __clang__
# define OF_DEALLOC_UNSUPPORTED \
[self doesNotRecognizeSelector: _cmd]; \
\
abort(); \
\
_Pragma("clang diagnostic push"); \
_Pragma("clang diagnostic ignored \
\"-Wunreachable-code\""); \
[super dealloc]; \
_Pragma("clang diagnostic pop");
#else
# define OF_DEALLOC_UNSUPPORTED \
[self doesNotRecognizeSelector: _cmd]; \
\
abort(); \
\
[super dealloc];
#endif
@implementation Foo
- (void)dealloc
{
OF_DEALLOC_UNSUPPORTED
}
@end
]])
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS -Wunreachable-code"
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wdocumentation -Werror"
AC_MSG_CHECKING(whether -Wdocumentation works correctly)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
/**
* @class Test conftest.m conftest.m
*/
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Test
@end
/**
* @struct Foo conftest.m conftest.m
*/
typedef struct {} Foo;
])
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS -Wdocumentation"
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
AS_IF([test x"$check_pedantic" = x"yes"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -pedantic -Werror"
AC_MSG_CHECKING(whether -pedantic is buggy)
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
#include
#include
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@interface Foo
{
void *foo;
}
@end
@interface Bar: Foo
- (void)assert;
@end
@implementation Bar
- (void)assert
{
/*
* Some versions of glibc break with
* -pedantic when using assert.
*/
assert(1);
}
@end
])
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS -pedantic"
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
])
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(whether we need -Wno-strict-prototypes)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include
], [
signal(SIGINT, SIG_DFL);
])
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS -Wno-strict-prototypes"
])
AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include
], [
complex float f = 0.5 + 0.5 * I;
(void)f;
])
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS -Wno-gnu-imaginary-constant"
])
])
])
case "$host_os" in
linux*)
AS_IF([test x"$enable_files" != x"no"], [
AC_SUBST(USE_SRCS_EVDEV, '${SRCS_EVDEV}')
])
;;
mingw*)
AC_SUBST(USE_SRCS_XINPUT, '${SRCS_XINPUT}')
;;
darwin*)
AC_CHECK_HEADERS(GameController/GameController.h, [
AC_SUBST(USE_SRCS_GCF, '${SRCS_GCF}')
tmp="-framework GameController"
HID_STATIC_LIBS="$tmp \${libdir}/libobjfwbridge.a $HID_LIBS"
HID_LIBS="$tmp -lobjfwbridge $HID_LIBS"
tmp="$tmp -framework ObjFWBridge"
HID_FRAMEWORK_LIBS="$tmp $HID_FRAMEWORK_LIBS"
])
;;
esac
AS_IF([test x"$cross_compiling" = x"yes"], [
AC_SUBST(BIN_PREFIX, "${host_alias}-")
case "$host" in
i?86-*-mingw*)
AC_CHECK_PROG(WINE, wine, wine)
;;
x86_64-*-mingw*)
AC_CHECK_PROG(WINE, wine64, wine64)
;;
esac
AS_IF([test x"$WINE" != x""], [AC_SUBST(WRAPPER, "$WINE")])
AS_IF([test x"$with_wii" = x"yes"], [
dnl Keep this lowercase, as WIILOAD is a variable used by
dnl wiiload and thus likely already set by the user to something
dnl that is not the path of the wiiload binary.
AC_CHECK_PROG(wiiload, wiiload, wiiload)
AS_IF([test x"$wiiload" != x""], [
AC_SUBST(WRAPPER, "$wiiload")
])
])
])
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself.
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)
dnl We use the ObjC compiler as our assembler
AC_SUBST(AS, $OBJC)
AC_SUBST(ASFLAGS)
AC_SUBST(DEP_ASFLAGS, '${DEP_OBJCFLAGS}')
AC_SUBST(OBJFW_CPPFLAGS)
AC_SUBST(OBJFW_OBJCFLAGS)
AC_SUBST(OBJFW_LDFLAGS)
AC_SUBST(OBJFW_LIBS)
AC_SUBST(HID_LIBS)
AC_SUBST(HID_FRAMEWORK_LIBS)
AC_SUBST(HID_STATIC_LIBS)
AC_SUBST(TESTS_LIBS)
AC_CONFIG_FILES([
buildsys.mk
extra.mk
src/Info.plist
src/hid/Info.plist
src/hid/ObjFWHID.oc
tests/Info.plist
utils/objfw-config
])
AC_CONFIG_HEADERS([config.h src/objfw-defs.h])
AC_OUTPUT
AS_IF([test x"$old_compiler" = x"yes"], [
echo
printf " ** Note: Your compiler does not seem to "
echo "accept -fobjc-runtime=objfw."
printf " ** To get optimal performance, you should install "
echo "Clang >= 3.2"
printf " ** (or the latest Clang release to be able to use all "
echo "features)."
echo
])
AS_IF([test x"$enable_threads" != x"no" -a x"$atomic_ops" = x"none" \
-a x"$have_spinlocks" != x"yes" -a x"$have_amiga_threads" != x"yes"], [
echo
printf " ** Warning: You have enabled threads, but neither atomic "
echo "operations nor"
printf " ** spinlocks are available. Expect *very* poor performance, "
echo "as a mutex will"
printf " ** be locked for every retain and release! If you don't "
echo "need threads, try"
echo " ** --disable-threads to work around this problem."
echo
])
objfw-1.3/extra.mk.in 100644 001750 001750 00000010326 14767513633 013621 0 ustar 00js js 000000 000000 OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@
OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@
OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@
OBJFW_LIB_MAJOR = 1
OBJFW_LIB_MINOR = 3
OBJFW_LIB_PATCH = 0
OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}
OBJFWRT_SHARED_LIB = @OBJFWRT_SHARED_LIB@
OBJFWRT_STATIC_LIB = @OBJFWRT_STATIC_LIB@
OBJFWRT_FRAMEWORK = @OBJFWRT_FRAMEWORK@
OBJFWRT_LIB_MAJOR = 1
OBJFWRT_LIB_MINOR = 3
OBJFWRT_LIB_PATCH = 0
OBJFWRT_LIB_MAJOR_MINOR = ${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR}
OBJFWBRIDGE_SHARED_LIB = @OBJFWBRIDGE_SHARED_LIB@
OBJFWBRIDGE_STATIC_LIB = @OBJFWBRIDGE_STATIC_LIB@
OBJFWBRIDGE_FRAMEWORK = @OBJFWBRIDGE_FRAMEWORK@
OBJFWBRIDGE_LIB_MAJOR = 1
OBJFWBRIDGE_LIB_MINOR = 3
OBJFWBRIDGE_LIB_PATCH = 0
OBJFWTLS_SHARED_LIB = @OBJFWTLS_SHARED_LIB@
OBJFWTLS_STATIC_LIB = @OBJFWTLS_STATIC_LIB@
OBJFWTLS_FRAMEWORK = @OBJFWTLS_FRAMEWORK@
OBJFWTLS_LIB_MAJOR = 1
OBJFWTLS_LIB_MINOR = 3
OBJFWTLS_LIB_PATCH = 0
OBJFWHID_SHARED_LIB = @OBJFWHID_SHARED_LIB@
OBJFWHID_STATIC_LIB = @OBJFWHID_STATIC_LIB@
OBJFWHID_FRAMEWORK = @OBJFWHID_FRAMEWORK@
OBJFWHID_LIB_MAJOR = 1
OBJFWHID_LIB_MINOR = 3
OBJFWHID_LIB_PATCH = 0
OBJFWHID_LIB_MAJOR_MINOR = ${OBJFWHID_LIB_MAJOR}.${OBJFWHID_LIB_MINOR}
AUTORELEASE_FOUNDATION_M = @AUTORELEASE_FOUNDATION_M@
BIN_PREFIX = @BIN_PREFIX@
BRIDGE = @BRIDGE@
CVINCLUDE_INLINE_H = @CVINCLUDE_INLINE_H@
ENCODINGS_A = @ENCODINGS_A@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
FORWARDING_A = @FORWARDING_A@
FORWARDING_LIB_A = @FORWARDING_LIB_A@
HID_FRAMEWORK_LIBS = @HID_FRAMEWORK_LIBS@
HID_LIBS = @HID_LIBS@
LIBBASES_M = @LIBBASES_M@
LIBOBJFWHID_DEP = @LIBOBJFWHID_DEP@
LIBOBJFWHID_DEP_LVL2 = @LIBOBJFWHID_DEP_LVL2@
LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@
LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@
LIBOBJFW_DEP = @LIBOBJFW_DEP@
LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@
LOOKUP_ASM_A = @LOOKUP_ASM_A@
LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@
MAP_LDFLAGS = @MAP_LDFLAGS@
OBJC_SYNC = @OBJC_SYNC@
OBJFW_NEW = @OBJFW_NEW@
OFARC = @OFARC@
OFARC_LIBS = @OFARC_LIBS@
OFDNS = @OFDNS@
OFHASH = @OFHASH@
OFHASH_LIBS = @OFHTTP_LIBS@
OFHTTP = @OFHTTP@
OFHTTP_LIBS = @OFHTTP_LIBS@
OF_BLOCK_TESTS_M = @OF_BLOCK_TESTS_M@
OF_EPOLL_KERNEL_EVENT_OBSERVER_M = @OF_EPOLL_KERNEL_EVENT_OBSERVER_M@
OF_HTTP_CLIENT_TESTS_M = @OF_HTTP_CLIENT_TESTS_M@
OF_KQUEUE_KERNEL_EVENT_OBSERVER_M = @OF_KQUEUE_KERNEL_EVENT_OBSERVER_M@
OF_POLL_KERNEL_EVENT_OBSERVER_M = @OF_POLL_KERNEL_EVENT_OBSERVER_M@
OF_SCTP_SOCKET_M = @OF_SCTP_SOCKET_M@
OF_SELECT_KERNEL_EVENT_OBSERVER_M = @OF_SELECT_KERNEL_EVENT_OBSERVER_M@
REEXPORT_RUNTIME = @REEXPORT_RUNTIME@
REEXPORT_RUNTIME_FRAMEWORK = @REEXPORT_RUNTIME_FRAMEWORK@
RUNTIME = @RUNTIME@
RUNTIME_ARC_TESTS_M = @RUNTIME_ARC_TESTS_M@
RUNTIME_ASSOCIATION_M = @RUNTIME_ASSOCIATION_M@
RUNTIME_FRAMEWORK_LIBS = @RUNTIME_FRAMEWORK_LIBS@
RUNTIME_INSTANCE_M = @RUNTIME_INSTANCE_M@
RUNTIME_LIBS = @RUNTIME_LIBS@
RUNTIME_STATIC_LIBS = @RUNTIME_STATIC_LIBS@
SUBPROCESS = @SUBPROCESS@
TESTPLUGIN = @TESTPLUGIN@
TESTPLUGIN_BUNDLE = @TESTPLUGIN_BUNDLE@
TESTPLUGIN_LIBS = @TESTPLUGIN_LIBS@
TESTPLUGIN_PLUGIN = @TESTPLUGIN_PLUGIN@
TESTS_LIBS = @TESTS_LIBS@
TESTS_STATIC_LIB = @TESTS_STATIC_LIB@
TLS = @TLS@
TLS_CPPFLAGS = @TLS_CPPFLAGS@
TLS_FRAMEWORK_LIBS = @TLS_FRAMEWORK_LIBS@
TLS_LIBS = @TLS_LIBS@
UNICODE_M = @UNICODE_M@
USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@
USE_SRCS_APPLETALK = @USE_SRCS_APPLETALK@
USE_SRCS_EVDEV = @USE_SRCS_EVDEV@
USE_SRCS_FILES = @USE_SRCS_FILES@
USE_SRCS_GCF = @USE_SRCS_GCF@
USE_SRCS_GNUTLS = @USE_SRCS_GNUTLS@
USE_SRCS_IPX = @USE_SRCS_IPX@
USE_SRCS_MBEDTLS = @USE_SRCS_MBEDTLS@
USE_SRCS_MODULES = @USE_SRCS_MODULES@
USE_SRCS_NINTENDO_3DS = @USE_SRCS_NINTENDO_3DS@
USE_SRCS_NINTENDO_DS = @USE_SRCS_NINTENDO_DS@
USE_SRCS_NINTENDO_SWITCH = @USE_SRCS_NINTENDO_SWITCH@
USE_SRCS_OPENSSL = @USE_SRCS_OPENSSL@
USE_SRCS_SCTP = @USE_SRCS_SCTP@
USE_SRCS_SECURETRANSPORT = @USE_SRCS_SECURETRANSPORT@
USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@
USE_SRCS_SUBPROCESSES = @USE_SRCS_SUBPROCESSES@
USE_SRCS_TAGGED_POINTERS = @USE_SRCS_TAGGED_POINTERS@
USE_SRCS_THREADS = @USE_SRCS_THREADS@
USE_SRCS_UNIX_SOCKETS = @USE_SRCS_UNIX_SOCKETS@
USE_SRCS_WII = @USE_SRCS_WII@
USE_SRCS_WINDOWS = @USE_SRCS_WINDOWS@
USE_SRCS_XINPUT = @USE_SRCS_XINPUT@
WII_U_TESTS_LIBS = @WII_U_TESTS_LIBS@
WRAPPER = @WRAPPER@
objfw-1.3/generators 040755 001750 001750 00000000000 14767513633 013633 5 ustar 00js js 000000 000000 objfw-1.3/generators/unicode 040755 001750 001750 00000000000 14767513633 015261 5 ustar 00js js 000000 000000 objfw-1.3/generators/unicode/Makefile 100644 001750 001750 00000005274 14767513633 017005 0 ustar 00js js 000000 000000 include ../../extra.mk
PROG_NOINST = gen_tables${PROG_SUFFIX}
SRCS = TableGenerator.m
include ../../buildsys.mk
.PHONY: run
run: all
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}
rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll
rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib
if test -f ../../src/libobjfw.so; then \
${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
${LN_S} ../../src/libobjfw.so \
libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \
libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
fi
if test -f ../../src/objfw${OBJFW_LIB_MAJOR}.dll; then \
${LN_S} ../../src/objfw${OBJFW_LIB_MAJOR}.dll \
objfw${OBJFW_LIB_MAJOR}.dll; \
fi
if test -f ../../src/libobjfw.dylib; then \
${LN_S} ../../src/libobjfw.dylib \
libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
fi
if test -f ../../src/runtime/libobjfwrt.so; then \
${LN_S} ../../src/runtime/libobjfwrt.so \
libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
${LN_S} ../../src/runtime/libobjfwrt.so \
libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
elif test -f ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \
${LN_S} ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
fi
if test -f ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll; then \
${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \
objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
fi
if test -f ../../src/runtime/libobjfwrt.dylib; then \
${LN_S} ../../src/runtime/libobjfwrt.dylib \
libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
fi
LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
ASAN_OPTIONS=allocator_may_return_null=1 \
${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \
rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \
rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
rm -f objfw${OBJFW_LIB_MAJOR}.dll; \
rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
exit $$EXIT
CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../..
LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS}
LD = ${OBJC}
objfw-1.3/generators/unicode/TableGenerator.h 100644 001750 001750 00000003113 14767513633 020402 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFObject.h"
#import "OFHTTPClient.h"
@class OFString;
@interface TableGenerator: OFObject
{
OFHTTPClient *_HTTPClient;
OFUnichar _uppercaseTable[0x110000];
OFUnichar _lowercaseTable[0x110000];
OFUnichar _titlecaseTable[0x110000];
OFUnichar _caseFoldingTable[0x110000];
char _uppercaseTableUsed[0x1100];
char _lowercaseTableUsed[0x1100];
char _titlecaseTableUsed[0x1100];
char _caseFoldingTableUsed[0x1100];
size_t _uppercaseTableSize;
size_t _lowercaseTableSize;
size_t _titlecaseTableSize;
size_t _caseFoldingTableSize;
enum {
stateUnicodeData,
stateCaseFolding
} _state;
}
- (void)parseUnicodeData: (OFHTTPResponse *)response;
- (void)parseCaseFolding: (OFHTTPResponse *)response;
- (void)writeFiles;
- (void)writeTablesToFile: (OFString *)path;
- (void)writeHeaderToFile: (OFString *)path;
@end
objfw-1.3/generators/unicode/TableGenerator.m 100644 001750 001750 00000032213 14767513633 020412 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFApplication.h"
#import "OFArray.h"
#import "OFFile.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFIRI.h"
#import "OFStdIOStream.h"
#import "OFString.h"
#import "OFOutOfRangeException.h"
#import "TableGenerator.h"
#import "copyright.h"
static OFString *const unicodeDataIRI =
@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt";
static OFString *const caseFoldingIRI =
@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt";
OF_APPLICATION_DELEGATE(TableGenerator)
@implementation TableGenerator
- (instancetype)init
{
self = [super init];
@try {
_HTTPClient = [[OFHTTPClient alloc] init];
_HTTPClient.delegate = self;
_uppercaseTableSize = SIZE_MAX;
_lowercaseTableSize = SIZE_MAX;
_titlecaseTableSize = SIZE_MAX;
_caseFoldingTableSize = SIZE_MAX;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
OFHTTPRequest *request;
[OFStdOut writeString: @"Downloading UnicodeData.txt…"];
_state = stateUnicodeData;
request = [OFHTTPRequest requestWithIRI:
[OFIRI IRIWithString: unicodeDataIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
exception: (id)exception
{
if (exception != nil)
@throw exception;
[OFStdOut writeLine: @" done"];
switch (_state) {
case stateUnicodeData:
[self parseUnicodeData: response];
break;
case stateCaseFolding:
[self parseCaseFolding: response];
break;
}
}
- (void)parseUnicodeData: (OFHTTPResponse *)response
{
OFString *line;
OFHTTPRequest *request;
[OFStdOut writeString: @"Parsing UnicodeData.txt…"];
while ((line = [response readLine]) != nil) {
void *pool2;
OFArray OF_GENERIC(OFString *) *components;
OFUnichar codePoint;
if (line.length == 0)
continue;
pool2 = objc_autoreleasePoolPush();
components = [line componentsSeparatedByString: @";"];
if (components.count != 15) {
OFLog(@"Invalid line: %@\n", line);
[OFApplication terminateWithStatus: 1];
}
codePoint = (OFUnichar)[[components objectAtIndex: 0]
unsignedLongValueWithBase: 16];
if (codePoint > 0x10FFFF)
@throw [OFOutOfRangeException exception];
_uppercaseTable[codePoint] = (OFUnichar)[[components
objectAtIndex: 12] unsignedLongValueWithBase: 16];
_lowercaseTable[codePoint] = (OFUnichar)[[components
objectAtIndex: 13] unsignedLongValueWithBase: 16];
_titlecaseTable[codePoint] = (OFUnichar)[[components
objectAtIndex: 14] unsignedLongValueWithBase: 16];
objc_autoreleasePoolPop(pool2);
}
[OFStdOut writeLine: @" done"];
[OFStdOut writeString: @"Downloading CaseFolding.txt…"];
_state = stateCaseFolding;
request = [OFHTTPRequest requestWithIRI:
[OFIRI IRIWithString: caseFoldingIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)parseCaseFolding: (OFHTTPResponse *)response
{
OFString *line;
[OFStdOut writeString: @"Parsing CaseFolding.txt…"];
while ((line = [response readLine]) != nil) {
void *pool2;
OFArray OF_GENERIC(OFString *) *components;
OFUnichar codePoint;
if (line.length == 0 || [line hasPrefix: @"#"])
continue;
pool2 = objc_autoreleasePoolPush();
components = [line componentsSeparatedByString: @"; "];
if (components.count != 4) {
OFLog(@"Invalid line: %s\n", line);
[OFApplication terminateWithStatus: 1];
}
if (![[components objectAtIndex: 1] isEqual: @"S"] &&
![[components objectAtIndex: 1] isEqual: @"C"])
continue;
codePoint = (OFUnichar)[[components objectAtIndex: 0]
unsignedLongValueWithBase: 16];
if (codePoint > 0x10FFFF)
@throw [OFOutOfRangeException exception];
_caseFoldingTable[codePoint] = (OFUnichar)[[components
objectAtIndex: 2] unsignedLongValueWithBase: 16];
objc_autoreleasePoolPop(pool2);
}
[OFStdOut writeLine: @" done"];
[self writeFiles];
}
- (void)writeFiles
{
OFIRI *IRI;
[OFStdOut writeString: @"Writing files…"];
IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: IRI.fileSystemRepresentation];
IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: IRI.fileSystemRepresentation];
[OFStdOut writeLine: @" done"];
[OFApplication terminate];
}
- (void)writeTablesToFile: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path
mode: @"w"];
[file writeString: COPYRIGHT
@"#include \"config.h\"\n"
@"\n"
@"#import \"unicode.h\"\n"
@"\n"
@"static const OFUnichar emptyPage[0x100] = { 0 };\n"
@"\n"];
/* Write uppercasePage%u */
for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
bool isEmpty = true;
for (OFUnichar j = i; j < i + 0x100; j++) {
if (_uppercaseTable[j] != 0) {
isEmpty = false;
_uppercaseTableSize = i >> 8;
_uppercaseTableUsed[_uppercaseTableSize] = 1;
break;
}
}
if (!isEmpty) {
void *pool2 = objc_autoreleasePoolPush();
[file writeFormat: @"static const OFUnichar "
@"uppercasePage%u[0x100] = {\n",
i >> 8];
for (OFUnichar j = i; j < i + 0x100; j += 8)
[file writeFormat:
@"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
_uppercaseTable[j],
_uppercaseTable[j + 1],
_uppercaseTable[j + 2],
_uppercaseTable[j + 3],
_uppercaseTable[j + 4],
_uppercaseTable[j + 5],
_uppercaseTable[j + 6],
_uppercaseTable[j + 7]];
[file writeString: @"};\n\n"];
objc_autoreleasePoolPop(pool2);
}
}
/* Write lowercasePage%u */
for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
bool isEmpty = true;
for (OFUnichar j = i; j < i + 0x100; j++) {
if (_lowercaseTable[j] != 0) {
isEmpty = false;
_lowercaseTableSize = i >> 8;
_lowercaseTableUsed[_lowercaseTableSize] = 1;
break;
}
}
if (!isEmpty) {
void *pool2 = objc_autoreleasePoolPush();
[file writeFormat: @"static const OFUnichar "
@"lowercasePage%u[0x100] = {\n",
i >> 8];
for (OFUnichar j = i; j < i + 0x100; j += 8)
[file writeFormat:
@"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
_lowercaseTable[j],
_lowercaseTable[j + 1],
_lowercaseTable[j + 2],
_lowercaseTable[j + 3],
_lowercaseTable[j + 4],
_lowercaseTable[j + 5],
_lowercaseTable[j + 6],
_lowercaseTable[j + 7]];
[file writeString: @"};\n\n"];
objc_autoreleasePoolPop(pool2);
}
}
/* Write titlecasePage%u if it does NOT match uppercasePage%u */
for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
bool isEmpty = true;
for (OFUnichar j = i; j < i + 0x100; j++) {
if (_titlecaseTable[j] != 0) {
isEmpty = !memcmp(_uppercaseTable + i,
_titlecaseTable + i,
256 * sizeof(OFUnichar));
_titlecaseTableSize = i >> 8;
_titlecaseTableUsed[_titlecaseTableSize] =
(isEmpty ? 2 : 1);
break;
}
}
if (!isEmpty) {
void *pool2 = objc_autoreleasePoolPush();
[file writeFormat: @"static const OFUnichar "
@"titlecasePage%u[0x100] = {\n",
i >> 8];
for (OFUnichar j = i; j < i + 0x100; j += 8)
[file writeFormat:
@"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
_titlecaseTable[j],
_titlecaseTable[j + 1],
_titlecaseTable[j + 2],
_titlecaseTable[j + 3],
_titlecaseTable[j + 4],
_titlecaseTable[j + 5],
_titlecaseTable[j + 6],
_titlecaseTable[j + 7]];
[file writeString: @"};\n\n"];
objc_autoreleasePoolPop(pool2);
}
}
/* Write caseFoldingPage%u if it does NOT match lowercasePage%u */
for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
bool isEmpty = true;
for (OFUnichar j = i; j < i + 0x100; j++) {
if (_caseFoldingTable[j] != 0) {
isEmpty = !memcmp(_lowercaseTable + i,
_caseFoldingTable + i,
256 * sizeof(OFUnichar));
_caseFoldingTableSize = i >> 8;
_caseFoldingTableUsed[_caseFoldingTableSize] =
(isEmpty ? 2 : 1);
break;
}
}
if (!isEmpty) {
void *pool2 = objc_autoreleasePoolPush();
[file writeFormat: @"static const OFUnichar "
@"caseFoldingPage%u[0x100] = {\n",
i >> 8];
for (OFUnichar j = i; j < i + 0x100; j += 8)
[file writeFormat:
@"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
_caseFoldingTable[j],
_caseFoldingTable[j + 1],
_caseFoldingTable[j + 2],
_caseFoldingTable[j + 3],
_caseFoldingTable[j + 4],
_caseFoldingTable[j + 5],
_caseFoldingTable[j + 6],
_caseFoldingTable[j + 7]];
[file writeString: @"};\n\n"];
objc_autoreleasePoolPop(pool2);
}
}
/*
* Those are currently set to the last index.
* But from now on, we need the size.
*/
_uppercaseTableSize++;
_lowercaseTableSize++;
_titlecaseTableSize++;
_caseFoldingTableSize++;
/* Write _OFUnicodeUppercaseTable */
[file writeFormat: @"const OFUnichar *const "
@"_OFUnicodeUppercaseTable[0x%X] = {\n\t",
_uppercaseTableSize];
for (OFUnichar i = 0; i < _uppercaseTableSize; i++) {
if (_uppercaseTableUsed[i])
[file writeFormat: @"uppercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _uppercaseTableSize) {
if ((i + 1) % 4 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
/* Write _OFUnicodeLowercaseTable */
[file writeFormat: @"const OFUnichar *const "
@"_OFUnicodeLowercaseTable[0x%X] = {\n\t",
_lowercaseTableSize];
for (OFUnichar i = 0; i < _lowercaseTableSize; i++) {
if (_lowercaseTableUsed[i])
[file writeFormat: @"lowercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _lowercaseTableSize) {
if ((i + 1) % 4 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
/* Write _OFUnicodeTitlecaseTable */
[file writeFormat: @"const OFUnichar *const "
@"_OFUnicodeTitlecaseTable[0x%X] = {\n\t",
_titlecaseTableSize];
for (OFUnichar i = 0; i < _titlecaseTableSize; i++) {
if (_titlecaseTableUsed[i] == 1)
[file writeFormat: @"titlecasePage%u", i];
else if (_titlecaseTableUsed[i] == 2)
[file writeFormat: @"uppercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _titlecaseTableSize) {
if ((i + 1) % 4 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
/* Write _OFUnicodeCaseFoldingTable */
[file writeFormat: @"const OFUnichar *const "
@"_OFUnicodeCaseFoldingTable[0x%X] = {\n\t",
_caseFoldingTableSize];
for (OFUnichar i = 0; i < _caseFoldingTableSize; i++) {
if (_caseFoldingTableUsed[i] == 1)
[file writeFormat: @"caseFoldingPage%u", i];
else if (_caseFoldingTableUsed[i] == 2)
[file writeFormat: @"lowercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _caseFoldingTableSize) {
if ((i + 1) % 3 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
objc_autoreleasePoolPop(pool);
}
- (void)writeHeaderToFile: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path
mode: @"w"];
[file writeString: COPYRIGHT
@"#import \"OFString.h\"\n\n"];
[file writeFormat:
@"#define _OFUnicodeUppercaseTableSize 0x%X\n"
@"#define _OFUnicodeLowercaseTableSize 0x%X\n"
@"#define _OFUnicodeTitlecaseTableSize 0x%X\n"
@"#define _OFUnicodeCaseFoldingTableSize 0x%X\n\n",
_uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize,
_caseFoldingTableSize];
[file writeString:
@"#ifdef __cplusplus\n"
@"extern \"C\" {\n"
@"#endif\n"
@"extern const OFUnichar *const _Nonnull\n"
@" _OFUnicodeUppercaseTable[_OFUnicodeUppercaseTableSize] "
@"OF_VISIBILITY_HIDDEN;\n"
@"extern const OFUnichar *const _Nonnull\n"
@" _OFUnicodeLowercaseTable[_OFUnicodeLowercaseTableSize] "
@"OF_VISIBILITY_HIDDEN;\n"
@"extern const OFUnichar *const _Nonnull\n"
@" _OFUnicodeTitlecaseTable[_OFUnicodeTitlecaseTableSize] "
@"OF_VISIBILITY_HIDDEN;\n"
@"extern const OFUnichar *const _Nonnull\n"
@" _OFUnicodeCaseFoldingTable[_OFUnicodeCaseFoldingTableSize]\n"
@" OF_VISIBILITY_HIDDEN;\n"
@"#ifdef __cplusplus\n"
@"}\n"
@"#endif\n"];
objc_autoreleasePoolPop(pool);
}
@end
objfw-1.3/generators/unicode/copyright.h 100644 001750 001750 00000003512 14767513633 017517 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFString.h"
#define COPYRIGHT \
@"/*\n" \
@" * Copyright (c) 2008-2025 Jonathan Schleifer \n" \
@" *\n" \
@" * All rights reserved.\n" \
@" *\n" \
@" * This program is free software: you can redistribute it " \
@"and/or modify it\n" \
@" * under the terms of the GNU Lesser General Public License " \
@"version 3.0 only,\n" \
@" * as published by the Free Software Foundation.\n" \
@" *\n" \
@" * This program is distributed in the hope that it will be " \
@"useful, but WITHOUT\n" \
@" * ANY WARRANTY; without even the implied warranty of " \
@"MERCHANTABILITY or\n" \
@" * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General " \
@"Public License\n" \
@" * version 3.0 for more details.\n" \
@" *\n" \
@" * You should have received a copy of the GNU Lesser General " \
@"Public License\n" \
@" * version 3.0 along with this program. If not, see\n" \
@" * .\n" \
@" */\n" \
@"\n"
objfw-1.3/misc 040755 001750 001750 00000000000 14767513633 012415 5 ustar 00js js 000000 000000 objfw-1.3/misc/keys.asc 100644 001750 001750 00000037772 14767513633 014154 0 ustar 00js js 000000 000000 -----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZu9LCBYJKwYBBAHaRw8BAQdA+pZNXuVr+rlJkiXiQv2C43JTqX37sunxoYKb
fQMIiXS0HkpvbmF0aGFuIFNjaGxlaWZlciA8anNAbmlsLmltPoiaBBMWCAA2AgsJ
AhsDBBUICQoEFgIDAQIXgAIeARYhBNxDFxtr6Tl40JrYssYB7iF3PnyPBQJm70u2
AhkBABYLGlRSRVpPUi1HUEcJEMYB7iF3PnyPYjsBAOhyQfRt5ooIpEyfd1v5eP/E
nR+Zy1CD1jVnVP+BycRWAQDzAtGXtP0Mf50BKD3QMJ8/u/cCxgpVvFHVSyU/NLQ3
DYkCNwQTAQoAIRYhBG0ewiabwLVFnIupIM/atB+Cks7uBQJm70wgAwUBeAAKCRDP
2rQfgpLO7g02EACQs1UJR7+TGG/vgoYLQHG16P0QgO+F3w/JO9tP49/fIhqdckY8
TgDRjuJsJNRlp06lZYHSDJP1i5GSNmYxOoQKmox1iHKpY+jBfM6diF/jEZP0W1Js
nNNxi0FIzErIavP8KhLwiClX6ORjHO2VqQmMcVC1T5fHcFYGI+g2dHwvel/QjlvQ
AsO58BDzzYn/gI1WTNS26wluQBojvgqWeLykC0wVk5ZRC5Wci84saAYu0ASsb2PK
+HXHiz+22/tR7AsO3RNmzyjbMhNex6DKVRWsI+/mfOEUOoBNmFbkhqU/9Ytxhd5Z
C5o7zQGG5aueeoJMbpT+4WrZ/byROsM5sMnjF3K38ylAA4nlBqbvUNdjsovspFDt
VDLQIxGOppidNFRpMDxH1G091ja7H537BNaJ09s285c7TL+7U4x6tzWIbyc2r7Le
lJYmpFJLYino53a7I9KrKGcUreQzCdRvTSdXdyhi0hgXUJbEraBeZMtLnx1CbcOV
Ozd0/V5PqgBZAoy4hrL11nWSD7HZmLibCkaeHL3HkE814fHfM2aZaSa2dXHlIV6r
r7c0gQz1QCvaSj84mz0gmtEjyKtniFSiFE5x16nDlY+F3WsXTWuQad7lDbVHL1Jh
WLi4+MaCIu3mdjBdJESJqQCJQ+wAL0aBwGtM/1i+01oMkJ6aPm6TtqIeUbQiSm9u
YXRoYW4gU2NobGVpZmVyIDxqc0BOZXRCU0Qub3JnPoiTBBMWCgA7FiEE3EMXG2vp
OXjQmtiyxgHuIXc+fI8FAmbvS3gCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcC
F4AACgkQxgHuIXc+fI9iaQD/WW9X9ISEaOVezL83R/PZjkanuEg5sbla9Kr//JjH
6cQA/RiOFMaXLbM+gIU/f4yVCOQQilLJPYDR3daTomLBDxQAiQI3BBMBCgAhFiEE
bR7CJpvAtUWci6kgz9q0H4KSzu4FAmbvTCYDBQF4AAoJEM/atB+Cks7ua6UP/095
woH0AtKVBhuHZklahnpoq4uxZbaa7LwaY10knZf1nFd58CYoNiLkuZ7QWs13+VZg
WXCnVlZERT3g9f7JlppSy2wjm55FPIxJqJAm1GDh2kRchBs/+y/hR0vLwFWn6LL7
ild5wx2LbyiunkXM1NItsea314gnmSvqxf6ftdSGLdklfHbnn5doFykv2LPbn1qz
YEACEPpRgmipPSm+YAlPrk3QTzY/RYUi+u03XgTm6uSl/JTqZBcnVB+nBlKBZLOZ
5STCkInxsJn2UIXsyj/gBOsYQAGPWMen67UG8bZRU0H75xPttrra+XF44MVd4tp0
RmdHHdD9JeUKLCWDLEG4yByKdFOpwQ5b2/zznl8734PYZyMbzAKALoD6WcUDDCZS
oGIa9soGeOsi2w0XFFMn8sDypQKxIe0Y4zT/9S+wwlJ4LvhGIoZNnqb3vxLq4BEu
5Mx/54YdhHQ0/GkqQXszd6TL7d9uS6f2OcMVZp9htLkpT93uig5FbGEQSdsS37bR
HqNXERqHBgGKAeB/Ozu4l46U+bXQmsOO0Wt6mtJAXuU+HvxbjxJsagYArQZUzNdz
Gq3rKwjWJjt+KJGusTNlJbCnFZMxOO9t6Z62sqfExG74JevmzKTtyu2AO16U9ix7
V5mRHfKmLAAohg446oCcV9Lpe5TaZsiKaJouzaXNtClKb25hdGhhbiBTY2hsZWlm
ZXIgPGpzQGZlZG9yYXByb2plY3Qub3JnPoiTBBMWCgA7FiEE3EMXG2vpOXjQmtiy
xgHuIXc+fI8FAmbvS6kCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQ
xgHuIXc+fI8ITgEAymLmZzgsvTozqcfblFKk6kBMSWHSw2MOBtDsmSFCoPIBAPZk
7Osv/wOQlit9sVT0EOJvZ0gJAptK+LJX9esWXTgHiQI3BBMBCgAhFiEEbR7CJpvA
tUWci6kgz9q0H4KSzu4FAmbvTCoDBQF4AAoJEM/atB+Cks7ufMwP/3YNULJcmUdF
6Fqcavmc6cRLsHRZEFcY5Ow9/X2T2a9BkVq7Pe4n8QUc/NnJkdXbh4ApupDxftTq
9/IUxT9f7vc8YDMnEnpfzZvKRuTE4RZu2dYZTRBB6sD82wkthvWEDsXzT2Wf5sJH
MqLeEZRIreNqrs8TBgN8fg7AkU/++mY+8bZI62kMR0HzdiFxO6LWPRvHYx/L3+4U
kj3fl0hrNRVcxK88EDKt5JM27PQQRrPD8+C4kLDyfN/cD3RWhH4MrQ8TNQlmbF8i
6RiGk8o59p6ZHBJJaRsEEcD/37yal+HuFT+yPIbyWKdOCezSd/qUbPeASj/xJ9I6
d+Xj3zOA/0iziNcR6hoQZtK5hpqnwpsdTriINMtrtmf3inzvgiiHZHy1uuMl1uF4
6FYposMmYsUIrViGWhk3YbrQOzbleyxEjvoaG8oz7Dl/UvcGD9i2pQCvHhU+pap9
tySmRtsTNtNVjlv4NzYbv2FwD06VOkN75QP1lmxfoZcigE9mQaJTo2foCDS5tF7V
jqCYHieUGpao7ljPTUDQdSE99PXN+3EuzIG8Nf+vj5YZNkG/QPRu5zB3BQNt6LyT
R/YVP+nbp8LX4JBPHJW1SpfWB6l4ywIr25Ghd3ZXwF/hYqrbKQbamRI+o05Bals+
dvscllsWzoqRF93stw+4ueOyCbIgP9lDuDgEZu9LCBIKKwYBBAGXVQEFAQEHQIBA
0BPV8gvQMvBifMqJhkbkOzFqsVJ5eAhcUCGeejh9AwEIB4htBBgWCAAJBQJm70sI
AhsMABYJEMYB7iF3PnyPCxpUUkVaT1ItR1BHXQEBAMldeLa3S/1+Qgjp6lZM3Eqf
AhBj0CpGSJSUqFHegMpnAP0T2KSmIBN2DxIv8o1+NQDxPOwzuFLVrauw6fongjYh
D5kCDQReih1/ARAAuXxV9zzoO2UYYlXdNlNSxu9iJKH/RySUzIPtCWVxUfsI1NOo
2ByhxxGWpATRye61Lm6cAU+tvEXjsaKpTi4i9WSy6m6xuLLqQrpDrbVOlazzM1MR
QcqGK2wFPtNKV9qz+oOdPXK9a2RlgI2iwQh6AjCjq8oa3T1MtDF4D3uGBE+Fn9g+
gryAf/TZ8gKWyYd8UZwtrlFLC7nq8gSj2hFiRYTAPGy8GhcdyKvD0cP2xiFlpJmz
Cn5B+i9a5i3EJDcbfcc0BSyqxkz2BY8bymw4kTt5e8Bmf4KdzK5OE4w3PFPiMq+Z
3LVohQCI2CRh1wGw6lzntU5nqJ0ceD2YV9C8dHwVEN1Vu2M5mXkoe9q4iLWETppx
chrQWVAWZWCOeElNxdOrW/uhxpdXRmzTMuCIHolB4VhszS+Wr3Uj98DWa9n/cPZp
vRdVdXmy95G9ocp+uBozQEjdmLOmrqPUUbE/WLUO/tRFqp6w6QVfh81G5omLo5VW
lxCODK8OjOR4/rfCH28I75bjrm9HpIYtSasVG1/XSV+ilv3PCwadftz8BR5iE0JJ
tk8NtI1jOvPrIe5d9hJ9109xk/r9one51VLFFQDsNJexCswjD25xgpqnhZBd0yOt
cE9+6hiENLZ0DFrKZSJjNC7xY/tsK9usWwm3CBx2VFi+GpjL04Apo9ooPA0AEQEA
AbQeSm9uYXRoYW4gU2NobGVpZmVyIDxqc0BuaWwuaW0+iQJbBBMBCgBFAhsDAh4B
AheACAsJCg0MCAsHBhUKCQgLAwUWAwIBAAIZARYhBG0ewiabwLVFnIupIM/atB+C
ks7uBQJj6WbtBQkJIbBuAAoJEM/atB+Cks7u1qUP+gLBceY67YURSNLLCO+L537X
ukf2eYlzJzUvBI1nYv8C94dQcmSasBcAsg2ELfKE6GD1/7VwHQHwclpa3kSX55V6
+Ep3VUSR7+2fqz4Ahr10FeOpjS5CIr51C44mAjeTkkmPIqhOWSoZyg2RxUZOAUZy
FqpLDPFGrRTGmuEFnP1tXOAn3TR2xllK9iAbB9ZcJ+MHEz+rVW5yj3XY8/QW1kcs
WIA6qV7eHPP4Y8tEIoefvsU5g188uHIhxWhB0Xd52VMxd32yiKRgPp9z+6e4PQ+X
ULv5oGiqR17XKMtMIfAe6kiDYXWTHpqOHnOekVPuqTsjAFttgKeCEzbyit6HIFlq
oXjoj23eTFQEi2qiSLCRDm2uGZJIhAL5YeHPaNa82dg6YNCGD8FFSwP+hhXMaQ7z
B2jB8smX9A9C+nHCKCFF4ba1RRNqsFRziE2YuY+KX6bQKz6AZ7OxB16YAx75e4J/
H/Si8bqm+1EKc6Xpg7uVjYYNH+drj4qvNsTf4tLr3FAm5tSRCdZkSlilS+565J4P
InBVjcLnlRAxh1X1RJGVuFuueVdM6joGmsPDnwdv8NOvy+4LvBHWkPLm3FVZE9fy
Dem+0SDooTpvFEuSRfna8agJB5kHzA532hu1dEX/XJMCCJT4RBYy7KOVXqcjrLn/
TqRiBZKPK4QbmC/JjdKJiQEiBBABCAAMBQJj6WgVBQMAEnUAAAoJEJcQuJvKV618
c0IIAKLZVwWsgQWBjtjaIsXKUhoo5HBwNpsNCnWAyUj0ayspkvM+hh5fa70s4Mj4
oRdCd44X1iDHQw2bV6PVA+TvqkY2NV7iL30Vqpyt50qreUz9qCdEittaFIkRNk2q
kQB89cKTrrLDu2k80NZdV4sAAJKuXFUOEecZVv5D3gYSKDQJ0lTUzSyS4cC5wdSp
eEFRTVXpOQOI32mRM9BxmjtDSBctfnHSWYoE+IoC+OPqDvbbP4TRz3UYjAz5lbLS
L5BnlHxZDG2NryH9tUn+/wnJd41mweKZidDO/AUQ9eKKaIsgzCXAjrLjKcgBBANn
1yXl+YAr7J8GFdiGkVznYhGjmAW0IkpvbmF0aGFuIFNjaGxlaWZlciA8anNATmV0
QlNELm9yZz6JAlgEEwEKAEICGwMICwkKDQwICwcGFQoJCAsDBRYDAgEAAh4BAheA
FiEEbR7CJpvAtUWci6kgz9q0H4KSzu4FAmPpZvIFCQkhsG4ACgkQz9q0H4KSzu4/
nRAAk5+6zavoleNtZ0/l9xs0lwwqsENTfdWqp19YvkiQTWz0gDvRoxKbXHI4HK25
th0rBu77ryQYjKrRjXhEZrNq2k6fhTBwJ1sbsDceksaHRlUlVgn112gf6B/iKG3J
pLxuFxuMS4ndN9z7H67t2RWDY/+MqSgaNFWXQtfmtC3tfV8e5etZScVO8w+0Wed6
MjGjA76crgVWXm2hGCokEk7+0uNdVmFC+cPEBMixgAHqZvM+Gu3pZvHgV50Ybcza
lx/6KV2W37MsaX6iRUCCpnnoAAxNpWo2Z2LIBVaoO9nuzO8pgF8dRdxwq3Px/Rps
eHtEUY4v1/aylB4z1joI7sWPqXOR3QlRmCd2O36kCiLIvm9OQ5tmjmW9T+t/gcCz
q5pHDNIx8D50urqnUH+WU/WaT5fpuM6VifBpSZslTuRavc6kxa7kuGCrsBtVOzlM
CxSVAqSgMMm4vVxJm20pYIItHHTZTXEehnLEst/EdEAmLmHO2Qch/qUh2i0w5+4p
wjY1pIOVP8Si3xbxtoN6PIM/UBEPfBQGB4NzljQwISdUUSGiWn7pcun350IsCjnC
2c+tJQ/lHjhrJjZ+aMAi7OSV6g9PpjFrz+z9UmTP0QUeBSNGBqAWgvC4okGgFr4c
f9H01FbZPNkWIfZYPZ1Nv3apxNOxlpzSHcURnFhXPJDlqNC0IkpvbmF0aGFuIFNj
aGxlaWZlciA8anNAcGtnc3JjLm9yZz6JAlgEEwEKAEICGwMICwkKDQwICwcGFQoJ
CAsDBRYDAgEAAh4BAheAFiEEbR7CJpvAtUWci6kgz9q0H4KSzu4FAmPpZvcFCQkh
sG4ACgkQz9q0H4KSzu4TrxAAnWBrgJnU96KbYRS7KkpUzeLeaLrHK5LIhaJ7rVxV
rOo+x5Ey2NjGJKoTxC9UAfITCfO99vsycp3Gb9fJnowieuQ1y1MFCrYLPPLOfNxh
4Jc9GZK64DlexrsXvDhx84wgN+elrnjuatm9LUJWe5czWKiAnoki/u+SGFVxwOUt
ND205I4go/8FtY8rZ1P3VEGiXeZqhjNOodDoGEGZJwQIycN5YCrweYPwM+p80Zbz
kWGB+Ov3lOO+omMf7NQ3LFtueV0JNq7SjmNESYLm1Gg2NFHZp4D12sSUfHTvNVJB
r1qCJggQs2mefRB/aKcS4i9Ajmfki7TkEwutDMX6rOCZRppYpS8N6aYoiAOZHQmf
fk8bdi0RBGVSxR+04IwpYObUbDIZUS2exkiaDB0tFeguIlgHU/V+3GWEUDF4AhQL
bSYkEwUc65FstULrDCRfegFoUBsY9D+qPYnsNOlTRlalR8hZaQlwZLAuZx0kn+YG
xs+9z2UhgMExRtCM/3FRpDuiFJGsQML2DUArYZeh7JyJy0m9PIt59wg5wnHUyCLo
p8g1gn6Wh22/R/Le6CEusJsO2qiMoE6PSB89g3nhsvUadRpYOP9eZS0aoRgNPLp+
qigthgEV9fvSADHtAvsaLYpQ+wjrO+Ih57Y2MrU8mPehwqGz17Ur58VcI65qXTkZ
pni5Ag0EXoodfwEQAPc4JUVqZGxSKtipZKGewKuNyqASMq8gNwL7ToSni5cTuQLa
9YU+5Zo/BX3OEJkXp+MNN3Y1wFxVcPBZsYpBAx3apWhi0Fki+zdPjTmRE7QcFE+U
E17OnnFReb93G2ErSiY+BzsfbW/3dMjLfLhrVjJktLA9pGMoR483jI6rIVEBa6Ti
koMo8b790Ulo0xicl6ehFhQVUGN4CfovBjCZ9CIX6dmRGaB/FMyOXgXWsx5+UilT
gJhRHbJnggw6U1H8lk/WhJzCyLyYTg+YkHx3WwAF37pR6g1XACMQEdumCLxW21EL
C5D4aX0QejM8oIDf/xw5mHcgB0xg07FmRbyiZheg+CSPgwHWW/K6urw/G04SbYxn
k1/kPA66x6Fss3BxTuJOYmEZqklVNp2KfJdEiBECftRRWIbZu2zFOMGK1olPIOgs
KdJvaATkgeYSxjCu9+o4vY1yGXtzBEwBfIUkU2B33QzWLq+I61WeVbqRC6k0SYBK
iQK/uQJSVYuEtNJ8pttYxdYkyY+rs0yCZHlTlJcYKhAdMi1Gbh2L6WbzsHIHfmdr
aWqcv7EEuVacjrgerdk3ezOQspC5Gfa6pLEmOoF/ctwg/uoGCyhnWBmHiuLdN7F4
+z6BHBoqHU1i3z2oUJ3tHDoVnEmhjYNOgIs7UgKxXiuczMJT4gpNM35ym32hABEB
AAGJAjwEGAEKACYCGwwWIQRtHsImm8C1RZyLqSDP2rQfgpLO7gUCY+lnIwUJCSGw
pAAKCRDP2rQfgpLO7oIlD/4oLDMHqTzdDIXjM9x5U4ENBeGwUKHEkKeRduXuj0pZ
TnWTHmdXD3RPbG1EfGJU3PVBudZUiEREibNaEYM5VFuDwMw51qw7Ox8j4r+RtP+8
AI0zpRdababPP1/A4ap+xwReTWVM/CFF3VekqeElgxSjM6luFPNDdwyBNavOLtbr
Whmyclw3DLB03ZtS0sPvu0hXTnp4nbuWdsPOxGIomb9UF0IplMPm5ChjkZaypKY7
5P1k5Il+AZFWEi5YB6y8yl1gmOxY3pnKCJWcoGsaEoxREqHH/tZAeI299u8aE8Gj
l+ZxGunuPDMUd8OSlE8MI3osnWU47rbVueWqJ4CG3OcYJP8Vj1Ygy68R5xBL5ku3
ddv5oI2ZIDkqTBFKJQnhWMUX6Trze7US0jSdVFv4fYf3aHDJ0afc9RsKebPgbfN3
FWak03zInVqdXRrraa410qz8fKBI1CKalErJN7/dpXu3vfJJ2TgYcgAN9N0lY+YF
Q834qpDk6KOTYzvIMJASVIJ1gjvliE94hE6FYuHU9DlwYL3/qbOOb6lLIFHxaeQ9
5ZZR+raPyi1FGVGXV8oZI5f2UzxoLYyioTRjgC0cr9aIK56ZQ5I/npwuEYSL/8oI
WdRrYGQT0FFQQAnhhkd61DuPt3GAfhsY1fGkPo/YC3yulOJt98FIMg/lRlYfOrxI
bLkCDQReiiM/ARAAwIzaby43las5ApAWVw4MxCIpdY9S0tKUBgF4koKKkgUQ20Kz
I395LctZ6TwRSaBp9df/Wi9JtXe3bkt46ASjq8CCMggVptq80KyhnVMYDJD8mH+g
FjUdlxTgILg1tnYwt01oBIMh8T1cEUQ2kcWkDbIRnrrSkVxh+ntu8aqZaF9E9iSc
PbNO8V5qIGCTfeFti1IUfClQ10CsdANPxVngzttHs7eg+ddwZdiwxb7vxKy1/juq
WTNFcHYd4XQ8MIuedXliHpvI5qufMbFvOmX6xxxoXTL/efGoA/zCM6/BcM2ul1o/
prJTauRuVKawE3mcMpTrubN+usf6QEUohxsxCvxVqGcJVAU5286Hv0Kc2jzqcWqE
fiyjCJI0vwCzFk3sRbuawlDuC535paR23QC/ClSCghMzfRRnN4OpJQjzgc6yOZ3y
dqmF5UeqGrgZhrW+O92jBb1XqGFVzTOYHvLNJCQ0Cj53fiYpju4Pdf2BWvDo1oSo
KbrvSd3DUyXlgN2Ar6t3X2uz7HhL2496v3BoIOqzzcdvpCaDZjDdrw8SHpp45u9q
rzMPKEIdqy4u5KjsKjuCZKczy4pcu44+JjDzNJRik0Ppf2AUJLBCnik6prZIttbC
fGsvid7SR5sZZgjbGk/fuQCF/tQtaksvsIqb598/sTzNVBGkp6qWttTkPs8AEQEA
AYkCPAQYAQoAJgIbIBYhBG0ewiabwLVFnIupIM/atB+Cks7uBQJj6WcnBQkJIark
AAoJEM/atB+Cks7uei8QAIa+BrMifmLTSLe09CnGvacepKNao6UqSHwbmf6Tonv9
rOU2EquKyCW/0YK53WGO6fnPE7FV8JYDWxecBvtLjj+hloEHJ/wliYwd4W3FOuGn
b/E9mzQgyKdWcSBIxreZLdD7xZ5Biv3VLeKyx+xnJ99dC2+MBuL6CBk+gmzwri7/
hkYG9GQW9TJEe7qi8D87iTN1YkXlcJXdDcqapEZxv8+nAa5E4gTmLlXnKYNidC6+
9gtnGpCRZtSpLwX0pMVY27w9sthUAcnx5N3AwS7rCodqnU3ANa5a00wbWOmZ90qb
ofRX9RC3qkfoisr62bRELY7KFt7MVTV0YBTCPHFeP+bubyOOyUe1OJsCvWJfIhJm
87qjS37WXxYDUU+KHGN4MX9LDvTSxy+h30Ba0XFfU1fgNtIvVR+MrrIGACq5VU2u
SyBQLmIkgcusUComEx77mETE92MwROJfy1O5VGsNDr61xIu72MjKAlukwgwX/qQ7
i8Flyf8N++J7fETf/4DHXxNS9imVJTVxHfvIWpclRfdUCZB6R1Ihv+n1T+yx/Fro
TxQ5wuilV7+0r2DhrW6Q0YISoWv5L1sfohVZCXF7EQgteax0/86WSboerrWQmfGk
0k4SjKhBJK1O8Jhh2tk8OmlUz6Fs7MhFJ5NGASlFL7p0W5iB3qWYwn52sEBaI8Vp
mDMEZZb+wRYJKwYBBAHaRw8BAQdAC6OXd6EGorPc8Uxb6uXz93/UpLtKTHTTFhTr
Gwui636IsgQgFgoAWhYhBGMuKk2/4/NDWi8hv5QpbvLsm+aDBQJm70bpPB0CQWNj
aWRlbnRhbGx5IHN0b3JlZCBvbiBkZXZpY2Ugd2l0aG91dCBmdWxsIGRpc2sgZW5j
cnlwdGlvbgAKCRCUKW7y7JvmgzubAQD9jhYUCG0ITXC2jZ4Bk+p352WuvewhDcKt
ARNlypaJhQD9Ex07k5IRSfv9BWA4FFm1cj/LdUGUXWvj4YrGTwGwXw60OEpvbmF0
aGFuIFNjaGxlaWZlciAoQ29tbWl0IFNpZ25pbmcgS2V5IDIwMjQpIDxqc0BuaWwu
aW0+iJoEExYKAEICGwMICwkKDQwICwcGFQoJCAsDBRYDAgEAAh4FAheAFiEEYy4q
Tb/j80NaLyG/lClu8uyb5oMFAmbvRhoFCQFZmNkACgkQlClu8uyb5oNWKAEA2qxg
QElOLfkjh7xV4VJjmqiO2PqUWKbU3wRlNqXsYM8BAPo/uUWc8XyvruU+xaPXMy+5
P1sPxYKagXbI7+x1resMiQI3BBMBCgAhFiEEbR7CJpvAtUWci6kgz9q0H4KSzu4F
AmWXALQDBQF4AAoJEM/atB+Cks7uyS0QAJ0godHu9McqCiTD/qPbPB01rewG3SML
u2yoDvFt+hvAxHfKhWcPj1PjMeVbkzAppAGxOTAj2lLipto+xftWhdXkjxSlY9td
4Oeh870H6w7nnJtWsZ/UVvY+bKRnzl2AR7XryEvRzlRf73MJeN8VMdoYDFGZOtgo
/SH6NhkmezVArcpkRaHSmSonPmg4sQup5lLYYwafU9COZvPPvb+SitmxSzBLmwMF
sxV66wJa415joUlnrOK/3uB6765Z7umnC/bmt5sQomCy5oioO4BPYaDc2Cu5t9cV
UuUPGO5h1o76J4FC6vnPxQ9pLMRiUXanv9y63bgDxZX93cPl1fdc7+AC4QyTIDCz
3M55jc0wx+QcRmy5fQB60ftw5BjIBQiWnJ7fQ7F6hmA7gKXcbmr3myRDiL8unM0R
Gr4nJ2aeI8xsz9MvynztFiv9uJ077Qp4fBHOx6xW7Zp7XE79lFLKqfK6flFluVL1
BjUffFSApBakwvEkZevqf715FOFGytMr8kfoYWmQWeOYym7Gq4DDfbA93EZYNRQT
fmkLh/Rf/qsvwgF/faylcb6YpsEtMmRKS15IzbpR9/jNUWW51BT43TpzpcVft4Gl
uGEeGwJps6yQYVddLRt2Lo1xmBrObUjiuGqtP6lAUcM5mD92CXlw0P9DjOpD1eu/
+JXqWMccA9gauDgEZZb+wRIKKwYBBAGXVQEFAQEHQJN4ZZLritsDAnNKKiHrLRSt
3n+kYiPlQR3IAWuOGIoOAwEIB4h+BBgWCgAmAhsMFiEEYy4qTb/j80NaLyG/lClu
8uyb5oMFAmbvRngFCQFZmTcACgkQlClu8uyb5oMNqgD9EZiNXru8oX7cT1EhkZ80
XebmipAgM5KqX7o8jxDVItMA/A7OKtfuExkeNh+shFYsbDiNxx0xfWL5guz2qciN
W24NmDMEYBW6BBYJKwYBBAHaRw8BAQdAWWTgOvzlX/x5OiYhMLK72aKOMvr0g6KI
aynmN2YMp5OIsgQgFgoAWhYhBAzGrFQcetxzPGQWEGNnA1dzlTEvBQJm700EPB0C
QWNjaWRlbnRhbGx5IHN0b3JlZCBvbiBkZXZpY2Ugd2l0aG91dCBmdWxsIGRpc2sg
ZW5jcnlwdGlvbgAKCRBjZwNXc5UxL6apAPwIlU0HLigBZ5VJ8dZxH4yvQjfkHbS0
pfDvJbgZgmA7wQEAke8ZBoQBgvHkXaHqCk0GSsXTrI8DzjyjhvHHj8JnVAS0M0pv
bmF0aGFuIFNjaGxlaWZlciAoQ29tbWl0IFNpZ25pbmcgS2V5KSA8anNAbmlsLmlt
PoiaBBMWCgBCAhsDCAsJCg0MCAsHBhUKCQgLAwUWAwIBAAIeAQIXgBYhBAzGrFQc
etxzPGQWEGNnA1dzlTEvBQJj6WYYBQkFtN+UAAoJEGNnA1dzlTEvXKQBAPQ4mbtE
mbuMbfpeV3pMP8bO1OhOB4/Thx4tUrrV7JcjAQCveLdvBrB+cSh+DA7edl6/XWfa
fCT0qrzRFhaoEZhxDbg4BGAVugQSCisGAQQBl1UBBQEBB0A2sxWorhv9BEE+urAm
X5GBUfcCdta9Un6Et5wEG5jLVAMBCAeIfgQYFgoAJgIbDBYhBAzGrFQcetxzPGQW
EGNnA1dzlTEvBQJj6WYtBQkFtN+pAAoJEGNnA1dzlTEvi+8BANiiPjamWJ3iSeME
aaYPoZXNZ7NAHlK0UUgQvB/osfQWAP9NKXMO7P5R/K+D2nRE/Ndmk0lqBykzumou
PVuR21pYB5gzBF4kWwEWCSsGAQQB2kcPAQEHQKNN/tu5oB43GAulu/3+PhSByMln
3tJOQBoztdpz4ODWtDdKb25hdGhhbiBTY2hsZWlmZXIgKE9iakZXIFNpZ25pbmcg
S2V5IDIwMjApIDxqc0BuaWwuaW0+iJkEExYKAEEWIQQw5pSPrIBCtYy0qW7ivM5r
NeGviwUCXiRbKQIbAwUJAeEzgAcLCg0MCAsHBhUKCQgLAwUWAwIBAAIeAQIXgAAK
CRDivM5rNeGvi1ACAP4/jk3H9gaTZD8nMHP5xux21yFrsh6GBe6WW13fEuN3CwEA
yh59VbAc4lrurXRlHEM3jyQMYP6SKq9J0i8pEa4uYwCJAjMEEwEKAB0WIQRtHsIm
m8C1RZyLqSDP2rQfgpLO7gUCXoowdwAKCRDP2rQfgpLO7scsEACjaK3RyLYe4lPX
7HWfvh0EjmfApqTXk6gAFbfu/G3XSAx2bXCj2GrRwmitd1CYTTukxakybPzzdiBr
KpNfIQknJ1WqreuBHXNwQo4amIlPprNF8bFy+w2Hxsy2j10LpxVWaSfJ3K81ODvd
Omh8+ZGUfxbyC3zDnkSI7cuThEk4PMaEI6sPFtHWj2sXf19QeP6Dc0HuCsr9NO11
m+iY5L6Zwz6kA1iK85OYxzmafSYRW5rcXrBG9RyTyKPYkVO8nkZXfGJ7okgNraGX
+EzYEvHZdGvCOcP6SKD8KOmgUQ/xvNz56kdvo4MC3ZJDmLhnHfRMVaJV56WNfVDM
Wrml8mvedsdA2GTOy7e5Zd+pS7UzqYFp3NiYtgsOBUUsUp3CEGBu8ievf1QC3ARi
XvQ2iqBWzA/NZKQDKstazT7ZdRdmXKEXE1o6qF5YTtVC/8M9gME9euKbd/kCW/Y+
1AnYFcO+XU/IODoKSDo97pehUo8nAxiyJZk6uydFEnN5BZrXMWxVZf4Jgg0+IRi/
guzY4UZmPru3M1TxZ/YQVs2ab9Xzaxes967SKpwn31prFnD62T6HlZLQGJdx5n0n
p1EqjaockkCrQUmcC37o1FqbUpgCSd33LqDlLZtGqIjXAmaKeaSxtItDnCZ66eUT
KfKVIgnH5RtcFhVu+aktZkUVFQoEzrQ4Sm9uYXRoYW4gU2NobGVpZmVyIChDb21t
aXQgU2lnbmluZyBLZXkgMjAyMCkgPGpzQG5pbC5pbT6ImQQTFgoAQRYhBDDmlI+s
gEK1jLSpbuK8zms14a+LBQJeJFsBAhsDBQkB4TOABwsKDQwICwcGFQoJCAsDBRYD
AgEAAh4BAheAAAoJEOK8zms14a+Lge4A+wSLfxHsTzvXqba5rYq8UHcIKVIKxVO1
mNshAEQfND+IAP9QRm2No1Rb8x/y8UTFueoV6zR3AXSno/NDQYuLHXYlAokCMwQT
AQoAHRYhBG0ewiabwLVFnIupIM/atB+Cks7uBQJeijCBAAoJEM/atB+Cks7uO0AP
/jTdaySqg+fD7ChZp4I9lxNTUtD+jltpRTFtANZMBQ1q/eHMPEENDXI9pxmHAG55
rpI2esRnBznB3lM+jOH2xd1rLe+oN7pH38BP4yiTElPcRam1NeZxrBFLIN0U1mtX
womp8ONE2S/0irGyOOn18PlXDzNUL8oivQk6rajHONT5a6ST3g2FI5TYsNFpAtXy
8yldlGlUmHfT7uurjqxPOFmoHkCxN0HKQU6xOX0tGZElecuN0r/hTu6GiPme19FD
M9QbeaZsd/lGUahAgWrYHKinQyIZVaMcj3cLk5Tt/KN+cBGcQ06oKBTGz7Jdq5gn
7CeCp0mugYSj/mSBsnGlOSy4r3NDcMO0TWnnLjypy3SC/DeFjPVQa+kRDb8+tzLW
rQ1ziHNDbOsb2M7n3vUpbZqVRPmWsguizXtkmU3mkjw0eFq3tP1FfzbOIHV9AoY7
NtKPFPyBdqzL2BsyHzD3ObWmtnX5VFBPwkYtg8czqZkgPbQXWrlxEtPjVTJONJ7P
NK1yL/Oj91AoUppNf0p6xNLBVL1mWjvKV1SAf6VbJpKMX1UKuPI0jdhsQn78Wq2v
DECnyTMW+I53tHkXjMAkFHCB9A0jjq/0Xdf0qlpN664mGbgq/Ko9ET/QbSid3wbI
lh4+gveMyF+XnTXrdw7r1MZfIma8rABMRrXFFTyf2UT1uDgEXiRbARIKKwYBBAGX
VQEFAQEHQJzpQHQ8PSSml1jJ4lXe5dK5eTuy1LqyLf3ck8oVfbAyAwEIB4h+BBgW
CgAmFiEEMOaUj6yAQrWMtKlu4rzOazXhr4sFAl4kWwECGwwFCQHhM4AACgkQ4rzO
azXhr4vtSgEAmQ1dmxjfMd6JJDbdh5oAFBRO2mNZvSjrGWOrc9dH+EQA/jhG9/eF
OQ88O4wIl6U7HOS+vze6lgIjIik/kenOoVYGmDMEXED5xxYJKwYBBAHaRw8BAQdA
h7Q0riedqDIg3HpnYMm3iVTO/trt7rE8uJ8S+jWJBWm0OkpvbmF0aGFuIFNjaGxl
aWZlciAoT2JqRlcgU2lnbmluZyBLZXkgMjAxOSkgPGpzQGhlYXAuem9uZT6ImQQT
FgoAQRYhBC0rHuxBdq5nqm+XYHnSEYmi1HCNBQJcQPnnAhsDBQkB4TOABwsKDQwI
CwcGFQoJCAsDBRYDAgEAAh4BAheAAAoJEHnSEYmi1HCN64gA/3BDyv7XdLRkc+Y6
R5VA2qlV2+zOKx+zNAo1GuQqtLt+AQAAXh4jghdvXfHmEe/NifYMwx7a6DHougJ3
NhxWW8UVDrQ7Sm9uYXRoYW4gU2NobGVpZmVyIChDb21taXQgU2lnbmluZyBLZXkg
MjAxOSkgPGpzQGhlYXAuem9uZT6ImQQTFgoAQRYhBC0rHuxBdq5nqm+XYHnSEYmi
1HCNBQJcQPnHAhsDBQkB4TOABwsKDQwICwcGFQoJCAsDBRYDAgEAAh4BAheAAAoJ
EHnSEYmi1HCNdN0A/ihgciDn4sGF875I1JCXTTwoffkqbI7jG1k8p9xtaNdyAP91
ZWpkONRiQKz/Simt0kNk9EEgHlBCGNzW6ffz54KIB5gzBFrcs+4WCSsGAQQB2kcP
AQEHQLMNq++FogeeDa+97GNrMQS7tEVIHrNoj3gaK9VnOgq3tDtKb25hdGhhbiBT
Y2hsZWlmZXIgKENvbW1pdCBTaWduaW5nIEtleSAyMDE4KSA8anNAaGVhcC56b25l
PoiZBBMWCgBBAhsDBwsKDQwICwcGFQoJCAsDBRYDAgEAAh4BAheAFiEExsWOwu+J
CR4OE81Y2Dp2v+N2NF4FAlxEs6QFCQFpUTYACgkQ2Dp2v+N2NF4QNQD+JyIgVC9p
zLZAyUm0m9P5G8iKEzYUV7ZSOHK2CKn7NO4A/jTHRx8zJxrR5KWl+xgKlU3k4k4W
VJ0xjTMJ1fWnq0EHtDpKb25hdGhhbiBTY2hsZWlmZXIgKE9iakZXIFNpZ25pbmcg
S2V5IDIwMTgpIDxqc0BoZWFwLnpvbmU+iJkEExYKAEECGwMHCwoNDAgLBwYVCgkI
CwMFFgMCAQACHgECF4AWIQTGxY7C74kJHg4TzVjYOna/43Y0XgUCXESzqAUJAWlR
NgAKCRDYOna/43Y0Xg1aAQDb5CGFEy3pqIN1IY2WIWXb6vQMXety9pZ6c5vhaK97
TQD/RpicG6v6IvBNJgMHrG70GGP0eDTjiiHVe65FYyc6Hgg=
=jW3V
-----END PGP PUBLIC KEY BLOCK-----
objfw-1.3/src 040755 001750 001750 00000000000 14767513633 012251 5 ustar 00js js 000000 000000 objfw-1.3/src/Info.plist.in 100644 001750 001750 00000001233 14767513633 014701 0 ustar 00js js 000000 000000
CFBundleExecutable
ObjFW
CFBundleName
ObjFW
CFBundleIdentifier
im.nil.objfw
CFBundleInfoDictionaryVersion
6.0
CFBundlePackageType
FMWK
CFBundleVersion
@BUNDLE_VERSION@
CFBundleShortVersionString
@BUNDLE_SHORT_VERSION@
MinimumOSVersion
9.0
objfw-1.3/src/Makefile 100644 001750 001750 00000017677 14767513633 014007 0 ustar 00js js 000000 000000 include ../extra.mk
SUBDIRS = ${RUNTIME} exceptions encodings forwarding
SUBDIRS_AFTER = ${BRIDGE} ${TLS} hid test
DISTCLEAN = Info.plist objfw-defs.h
SHARED_LIB = ${OBJFW_SHARED_LIB}
STATIC_LIB = ${OBJFW_STATIC_LIB}
FRAMEWORK = ${OBJFW_FRAMEWORK}
LIB_MAJOR = ${OBJFW_LIB_MAJOR}
LIB_MINOR = ${OBJFW_LIB_MINOR}
LIB_PATCH = ${OBJFW_LIB_PATCH}
SRCS = OFApplication.m \
OFArray.m \
OFBlock.m \
OFCharacterSet.m \
OFColor.m \
OFConstantString.m \
OFCountedSet.m \
OFData.m \
OFData+CryptographicHashing.m \
OFData+MessagePackParsing.m \
OFDate.m \
OFDictionary.m \
OFEmbeddedIRIHandler.m \
OFEnumerator.m \
OFFileManager.m \
OFGZIPStream.m \
OFHMAC.m \
OFINICategory.m \
OFINIFile.m \
OFINISection.m \
OFIRI.m \
OFIRIHandler.m \
OFInflate64Stream.m \
OFInflateStream.m \
OFInvocation.m \
OFLHAArchive.m \
OFLHAArchiveEntry.m \
OFList.m \
OFLocale.m \
OFMD5Hash.m \
OFMapTable.m \
OFMatrix4x4.m \
OFMemoryStream.m \
OFMessagePackExtension.m \
OFMethodSignature.m \
OFMutableArray.m \
OFMutableData.m \
OFMutableDictionary.m \
OFMutableIRI.m \
OFMutableLHAArchiveEntry.m \
OFMutablePair.m \
OFMutableSet.m \
OFMutableString.m \
OFMutableTarArchiveEntry.m \
OFMutableTriple.m \
OFMutableZIPArchiveEntry.m \
OFMutableZooArchiveEntry.m \
OFNotification.m \
OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
OFOnce.m \
OFOptionsParser.m \
OFPBKDF2.m \
OFPair.m \
OFRIPEMD160Hash.m \
OFRunLoop.m \
OFSHA1Hash.m \
OFSHA224Hash.m \
OFSHA224Or256Hash.m \
OFSHA256Hash.m \
OFSHA384Hash.m \
OFSHA384Or512Hash.m \
OFSHA512Hash.m \
OFScrypt.m \
OFSecureData.m \
OFSeekableStream.m \
OFSet.m \
OFSettings.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
OFString.m \
OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PercentEncoding.m \
OFString+PropertyListParsing.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
OFXMLElementBuilder.m \
OFXMLNode.m \
OFXMLParser.m \
OFXMLProcessingInstruction.m \
OFZIPArchive.m \
OFZIPArchiveEntry.m \
OFZooArchive.m \
OFZooArchiveEntry.m \
${USE_SRCS_FILES} \
${USE_SRCS_MODULES} \
${USE_SRCS_SOCKETS} \
${USE_SRCS_SUBPROCESSES} \
${USE_SRCS_THREADS} \
${USE_SRCS_WINDOWS}
SRCS_FILES = OFFile.m \
OFString+PathAdditions.m
SRCS_MODULES = OFPlugin.m \
OFModule.m
SRCS_SOCKETS = OFAAAADNSResourceRecord.m \
OFADNSResourceRecord.m \
OFCNAMEDNSResourceRecord.m \
OFDNSQuery.m \
OFDNSResolver.m \
OFDNSResourceRecord.m \
OFDNSResponse.m \
OFDatagramSocket.m \
OFHINFODNSResourceRecord.m \
OFHTTPClient.m \
OFHTTPCookie.m \
OFHTTPCookieManager.m \
OFHTTPRequest.m \
OFHTTPResponse.m \
OFHTTPServer.m \
OFLOCDNSResourceRecord.m \
OFMXDNSResourceRecord.m \
OFNSDNSResourceRecord.m \
OFPTRDNSResourceRecord.m \
OFRPDNSResourceRecord.m \
OFSOADNSResourceRecord.m \
OFSRVDNSResourceRecord.m \
OFSequencedPacketSocket.m \
OFSocket.m \
OFStreamSocket.m \
OFSystemInfo+NetworkInterfaces.m \
OFTCPSocket.m \
OFTLSStream.m \
OFTXTDNSResourceRecord.m \
OFUDPSocket.m \
OFURIDNSResourceRecord.m \
OFX509Certificate.m \
${USE_SRCS_APPLETALK} \
${USE_SRCS_IPX} \
${USE_SRCS_SCTP} \
${USE_SRCS_UNIX_SOCKETS}
SRCS_APPLETALK = OFDDPSocket.m
SRCS_IPX = OFIPXSocket.m \
OFSPXSocket.m \
OFSPXStreamSocket.m
SRCS_SCTP = OFSCTPSocket.m
SRCS_UNIX_SOCKETS = OFUNIXDatagramSocket.m \
OFUNIXSequencedPacketSocket.m \
OFUNIXStreamSocket.m
SRCS_SUBPROCESSES = OFSubprocess.m
SRCS_THREADS = OFCondition.m \
OFMutex.m \
OFPlainCondition.m \
OFPlainMutex.m \
OFPlainThread.m \
OFRecursiveMutex.m \
OFTLSKey.m
SRCS_WINDOWS = OFWindowsRegistryKey.m
INCLUDES_ATOMIC = OFAtomic.h \
platform/GCC4/OFAtomic.h \
platform/GCC4.7/OFAtomic.h \
platform/PowerPC/OFAtomic.h \
platform/macOS/OFAtomic.h \
platform/x86/OFAtomic.h
INCLUDES := ${SRCS:.m=.h} \
OFArchiveEntry.h \
OFCollection.h \
OFCryptographicHash.h \
OFJSONRepresentation.h \
OFKernelEventObserver.h \
OFKeyValueCoding.h \
OFLocking.h \
OFMessagePackRepresentation.h \
OFMutableArchiveEntry.h \
ObjFW.h \
macros.h \
objfw-defs.h \
platform.h \
${USE_INCLUDES_ATOMIC}
SRCS += OFASPrintF.m \
OFArchiveIRIHandler.m \
OFBase64.m \
OFBitSetCharacterSet.m \
OFCRC16.m \
OFCRC32.m \
OFConcreteArray.m \
OFConcreteColor.m \
OFConcreteCountedSet.m \
OFConcreteData.m \
OFConcreteDate.m \
OFConcreteDictionary.m \
OFConcreteMutableArray.m \
OFConcreteMutableData.m \
OFConcreteMutableDictionary.m \
OFConcreteMutableSet.m \
OFConcreteNumber.m \
OFConcreteSet.m \
OFConcreteSubarray.m \
OFConcreteValue.m \
OFHuffmanTree.m \
OFINIFileSettings.m \
OFInvertedCharacterSet.m \
OFLHADecompressingStream.m \
OFMutableUTF8String.m \
OFRangeCharacterSet.m \
OFSandbox.m \
OFStrFTime.m \
OFStrPTime.m \
OFSubarray.m \
OFSubdata.m \
OFUTF8String.m \
${AUTORELEASE_FOUNDATION_M} \
${LIBBASES_M} \
${RUNTIME_ASSOCIATION_M} \
${RUNTIME_INSTANCE_M} \
${UNICODE_M} \
${USE_SRCS_TAGGED_POINTERS}
SRCS_FILES += OFFileIRIHandler.m
SRCS_SOCKETS += OFAsyncIPSocketConnector.m \
OFDNSResolverSettings.m \
${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
OFHTTPIRIHandler.m \
OFHostAddressResolver.m \
OFKernelEventObserver.m \
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
OFTCPSocketSOCKS5Connector.m
SRCS_TAGGED_POINTERS = OFTaggedPointerColor.m \
OFTaggedPointerDate.m \
OFTaggedPointerNumber.m \
OFTaggedPointerString.m
SRCS_WINDOWS += platform/Windows/OFWin32ConsoleStdIOStream.m \
versioninfo.rc
OBJS_EXTRA = exceptions/exceptions.a \
encodings/encodings.a \
forwarding/forwarding.a
LIB_OBJS_EXTRA = exceptions/exceptions.lib.a \
encodings/encodings.lib.a \
forwarding/forwarding.lib.a
include ../buildsys.mk
${TLS} hid: ${BRIDGE}
CPPFLAGS += -I. -I.. -Iexceptions -Iruntime
LD = ${OBJC}
FRAMEWORK_LIBS := -Fruntime \
${RUNTIME_FRAMEWORK_LIBS} \
${REEXPORT_RUNTIME_FRAMEWORK} \
${LIBS}
LIBS := -Lruntime ${RUNTIME_LIBS} ${REEXPORT_RUNTIME} ${LIBS}
RCFLAGS = --use-temp-file \
-DOBJFW_LIB_MAJOR=${OBJFW_LIB_MAJOR} \
-DOBJFW_LIB_MINOR=${OBJFW_LIB_MINOR} \
-DOBJFW_LIB_VERSION=\"${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}\" \
-DOBJFW_SHARED_LIB=\"${OBJFW_SHARED_LIB}\"
uninstall-extra:
for i in platform/GCC4 platform/GCC4.7 platform/PowerPC platform/macOS \
platform/x86 platform ""; do \
if test -d ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
rmdir ${DESTDIR}${includedir}/${includesubdir}/$$i; \
fi; \
done
objfw-1.3/src/OFAAAADNSResourceRecord.h 100644 001750 001750 00000003501 14767513633 016621 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDNSResourceRecord.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFAAAADNSResourceRecord OFAAAADNSResourceRecord.h ObjFW/ObjFW.h
*
* @brief A class representing a DNS resource record.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFAAAADNSResourceRecord: OFDNSResourceRecord
{
OFSocketAddress _address;
}
/**
* @brief The IPv6 address of the resource record.
*/
@property (readonly, nonatomic) const OFSocketAddress *address;
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
recordType: (OFDNSRecordType)recordType
TTL: (uint32_t)TTL OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFAAAADNSResourceRecord with the
* specified name, class, address and time to live.
*
* @param name The name for the resource record
* @param address The address for the resource record
* @param TTL The time to live for the resource record
* @return An initialized OFAAAADNSResourceRecord
*/
- (instancetype)initWithName: (OFString *)name
address: (const OFSocketAddress *)address
TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFAAAADNSResourceRecord.m 100644 001750 001750 00000004574 14767513633 016641 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFAAAADNSResourceRecord.h"
@implementation OFAAAADNSResourceRecord
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
recordType: (OFDNSRecordType)recordType
TTL: (uint32_t)TTL
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithName: (OFString *)name
address: (const OFSocketAddress *)address
TTL: (uint32_t)TTL
{
self = [super initWithName: name
DNSClass: OFDNSClassIN
recordType: OFDNSRecordTypeAAAA
TTL: TTL];
_address = *address;
return self;
}
- (const OFSocketAddress *)address
{
return &_address;
}
- (bool)isEqual: (id)object
{
OFAAAADNSResourceRecord *record;
if (object == self)
return true;
if (![object isKindOfClass: [OFAAAADNSResourceRecord class]])
return false;
record = object;
if (record->_name != _name && ![record->_name isEqual: _name])
return false;
if (record->_DNSClass != _DNSClass)
return false;
if (record->_recordType != _recordType)
return false;
if (!OFSocketAddressEqual(&record->_address, &_address))
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
OFHashAddHash(&hash, _name.hash);
OFHashAddByte(&hash, _DNSClass >> 8);
OFHashAddByte(&hash, _DNSClass);
OFHashAddByte(&hash, _recordType >> 8);
OFHashAddByte(&hash, _recordType);
OFHashAddHash(&hash, OFSocketAddressHash(&_address));
OFHashFinalize(&hash);
return hash;
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"<%@:\n"
@"\tName = %@\n"
@"\tAddress = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
self.className, _name, OFSocketAddressString(&_address), _TTL];
}
@end
objfw-1.3/src/OFADNSResourceRecord.h 100644 001750 001750 00000003465 14767513633 016327 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDNSResourceRecord.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFADNSResourceRecord OFADNSResourceRecord.h ObjFW/ObjFW.h
*
* @brief A class representing an A DNS resource record.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFADNSResourceRecord: OFDNSResourceRecord
{
OFSocketAddress _address;
}
/**
* @brief The IPv4 address of the resource record.
*/
@property (readonly, nonatomic) const OFSocketAddress *address;
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
recordType: (OFDNSRecordType)recordType
TTL: (uint32_t)TTL OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFADNSResourceRecord with the
* specified name, class, address and time to live.
*
* @param name The name for the resource record
* @param address The address for the resource record
* @param TTL The time to live for the resource record
* @return An initialized OFADNSResourceRecord
*/
- (instancetype)initWithName: (OFString *)name
address: (const OFSocketAddress *)address
TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFADNSResourceRecord.m 100644 001750 001750 00000004555 14767513633 016335 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFADNSResourceRecord.h"
@implementation OFADNSResourceRecord
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
recordType: (OFDNSRecordType)recordType
TTL: (uint32_t)TTL
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithName: (OFString *)name
address: (const OFSocketAddress *)address
TTL: (uint32_t)TTL
{
self = [super initWithName: name
DNSClass: OFDNSClassIN
recordType: OFDNSRecordTypeA
TTL: TTL];
_address = *address;
return self;
}
- (const OFSocketAddress *)address
{
return &_address;
}
- (bool)isEqual: (id)object
{
OFADNSResourceRecord *record;
if (object == self)
return true;
if (![object isKindOfClass: [OFADNSResourceRecord class]])
return false;
record = object;
if (record->_name != _name && ![record->_name isEqual: _name])
return false;
if (record->_DNSClass != _DNSClass)
return false;
if (record->_recordType != _recordType)
return false;
if (!OFSocketAddressEqual(&record->_address, &_address))
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
OFHashAddHash(&hash, _name.hash);
OFHashAddByte(&hash, _DNSClass >> 8);
OFHashAddByte(&hash, _DNSClass);
OFHashAddByte(&hash, _recordType >> 8);
OFHashAddByte(&hash, _recordType);
OFHashAddHash(&hash, OFSocketAddressHash(&_address));
OFHashFinalize(&hash);
return hash;
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"<%@:\n"
@"\tName = %@\n"
@"\tAddress = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
self.className, _name, OFSocketAddressString(&_address), _TTL];
}
@end
objfw-1.3/src/OFASPrintF.h 100644 001750 001750 00000002160 14767513633 014350 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#include
#import "macros.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFVASPrintF(
char *_Nullable *_Nonnull, const char *_Nonnull, va_list)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFASPrintF.m 100644 001750 001750 00000041400 14767513633 014355 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#include
#include
#include
#include
#ifdef HAVE_WCHAR_H
# include
#endif
#if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE)
# include
#endif
#ifdef HAVE_XLOCALE_H
# include
#endif
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#import "OFASPrintF.h"
#import "OFLocale.h"
#import "OFString.h"
#import "OFString+Private.h"
#import "OFInitializationFailedException.h"
#define maxSubformatLen 64
#ifndef HAVE_ASPRINTF
/*
* (v)asprintf might be declared, but HAVE_ASPRINTF not defined because
* configure determined it is broken. In this case, we must make sure there is
* no name clash.
*/
# define asprintf asprintf_
# define vasprintf vasprintf_
#endif
struct Context {
const char *format;
size_t formatLen;
char subformat[maxSubformatLen + 1];
size_t subformatLen;
va_list arguments;
char *buffer;
size_t bufferLen;
size_t i, last;
enum {
stateString,
stateFormatFlags,
stateFormatFieldWidth,
stateFormatLengthModifier,
stateFormatConversionSpecifier
} state;
enum {
lengthModifierNone,
lengthModifierHH,
lengthModifierH,
lengthModifierL,
lengthModifierLL,
lengthModifierJ,
lengthModifierZ,
lengthModifierT,
lengthModifierCapitalL
} lengthModifier;
bool useLocale;
};
#if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE)
static locale_t cLocale;
OF_CONSTRUCTOR()
{
if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL)
@throw [OFInitializationFailedException exception];
}
#endif
#ifndef HAVE_ASPRINTF
static int
vasprintf(char **string, const char *format, va_list arguments)
{
int length;
size_t bufferLength = 128;
*string = NULL;
for (;;) {
free(*string);
if ((*string = malloc(bufferLength)) == NULL)
return -1;
length = vsnprintf(*string, bufferLength - 1, format,
arguments);
if (length >= 0 && (size_t)length < bufferLength - 1)
break;
if (bufferLength > INT_MAX / 2) {
free(*string);
return -1;
}
bufferLength <<= 1;
}
if (length > 0 && (size_t)length != bufferLength - 1) {
char *resized = realloc(*string, length + 1);
/* Ignore if making it smaller failed. */
if (resized != NULL)
*string = resized;
}
return length;
}
static int
asprintf(char **string, const char *format, ...)
{
int ret;
va_list arguments;
va_start(arguments, format);
ret = vasprintf(string, format, arguments);
va_end(arguments);
return ret;
}
#endif
static bool
appendString(struct Context *ctx, const char *append, size_t appendLen)
{
char *newBuf;
if (appendLen == 0)
return true;
if ((newBuf = realloc(ctx->buffer,
ctx->bufferLen + appendLen + 1)) == NULL)
return false;
memcpy(newBuf + ctx->bufferLen, append, appendLen);
ctx->buffer = newBuf;
ctx->bufferLen += appendLen;
return true;
}
static bool
appendSubformat(struct Context *ctx, const char *subformat,
size_t subformatLen)
{
if (ctx->subformatLen + subformatLen > maxSubformatLen)
return false;
memcpy(ctx->subformat + ctx->subformatLen, subformat, subformatLen);
ctx->subformatLen += subformatLen;
ctx->subformat[ctx->subformatLen] = 0;
return true;
}
static bool
stringState(struct Context *ctx)
{
if (ctx->format[ctx->i] == '%') {
if (ctx->i > 0)
if (!appendString(ctx, ctx->format + ctx->last,
ctx->i - ctx->last))
return false;
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->last = ctx->i + 1;
ctx->state = stateFormatFlags;
}
return true;
}
static bool
formatFlagsState(struct Context *ctx)
{
switch (ctx->format[ctx->i]) {
case '-':
case '+':
case ' ':
case '#':
case '0':
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
break;
case ',':
/* ObjFW extension: Use decimal point from locale */
ctx->useLocale = true;
break;
default:
ctx->state = stateFormatFieldWidth;
ctx->i--;
break;
}
return true;
}
static bool
formatFieldWidthState(struct Context *ctx)
{
if ((ctx->format[ctx->i] >= '0' && ctx->format[ctx->i] <= '9') ||
ctx->format[ctx->i] == '*' || ctx->format[ctx->i] == '.') {
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
} else {
ctx->state = stateFormatLengthModifier;
ctx->i--;
}
return true;
}
static bool
formatLengthModifierState(struct Context *ctx)
{
/* Only one allowed */
switch (ctx->format[ctx->i]) {
case 'h': /* and also hh */
if (ctx->formatLen > ctx->i + 1 &&
ctx->format[ctx->i + 1] == 'h') {
if (!appendSubformat(ctx, ctx->format + ctx->i, 2))
return false;
ctx->i++;
ctx->lengthModifier = lengthModifierHH;
} else {
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->lengthModifier = lengthModifierH;
}
break;
case 'l': /* and also ll */
if (ctx->formatLen > ctx->i + 1 &&
ctx->format[ctx->i + 1] == 'l') {
#ifndef OF_WINDOWS
if (!appendSubformat(ctx, ctx->format + ctx->i, 2))
return false;
#else
if (!appendSubformat(ctx, "I64", 3))
return false;
#endif
ctx->i++;
ctx->lengthModifier = lengthModifierLL;
} else {
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->lengthModifier = lengthModifierL;
}
break;
case 'j':
#if defined(OF_WINDOWS)
if (!appendSubformat(ctx, "I64", 3))
return false;
#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX)
if (!appendSubformat(ctx, "ll", 2))
return false;
#else
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
#endif
ctx->lengthModifier = lengthModifierJ;
break;
case 'z':
#if defined(OF_WINDOWS)
if (sizeof(size_t) == 8)
if (!appendSubformat(ctx, "I64", 3))
return false;
#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX)
if (!appendSubformat(ctx, "l", 1))
return false;
#else
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
#endif
ctx->lengthModifier = lengthModifierZ;
break;
case 't':
#if defined(OF_WINDOWS)
if (sizeof(ptrdiff_t) == 8)
if (!appendSubformat(ctx, "I64", 3))
return false;
#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX)
if (!appendSubformat(ctx, "l", 1))
return false;
#else
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
#endif
ctx->lengthModifier = lengthModifierT;
break;
case 'L':
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->lengthModifier = lengthModifierCapitalL;
break;
#ifdef OF_WINDOWS
case 'I': /* win32 strangeness (I64 instead of ll or j) */
if (ctx->formatLen > ctx->i + 2 &&
ctx->format[ctx->i + 1] == '6' &&
ctx->format[ctx->i + 2] == '4') {
if (!appendSubformat(ctx, ctx->format + ctx->i, 3))
return false;
ctx->i += 2;
ctx->lengthModifier = lengthModifierLL;
} else
ctx->i--;
break;
#endif
#ifdef OF_IOS
case 'q': /* iOS uses this for PRI?64 */
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
ctx->lengthModifier = lengthModifierLL;
break;
#endif
default:
ctx->i--;
break;
}
ctx->state = stateFormatConversionSpecifier;
return true;
}
static bool
formatConversionSpecifierState(struct Context *ctx)
{
char *tmp = NULL;
int tmpLen = 0;
#if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE)
OFString *point;
#endif
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
switch (ctx->format[ctx->i]) {
case '@':
if (ctx->lengthModifier != lengthModifierNone)
return false;
ctx->subformat[ctx->subformatLen - 1] = 's';
@try {
id object;
if ((object = va_arg(ctx->arguments, id)) != nil) {
void *pool = objc_autoreleasePoolPush();
tmpLen = asprintf(&tmp, ctx->subformat,
[object description].UTF8String);
objc_autoreleasePoolPop(pool);
} else
tmpLen = asprintf(&tmp, ctx->subformat,
"(nil)");
} @catch (id e) {
free(ctx->buffer);
@throw e;
}
break;
case 'C':
if (ctx->lengthModifier != lengthModifierNone)
return false;
ctx->subformat[ctx->subformatLen - 1] = 's';
{
char buffer[5];
size_t len = _OFUTF8StringEncode(
va_arg(ctx->arguments, OFUnichar), buffer);
if (len == 0)
return false;
buffer[len] = 0;
tmpLen = asprintf(&tmp, ctx->subformat, buffer);
}
break;
case 'S':
if (ctx->lengthModifier != lengthModifierNone)
return false;
ctx->subformat[ctx->subformatLen - 1] = 's';
{
const OFUnichar *arg =
va_arg(ctx->arguments, const OFUnichar *);
size_t j, len = OFUTF32StringLength(arg);
char *buffer;
if (SIZE_MAX / 4 < len || (SIZE_MAX / 4) - len < 1)
return false;
if ((buffer = malloc((len * 4) + 1)) == NULL)
return false;
j = 0;
for (size_t i = 0; i < len; i++) {
size_t clen = _OFUTF8StringEncode(arg[i],
buffer + j);
if (clen == 0) {
free(buffer);
return false;
}
j += clen;
}
buffer[j] = 0;
tmpLen = asprintf(&tmp, ctx->subformat, buffer);
free(buffer);
}
break;
case 'd':
case 'i':
switch (ctx->lengthModifier) {
case lengthModifierNone:
case lengthModifierHH:
case lengthModifierH:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, int));
break;
case lengthModifierL:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long));
break;
case lengthModifierLL:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long long));
break;
case lengthModifierJ:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, intmax_t));
break;
case lengthModifierZ:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, ssize_t));
break;
case lengthModifierT:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, ptrdiff_t));
break;
default:
return false;
}
break;
case 'o':
case 'u':
case 'x':
case 'X':
switch (ctx->lengthModifier) {
case lengthModifierNone:
case lengthModifierHH:
case lengthModifierH:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, unsigned int));
break;
case lengthModifierL:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, unsigned long));
break;
case lengthModifierLL:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, unsigned long long));
break;
case lengthModifierJ:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, uintmax_t));
break;
case lengthModifierZ:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, size_t));
break;
case lengthModifierT:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, ptrdiff_t));
break;
default:
return false;
}
break;
case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
case 'a':
case 'A':
switch (ctx->lengthModifier) {
case lengthModifierNone:
case lengthModifierL:
#if defined(HAVE_ASPRINTF_L)
if (!ctx->useLocale)
tmpLen = asprintf_l(&tmp, cLocale,
ctx->subformat,
va_arg(ctx->arguments, double));
else
#elif defined(HAVE_USELOCALE)
if (!ctx->useLocale) {
locale_t previousLocale = uselocale(cLocale);
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, double));
uselocale(previousLocale);
} else
#endif
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, double));
break;
case lengthModifierCapitalL:
#if defined(HAVE_ASPRINTF_L)
if (!ctx->useLocale)
tmpLen = asprintf_l(&tmp, cLocale,
ctx->subformat,
va_arg(ctx->arguments, long double));
else
#elif defined(HAVE_USELOCALE)
if (!ctx->useLocale) {
locale_t previousLocale = uselocale(cLocale);
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long double));
uselocale(previousLocale);
} else
#endif
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long double));
break;
default:
return false;
}
#if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE)
if (tmpLen == -1)
return false;
/*
* If there's no asprintf_l and no uselocale, we have no other
* choice than to use this ugly hack to replace the locale's
* decimal point back to ".".
*/
point = [OFLocale decimalSeparator];
if (!ctx->useLocale && point != nil && ![point isEqual: @"."]) {
void *pool = objc_autoreleasePoolPush();
char *tmp2;
@try {
OFMutableString *tmpStr = [OFMutableString
stringWithUTF8String: tmp
length: tmpLen];
[tmpStr replaceOccurrencesOfString: point
withString: @"."];
if (tmpStr.UTF8StringLength > INT_MAX)
return false;
tmpLen = (int)tmpStr.UTF8StringLength;
tmp2 = malloc(tmpLen);
memcpy(tmp2, tmpStr.UTF8String, tmpLen);
} @finally {
free(tmp);
objc_autoreleasePoolPop(pool);
}
tmp = tmp2;
}
#endif
break;
case 'c':
switch (ctx->lengthModifier) {
case lengthModifierNone:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, int));
break;
case lengthModifierL:
#ifdef HAVE_WCHAR_H
# if WINT_MAX >= INT_MAX
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, wint_t));
# else
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, int));
# endif
break;
#endif
default:
return false;
}
break;
case 's':
switch (ctx->lengthModifier) {
case lengthModifierNone:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, const char *));
break;
#ifdef HAVE_WCHAR_T
case lengthModifierL:
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, const wchar_t *));
break;
#endif
default:
return false;
}
break;
case 'p':
if (ctx->lengthModifier != lengthModifierNone)
return false;
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, void *));
break;
case 'n':
switch (ctx->lengthModifier) {
case lengthModifierNone:
*va_arg(ctx->arguments, int *) = (int)ctx->bufferLen;
break;
case lengthModifierHH:
*va_arg(ctx->arguments, signed char *) =
(signed char)ctx->bufferLen;
break;
case lengthModifierH:
*va_arg(ctx->arguments, short *) =
(short)ctx->bufferLen;
break;
case lengthModifierL:
*va_arg(ctx->arguments, long *) =
(long)ctx->bufferLen;
break;
case lengthModifierLL:
*va_arg(ctx->arguments, long long *) =
(long long)ctx->bufferLen;
break;
case lengthModifierJ:
*va_arg(ctx->arguments, intmax_t *) =
(intmax_t)ctx->bufferLen;
break;
case lengthModifierZ:
*va_arg(ctx->arguments, size_t *) =
(size_t)ctx->bufferLen;
break;
case lengthModifierT:
*va_arg(ctx->arguments, ptrdiff_t *) =
(ptrdiff_t)ctx->bufferLen;
break;
default:
return false;
}
break;
case '%':
if (ctx->lengthModifier != lengthModifierNone)
return false;
if (!appendString(ctx, "%", 1))
return false;
break;
default:
return false;
}
if (tmpLen == -1)
return false;
if (tmp != NULL) {
if (!appendString(ctx, tmp, tmpLen)) {
free(tmp);
return false;
}
free(tmp);
}
memset(ctx->subformat, 0, maxSubformatLen);
ctx->subformatLen = 0;
ctx->lengthModifier = lengthModifierNone;
ctx->useLocale = false;
ctx->last = ctx->i + 1;
ctx->state = stateString;
return true;
}
static bool (*states[])(struct Context *) = {
stringState,
formatFlagsState,
formatFieldWidthState,
formatLengthModifierState,
formatConversionSpecifierState
};
int
_OFVASPrintF(char **string, const char *format, va_list arguments)
{
struct Context ctx;
ctx.format = format;
ctx.formatLen = strlen(format);
memset(ctx.subformat, 0, maxSubformatLen + 1);
ctx.subformatLen = 0;
va_copy(ctx.arguments, arguments);
ctx.bufferLen = 0;
ctx.last = 0;
ctx.state = stateString;
ctx.lengthModifier = lengthModifierNone;
ctx.useLocale = false;
if ((ctx.buffer = malloc(1)) == NULL)
return -1;
for (ctx.i = 0; ctx.i < ctx.formatLen; ctx.i++) {
if (!states[ctx.state](&ctx)) {
free(ctx.buffer);
return -1;
}
}
if (ctx.state != stateString) {
free(ctx.buffer);
return -1;
}
if (!appendString(&ctx, ctx.format + ctx.last,
ctx.formatLen - ctx.last)) {
free(ctx.buffer);
return -1;
}
ctx.buffer[ctx.bufferLen] = 0;
*string = ctx.buffer;
return (ctx.bufferLen <= INT_MAX ? (int)ctx.bufferLen : -1);
}
objfw-1.3/src/OFApplication.h 100644 001750 001750 00000023623 14767513633 015174 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include
#import "OFObject.h"
#import "OFNotification.h"
#ifdef OF_WINDOWS
# include
#endif
OF_ASSUME_NONNULL_BEGIN
/** @file */
@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
@class OFSandbox;
@class OFString;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief A notification that will be sent when the application did finish
* launching.
*/
extern const OFNotificationName OFApplicationDidFinishLaunchingNotification;
/**
* @brief A notification that will be sent when the application will terminate.
*/
extern const OFNotificationName OFApplicationWillTerminateNotification;
#ifdef __cplusplus
}
#endif
/**
* @brief Specify the class to be used as the application delegate.
*
* An instance of this class will be created and act as the application
* delegate.
*
* For example, it can be used like this:
*
* @code
* // In MyAppDelegate.h:
* @interface MyAppDelegate: OFObject
* @end
*
* // In MyAppDelegate.m:
* OF_APPLICATION_DELEGATE(MyAppDelegate)
*
* @implementation MyAppDelegate
* - (void)applicationDidFinishLaunching: (OFNotification *)notification
* {
* [OFApplication terminate];
* }
* @end
* @endcode
*/
#ifndef OF_WINDOWS
# define OF_APPLICATION_DELEGATE(class_) \
int \
main(int argc, char *argv[]) \
{ \
return OFApplicationMain(&argc, &argv, \
(class_ *)[[class_ alloc] init]); \
}
#else
# define OF_APPLICATION_DELEGATE(class_) \
int \
main(int argc, char *argv[]) \
{ \
return OFApplicationMain(&argc, &argv, \
(class_ *)[[class_ alloc] init]); \
} \
\
WINAPI int \
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, \
LPSTR lpCmdLine, int nShowCmd) \
{ \
int argc = 0, si = 0; \
char **argv = NULL, **envp = NULL; \
\
__getmainargs(&argc, &argv, &envp, _CRT_glob, &si); \
\
return OFApplicationMain(&argc, &argv, \
(class_ *)[[class_ alloc] init]); \
}
# ifdef __cplusplus
extern "C" {
# endif
extern void __getmainargs(int *_Nonnull, char *_Nonnull *_Nullable *_Nullable,
char *_Nonnull *_Nullable *_Nullable, int, int *_Nonnull);
extern int _CRT_glob;
# ifdef __cplusplus
}
# endif
#endif
#ifdef OF_HAVE_PLEDGE
# define OF_HAVE_SANDBOX
#endif
/**
* @protocol OFApplicationDelegate OFApplication.h ObjFW/ObjFW.h
*
* @brief A protocol for delegates of OFApplication.
*
* @note Signals are not available on AmigaOS!
*/
@protocol OFApplicationDelegate
/**
* @brief A method which is called when the application was initialized and is
* running now.
*
* @param notification A notification with name
* OFApplicationDidFinishLaunchingNotification
*/
- (void)applicationDidFinishLaunching: (OFNotification *)notification;
@optional
/**
* @brief A method which is called when the application will terminate.
*
* @param notification A notification with name
* OFApplicationWillTerminateNotification
*/
- (void)applicationWillTerminate: (OFNotification *)notification;
/**
* @brief A method which is called when the application received a SIGINT.
*
* @warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
*/
- (void)applicationDidReceiveSIGINT;
#ifdef SIGHUP
/**
* @brief A method which is called when the application received a SIGHUP.
*
* This signal is not available on Windows.
*
* @warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
*/
- (void)applicationDidReceiveSIGHUP;
#endif
#ifdef SIGUSR1
/**
* @brief A method which is called when the application received a SIGUSR1.
*
* This signal is not available on Windows.
*
* @warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
*/
- (void)applicationDidReceiveSIGUSR1;
#endif
#ifdef SIGUSR2
/**
* @brief A method which is called when the application received a SIGUSR2.
*
* This signal is not available on Windows.
*
* @warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
*/
- (void)applicationDidReceiveSIGUSR2;
#endif
@end
/**
* @class OFApplication OFApplication.h ObjFW/ObjFW.h
*
* @brief A class which represents the application as an object.
*
* In order to create a new OFApplication, you should create a class conforming
* to the optional @ref OFApplicationDelegate protocol and put
* `OF_APPLICATION_DELEGATE(NameOfYourClass)` in the .m file of that class.
*
* When the application is about to be terminated,
* @ref OFApplicationDelegate#applicationWillTerminate: will be called on the
* delegate and an @ref OFApplicationWillTerminateNotification will be sent.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFApplication: OFObject
{
OFString *_programName;
OFArray OF_GENERIC(OFString *) *_arguments;
OFMutableDictionary OF_GENERIC(OFString *, OFString *) *_environment;
int *_argc;
char ***_argv;
id _Nullable _delegate;
void (*_Nullable _SIGINTHandler)(id, SEL);
#ifndef OF_WINDOWS
void (*_Nullable _SIGHUPHandler)(id, SEL);
void (*_Nullable _SIGUSR1Handler)(id, SEL);
void (*_Nullable _SIGUSR2Handler)(id, SEL);
#endif
#ifdef OF_HAVE_SANDBOX
OFSandbox *_Nullable _activeSandbox;
OFSandbox *_Nullable _activeSandboxForChildProcesses;
#endif
}
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nullable, nonatomic)
OFApplication *sharedApplication;
@property (class, readonly, nullable, nonatomic) OFString *programName;
@property (class, readonly, nullable, nonatomic)
OFArray OF_GENERIC(OFString *) *arguments;
@property (class, readonly, nullable, nonatomic)
OFDictionary OF_GENERIC(OFString *, OFString *) *environment;
#endif
/**
* @brief The name of the program (argv[0]).
*/
@property (readonly, nonatomic) OFString *programName;
/**
* @brief The arguments passed to the application.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *arguments;
/**
* @brief The environment of the application.
*/
@property (readonly, nonatomic)
OFDictionary OF_GENERIC(OFString *, OFString *) *environment;
/**
* @brief The delegate of the application.
*/
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
id delegate;
#ifdef OF_HAVE_SANDBOX
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFSandbox *activeSandbox;
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
OFSandbox *activeSandboxForChildProcesses;
#endif
/**
* @brief Returns the only OFApplication instance in the application.
*
* @return The only OFApplication instance in the application
*/
+ (nullable OFApplication *)sharedApplication;
/**
* @brief Returns the name of the program (argv[0]).
*
* @return The name of the program (argv[0])
*/
+ (nullable OFString *)programName;
/**
* @brief Returns the arguments passed to the application.
*
* @return The arguments passed to the application
*/
+ (nullable OFArray OF_GENERIC(OFString *) *)arguments;
/**
* @brief Returns the environment of the application.
*
* @return The environment of the application
*/
+ (nullable OFDictionary OF_GENERIC(OFString *, OFString *) *)environment;
/**
* @brief Terminates the application with the EXIT_SUCCESS status.
*/
+ (void)terminate OF_NO_RETURN;
/**
* @brief Terminates the application with the specified status.
*
* @param status The status with which the application will terminate
*/
+ (void)terminateWithStatus: (int)status OF_NO_RETURN;
#ifdef OF_HAVE_SANDBOX
+ (void)of_activateSandbox: (OFSandbox *)sandbox;
+ (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox;
#endif
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Gets argc and argv.
*
* @param argc A pointer where a pointer to argc should be stored
* @param argv A pointer where a pointer to argv should be stored
*/
- (void)getArgumentCount: (int *_Nonnull *_Nonnull)argc
andArgumentValues: (char *_Nullable *_Nonnull *_Nonnull[_Nonnull])argv;
/**
* @brief Terminates the application.
*/
- (void)terminate OF_NO_RETURN;
/**
* @brief Terminates the application with the specified status.
*
* @param status The status with which the application will terminate
*/
- (void)terminateWithStatus: (int)status OF_NO_RETURN;
#ifdef OF_HAVE_SANDBOX
- (void)of_activateSandbox: (OFSandbox *)sandbox;
- (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox;
#endif
@end
#ifdef __cplusplus
extern "C" {
#endif
extern int OFApplicationMain(int *_Nonnull, char *_Nullable *_Nonnull[_Nonnull],
id );
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFApplication.m 100644 001750 001750 00000041065 14767513633 015201 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#include
#include
#include
#include
#include "unistd_wrapper.h"
#import "OFApplication.h"
#import "OFArray.h"
#import "OFDictionary.h"
#ifdef OF_AMIGAOS
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFLocale.h"
#import "OFNotificationCenter.h"
#import "OFPair.h"
#import "OFRunLoop+Private.h"
#import "OFRunLoop.h"
#import "OFSandbox.h"
#ifdef OF_HAVE_SOCKETS
# import "OFSocket.h"
# import "OFSocket+Private.h"
#endif
#import "OFStdIOStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFThread+Private.h"
#import "OFThread.h"
#import "OFActivateSandboxFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#if defined(OF_MACOS)
# include
#elif defined(OF_WINDOWS)
# include
#elif defined(OF_AMIGAOS)
# define Class IntuitionClass
# include
# include
# undef Class
#elif !defined(OF_IOS)
extern char **environ;
#endif
#ifdef OF_PSP
# include
# include
#endif
#ifdef OF_NINTENDO_DS
# define asm __asm__
# include
# undef asm
#endif
OF_DIRECT_MEMBERS
@interface OFApplication ()
- (instancetype)of_init OF_METHOD_FAMILY(init);
- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv;
#ifdef OF_WINDOWS
- (void)of_setArgumentCount: (int *)argc
andArgumentValues: (char **[])argv
andWideArgumentCount: (int)wargc
andWideArgumentValues: (wchar_t *[])wargv;
#endif
- (void)of_run;
@end
const OFNotificationName OFApplicationDidFinishLaunchingNotification =
@"OFApplicationDidFinishLaunchingNotification";
const OFNotificationName OFApplicationWillTerminateNotification =
@"OFApplicationWillTerminateNotification";
static OFApplication *app = nil;
static void
atexitHandler(void)
{
id delegate = app.delegate;
OFNotification *notification = [OFNotification
notificationWithName: OFApplicationWillTerminateNotification
object: app];
if ([delegate respondsToSelector: @selector(applicationWillTerminate:)])
[delegate applicationWillTerminate: notification];
[delegate release];
[[OFNotificationCenter defaultCenter] postNotification: notification];
#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \
defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
_OFSocketDeinit();
#endif
}
int
OFApplicationMain(int *argc, char **argv[], id delegate)
{
[OFLocale currentLocale];
app = [[OFApplication alloc] of_init];
#ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT]) {
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int,
int *);
extern int _CRT_glob;
wchar_t **wargv, **wenvp;
int wargc, si = 0;
__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);
[app of_setArgumentCount: argc
andArgumentValues: argv
andWideArgumentCount: wargc
andWideArgumentValues: wargv];
} else
#endif
[app of_setArgumentCount: argc andArgumentValues: argv];
app.delegate = delegate;
[app of_run];
[delegate release];
return 0;
}
@implementation OFApplication
@synthesize programName = _programName, arguments = _arguments;
@synthesize environment = _environment;
#ifdef OF_HAVE_SANDBOX
@synthesize activeSandbox = _activeSandbox;
@synthesize activeSandboxForChildProcesses = _activeSandboxForChildProcesses;
#endif
#define SIGNAL_HANDLER(signal) \
static void \
handle##signal(int sig) \
{ \
app->_##signal##Handler(app->_delegate, \
@selector(applicationDidReceive##signal)); \
}
SIGNAL_HANDLER(SIGINT)
#ifdef SIGHUP
SIGNAL_HANDLER(SIGHUP)
#endif
#ifdef SIGUSR1
SIGNAL_HANDLER(SIGUSR1)
#endif
#ifdef SIGUSR2
SIGNAL_HANDLER(SIGUSR2)
#endif
#undef SIGNAL_HANDLER
+ (OFApplication *)sharedApplication
{
return app;
}
+ (OFString *)programName
{
return app.programName;
}
+ (OFArray *)arguments
{
return app.arguments;
}
+ (OFDictionary *)environment
{
return app.environment;
}
+ (void)terminate
{
[self terminateWithStatus: EXIT_SUCCESS];
OF_UNREACHABLE
}
+ (void)terminateWithStatus: (int)status
{
#ifndef OF_PSP
exit(status);
OF_UNREACHABLE
#else
sceKernelExitGame();
OF_UNREACHABLE
#endif
}
#ifdef OF_HAVE_SANDBOX
+ (void)of_activateSandbox: (OFSandbox *)sandbox
{
[app of_activateSandbox: sandbox];
}
+ (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox
{
[app of_activateSandboxForChildProcesses: sandbox];
}
#endif
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_init
{
self = [super init];
@try {
_environment = [[OFMutableDictionary alloc] init];
atexit(atexitHandler);
#if defined(OF_WINDOWS)
if ([OFSystemInfo isWindowsNT]) {
OFChar16 *env, *env0;
env = env0 = GetEnvironmentStringsW();
while (*env != 0) {
void *pool = objc_autoreleasePoolPush();
OFString *tmp, *key, *value;
size_t length, pos;
length = OFUTF16StringLength(env);
tmp = [OFString stringWithUTF16String: env
length: length];
env += length + 1;
/*
* cmd.exe seems to add some special variables
* which start with a "=", even though variable
* names are not allowed to contain a "=".
*/
if ([tmp hasPrefix: @"="]) {
objc_autoreleasePoolPop(pool);
continue;
}
pos = [tmp rangeOfString: @"="].location;
if (pos == OFNotFound) {
OFLog(@"Warning: Invalid environment "
"variable: %@", tmp);
continue;
}
key = [tmp substringToIndex: pos];
value = [tmp substringFromIndex: pos + 1];
[_environment setObject: value forKey: key];
objc_autoreleasePoolPop(pool);
}
FreeEnvironmentStringsW(env0);
} else {
char *env, *env0;
env = env0 = GetEnvironmentStringsA();
while (*env != 0) {
void *pool = objc_autoreleasePoolPush();
OFString *tmp, *key, *value;
size_t length, pos;
length = strlen(env);
tmp = [OFString
stringWithCString: env
encoding: [OFLocale encoding]
length: length];
env += length + 1;
/*
* cmd.exe seems to add some special variables
* which start with a "=", even though variable
* names are not allowed to contain a "=".
*/
if ([tmp hasPrefix: @"="]) {
objc_autoreleasePoolPop(pool);
continue;
}
pos = [tmp rangeOfString: @"="].location;
if (pos == OFNotFound) {
OFLog(@"Warning: Invalid environment "
"variable: %@", tmp);
continue;
}
key = [tmp substringToIndex: pos];
value = [tmp substringFromIndex: pos + 1];
[_environment setObject: value forKey: key];
objc_autoreleasePoolPop(pool);
}
FreeEnvironmentStringsA(env0);
}
#elif defined(OF_AMIGAOS)
void *pool = objc_autoreleasePoolPush();
OFFileManager *fileManager = [OFFileManager defaultManager];
OFArray *envContents =
[fileManager contentsOfDirectoryAtPath: @"ENV:"];
OFStringEncoding encoding = [OFLocale encoding];
struct Process *proc;
struct LocalVar *firstLocalVar;
for (OFString *name in envContents) {
void *pool2 = objc_autoreleasePoolPush();
OFString *path, *value;
OFFile *file;
if ([name containsString: @"."])
continue;
path = [@"ENV:" stringByAppendingString: name];
if ([fileManager directoryExistsAtPath: path])
continue;
file = [OFFile fileWithPath: path mode: @"r"];
value = [file readLineWithEncoding: encoding];
if (value != nil)
[_environment setObject: value forKey: name];
objc_autoreleasePoolPop(pool2);
}
/* Local variables override global variables */
proc = (struct Process *)FindTask(NULL);
firstLocalVar = (struct LocalVar *)proc->pr_LocalVars.mlh_Head;
for (struct LocalVar *iter = firstLocalVar;
iter->lv_Node.ln_Succ != NULL;
iter = (struct LocalVar *)iter->lv_Node.ln_Succ) {
# ifdef OF_AMIGAOS4
int32 length;
# else
ULONG length;
# endif
OFString *key, *value;
if (iter->lv_Node.ln_Type != LV_VAR ||
iter->lv_Flags & GVF_BINARY_VAR)
continue;
for (length = 0; length < iter->lv_Len; length++)
if (iter->lv_Value[length] == 0)
break;
key = [OFString stringWithCString: iter->lv_Node.ln_Name
encoding: encoding];
value = [OFString
stringWithCString: (const char *)iter->lv_Value
encoding: encoding
length: length];
[_environment setObject: value forKey: key];
}
objc_autoreleasePoolPop(pool);
#elif !defined(OF_IOS)
# ifndef OF_MACOS
char **env = environ;
# else
char **env = *_NSGetEnviron();
# endif
if (env != NULL) {
OFStringEncoding encoding = [OFLocale encoding];
for (; *env != NULL; env++) {
void *pool = objc_autoreleasePoolPush();
OFString *key, *value;
char *sep;
if ((sep = strchr(*env, '=')) == NULL) {
OFLog(@"Warning: Invalid environment "
"variable: %s", *env);
continue;
}
key = [OFString
stringWithCString: *env
encoding: encoding
length: sep - *env];
value = [OFString
stringWithCString: sep + 1
encoding: encoding];
[_environment setObject: value forKey: key];
objc_autoreleasePoolPop(pool);
}
}
#else
/*
* iOS does not provide environ and Apple does not allow using
* _NSGetEnviron on iOS. Therefore, we just get a few common
* variables from the environment which applications might
* expect.
*/
void *pool = objc_autoreleasePoolPush();
char *env;
if ((env = getenv("HOME")) != NULL) {
OFString *home = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
[_environment setObject: home forKey: @"HOME"];
}
if ((env = getenv("PATH")) != NULL) {
OFString *path = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
[_environment setObject: path forKey: @"PATH"];
}
if ((env = getenv("SHELL")) != NULL) {
OFString *shell = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
[_environment setObject: shell forKey: @"SHELL"];
}
if ((env = getenv("TMPDIR")) != NULL) {
OFString *tmpdir = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
[_environment setObject: tmpdir forKey: @"TMPDIR"];
}
if ((env = getenv("USER")) != NULL) {
OFString *user = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
[_environment setObject: user forKey: @"USER"];
}
objc_autoreleasePoolPop(pool);
#endif
[_environment makeImmutable];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_arguments release];
[_environment release];
[super dealloc];
}
- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
OFStringEncoding encoding;
_argc = argc;
_argv = argv;
encoding = [OFLocale encoding];
#ifndef OF_NINTENDO_DS
if (*argc > 0) {
#else
if (g_envNdsArgvHeader->magic == ENV_NDS_ARGV_MAGIC &&
g_envNdsArgvHeader->argc > 0) {
#endif
_programName = [[OFString alloc] initWithCString: (*argv)[0]
encoding: encoding];
arguments = [[OFMutableArray alloc] init];
_arguments = arguments;
for (int i = 1; i < *argc; i++)
[arguments addObject:
[OFString stringWithCString: (*argv)[i]
encoding: encoding]];
[arguments makeImmutable];
}
objc_autoreleasePoolPop(pool);
}
#ifdef OF_WINDOWS
- (void)of_setArgumentCount: (int *)argc
andArgumentValues: (char **[])argv
andWideArgumentCount: (int)wargc
andWideArgumentValues: (wchar_t *[])wargv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
_argc = argc;
_argv = argv;
if (wargc > 0) {
_programName = [[OFString alloc] initWithUTF16String: wargv[0]];
arguments = [[OFMutableArray alloc] init];
for (int i = 1; i < wargc; i++)
[arguments addObject:
[OFString stringWithUTF16String: wargv[i]]];
[arguments makeImmutable];
_arguments = arguments;
}
objc_autoreleasePoolPop(pool);
}
#endif
- (void)getArgumentCount: (int **)argc andArgumentValues: (char ****)argv
{
*argc = _argc;
*argv = _argv;
}
- (id )delegate
{
return _delegate;
}
- (void)setDelegate: (id )delegate
{
#define REGISTER_SIGNAL(sig) \
if ([delegate respondsToSelector: \
@selector(applicationDidReceive##sig)]) { \
_##sig##Handler = (void (*)(id, SEL))[(id)delegate \
methodForSelector: \
@selector(applicationDidReceive##sig)]; \
signal(sig, handle##sig); \
} else { \
_##sig##Handler = NULL; \
signal(sig, (void (*)(int))SIG_DFL); \
}
_delegate = delegate;
REGISTER_SIGNAL(SIGINT)
#ifdef SIGHUP
REGISTER_SIGNAL(SIGHUP)
#endif
#ifdef SIGUSR1
REGISTER_SIGNAL(SIGUSR1)
#endif
#ifdef SIGUSR2
REGISTER_SIGNAL(SIGUSR2)
#endif
#undef REGISTER_SIGNAL
}
- (void)of_run
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop;
OFNotification *notification;
#ifdef OF_HAVE_THREADS
[OFThread of_createMainThread];
runLoop = [OFRunLoop currentRunLoop];
#else
runLoop = [[[OFRunLoop alloc] init] autorelease];
#endif
[OFRunLoop of_setMainRunLoop: runLoop];
objc_autoreleasePoolPop(pool);
/*
* Note: runLoop is still valid after the release of the pool, as
* of_setMainRunLoop: retained it. However, we only have a weak
* reference to it now, whereas we had a strong reference before.
*/
pool = objc_autoreleasePoolPush();
notification = [OFNotification
notificationWithName: OFApplicationDidFinishLaunchingNotification
object: app];
[[OFNotificationCenter defaultCenter] postNotification: notification];
[_delegate applicationDidFinishLaunching: notification];
objc_autoreleasePoolPop(pool);
[runLoop run];
}
- (void)terminate
{
[self.class terminate];
OF_UNREACHABLE
}
- (void)terminateWithStatus: (int)status
{
[self.class terminateWithStatus: status];
OF_UNREACHABLE
}
#ifdef OF_HAVE_SANDBOX
- (void)of_activateSandbox: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
void *pool = objc_autoreleasePoolPush();
OFStringEncoding encoding = [OFLocale encoding];
OFArray OF_GENERIC(OFSandboxUnveilPath) *unveiledPaths;
size_t unveiledPathsCount;
const char *promises;
if (_activeSandbox != nil && sandbox != _activeSandbox)
@throw [OFInvalidArgumentException exception];
unveiledPaths = sandbox.unveiledPaths;
unveiledPathsCount = unveiledPaths.count;
for (size_t i = sandbox->_unveiledPathsIndex;
i < unveiledPathsCount; i++) {
OFSandboxUnveilPath unveiledPath =
[unveiledPaths objectAtIndex: i];
OFString *path = unveiledPath.firstObject;
OFString *permissions = unveiledPath.secondObject;
if (path == nil || permissions == nil)
@throw [OFInvalidArgumentException exception];
unveil([path cStringWithEncoding: encoding],
[permissions cStringWithEncoding: encoding]);
}
sandbox->_unveiledPathsIndex = unveiledPathsCount;
promises = [sandbox.pledgeString cStringWithEncoding: encoding];
if (pledge(promises, NULL) != 0)
@throw [OFActivateSandboxFailedException
exceptionWithSandbox: sandbox
errNo: errno];
objc_autoreleasePoolPop(pool);
if (_activeSandbox == nil)
_activeSandbox = [sandbox retain];
# endif
}
- (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
void *pool = objc_autoreleasePoolPush();
const char *promises;
if (_activeSandboxForChildProcesses != nil &&
sandbox != _activeSandboxForChildProcesses)
@throw [OFInvalidArgumentException exception];
if (sandbox.unveiledPaths.count != 0)
@throw [OFInvalidArgumentException exception];
promises = [sandbox.pledgeString
cStringWithEncoding: [OFLocale encoding]];
if (pledge(NULL, promises) != 0)
@throw [OFActivateSandboxFailedException
exceptionWithSandbox: sandbox
errNo: errno];
objc_autoreleasePoolPop(pool);
if (_activeSandboxForChildProcesses == nil)
_activeSandboxForChildProcesses = [sandbox retain];
# endif
}
#endif
@end
objfw-1.3/src/OFArchiveEntry.h 100644 001750 001750 00000004571 14767513633 015335 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFObject.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFDate;
@class OFNumber;
/**
* @protocol OFArchiveEntry OFArchiveEntry.h ObjFW/ObjFW.h
*
* @brief A class which represents an entry in an archive.
*/
@protocol OFArchiveEntry
/**
* @brief The file name of the entry.
*/
@property (readonly, copy, nonatomic) OFString *fileName;
/**
* @brief The compressed size of the entry's file.
*/
@property (readonly, nonatomic) unsigned long long compressedSize;
/**
* @brief The uncompressed size of the entry's file.
*/
@property (readonly, nonatomic) unsigned long long uncompressedSize;
@optional
/**
* @brief The modification date of the file.
*/
@property (readonly, retain, nonatomic) OFDate *modificationDate;
/**
* @brief The comment of the entry's file.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *fileComment;
/**
* @brief The POSIX permissions of the file.
*/
@property OF_NULLABLE_PROPERTY (readonly, retain, nonatomic)
OFNumber *POSIXPermissions;
/**
* @brief The file owner's account ID.
*/
@property OF_NULLABLE_PROPERTY (readonly, retain, nonatomic)
OFNumber *ownerAccountID;
/**
* @brief The file owner's group account ID.
*/
@property OF_NULLABLE_PROPERTY (readonly, retain, nonatomic)
OFNumber *groupOwnerAccountID;
/**
* @brief The file owner's account name.
*/
@property OF_NULLABLE_PROPERTY (readonly, retain, nonatomic)
OFString *ownerAccountName;
/**
* @brief The file owner's group account name.
*/
@property OF_NULLABLE_PROPERTY (readonly, retain, nonatomic)
OFString *groupOwnerAccountName;
@end
OF_ASSUME_NONNULL_END
#import "OFMutableArchiveEntry.h"
objfw-1.3/src/OFArchiveIRIHandler.h 100644 001750 001750 00000002015 14767513633 016144 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFIRIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFArchiveIRIHandler: OFIRIHandler
@end
#ifdef __cplusplus
extern "C" {
#endif
extern OFIRI *_OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *,
OFIRI *) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFArchiveIRIHandler.m 100644 001750 001750 00000013151 14767513633 016154 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFArchiveIRIHandler.h"
#import "OFCharacterSet.h"
#import "OFGZIPStream.h"
#import "OFIRI.h"
#import "OFLHAArchive.h"
#import "OFStream.h"
#import "OFTarArchive.h"
#import "OFZIPArchive.h"
#import "OFZooArchive.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
@interface OFArchiveIRIHandlerPathAllowedCharacterSet: OFCharacterSet
{
OFCharacterSet *_characterSet;
bool (*_characterIsMember)(id, SEL, OFUnichar);
}
@end
static OFCharacterSet *pathAllowedCharacters;
static void
initPathAllowedCharacters(void)
{
pathAllowedCharacters =
[[OFArchiveIRIHandlerPathAllowedCharacterSet alloc] init];
}
@implementation OFArchiveIRIHandler
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFString *scheme = IRI.scheme;
OFString *percentEncodedPath, *path;
size_t pos;
OFIRI *archiveIRI;
OFStream *stream;
if (IRI.host != nil || IRI.port != nil || IRI.user != nil ||
IRI.password != nil || IRI.query != nil || IRI.fragment != nil)
@throw [OFInvalidArgumentException exception];
if (![mode isEqual: @"r"])
/*
* Writing has some implications that are not decided yet: Will
* it always append to an archive? What happens if the file
* already exists?
*/
@throw [OFInvalidArgumentException exception];
/*
* GZIP only compresses one file and thus has no path inside an
* archive.
*/
if ([scheme isEqual: @"gzip"]) {
stream = [OFIRIHandler openItemAtIRI: [OFIRI IRIWithString:
IRI.path]
mode: mode];
stream = [OFGZIPStream streamWithStream: stream mode: mode];
goto end;
}
percentEncodedPath = IRI.percentEncodedPath;
pos = [percentEncodedPath
rangeOfString: @"!"
options: OFStringSearchBackwards].location;
if (pos == OFNotFound)
@throw [OFInvalidArgumentException exception];
archiveIRI = [OFIRI IRIWithString:
[percentEncodedPath substringToIndex: pos]
.stringByRemovingPercentEncoding];
path = [percentEncodedPath substringFromIndex: pos + 1]
.stringByRemovingPercentEncoding;
if ([scheme isEqual: @"lha"]) {
OFLHAArchive *archive = [OFLHAArchive archiveWithIRI: archiveIRI
mode: mode];
OFLHAArchiveEntry *entry;
while ((entry = [archive nextEntry]) != nil) {
if ([entry.fileName isEqual: path]) {
stream = [archive streamForReadingCurrentEntry];
goto end;
}
}
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: ENOENT];
} else if ([scheme isEqual: @"tar"]) {
OFTarArchive *archive = [OFTarArchive archiveWithIRI: archiveIRI
mode: mode];
OFTarArchiveEntry *entry;
while ((entry = [archive nextEntry]) != nil) {
if ([entry.fileName isEqual: path]) {
stream = [archive streamForReadingCurrentEntry];
goto end;
}
}
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: ENOENT];
} else if ([scheme isEqual: @"zip"]) {
OFZIPArchive *archive = [OFZIPArchive archiveWithIRI: archiveIRI
mode: mode];
stream = [archive streamForReadingFile: path];
} else if ([scheme isEqual: @"zoo"]) {
OFZooArchive *archive = [OFZooArchive archiveWithIRI: archiveIRI
mode: mode];
OFZooArchiveEntry *entry;
while ((entry = [archive nextEntry]) != nil) {
if ([entry.fileName isEqual: path]) {
stream = [archive streamForReadingCurrentEntry];
goto end;
}
}
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: ENOENT];
} else
@throw [OFInvalidArgumentException exception];
end:
stream = [stream retain];
objc_autoreleasePoolPop(pool);
return [stream autorelease];
}
@end
@implementation OFArchiveIRIHandlerPathAllowedCharacterSet
- (instancetype)init
{
self = [super init];
@try {
_characterSet =
[[OFCharacterSet IRIPathAllowedCharacterSet] retain];
_characterIsMember = (bool (*)(id, SEL, OFUnichar))
[_characterSet methodForSelector:
@selector(characterIsMember:)];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_characterSet release];
[super dealloc];
}
- (bool)characterIsMember: (OFUnichar)character
{
return (character != '!' && _characterIsMember(_characterSet,
@selector(characterIsMember:), character));
}
@end
OFIRI *
_OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme,
OFString *pathInArchive, OFIRI *archiveIRI)
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFMutableIRI *ret = [OFMutableIRI IRIWithScheme: scheme];
void *pool = objc_autoreleasePoolPush();
OFOnce(&onceControl, initPathAllowedCharacters);
pathInArchive = [pathInArchive
stringByAddingPercentEncodingWithAllowedCharacters:
pathAllowedCharacters];
ret.percentEncodedPath = [OFString
stringWithFormat: @"%@!%@", archiveIRI.string, pathInArchive];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
objfw-1.3/src/OFArray+Private.h 100644 001750 001750 00000002111 14767513633 015402 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFArray.h"
OF_ASSUME_NONNULL_BEGIN
OF_DIRECT_MEMBERS
@interface OFArrayEnumerator: OFEnumerator
{
OFArray *_array;
size_t _count;
unsigned long _mutations;
unsigned long *_Nullable _mutationsPtr;
size_t _position;
}
- (instancetype)initWithArray: (OFArray *)data
mutationsPtr: (nullable unsigned long *)mutationsPtr;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFArray.h 100644 001750 001750 00000036756 14767513633 014022 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#include
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
@class OFString;
/**
* @brief Options for joining the objects of an array.
*
* This is a bit mask.
*/
typedef enum {
/** Skip empty components */
OFArraySkipEmptyComponents = 1
} OFArrayJoinOptions;
/**
* @brief Options for sorting an array.
*
* This is a bit mask.
*/
typedef enum {
/** Sort the array descending */
OFArraySortDescending = 1
} OFArraySortOptions;
#ifdef OF_HAVE_BLOCKS
/**
* @brief A block for enumerating an OFArray.
*
* @param object The current object
* @param index The index of the current object
* @param stop A pointer to a variable that can be set to true to stop the
* enumeration
*/
typedef void (^OFArrayEnumerationBlock)(id object, size_t index, bool *stop);
/**
* @brief A block for filtering an OFArray.
*
* @param object The object to inspect
* @param index The index of the object to inspect
* @return Whether the object should be in the filtered array
*/
typedef bool (^OFArrayFilterBlock)(id object, size_t index);
/**
* @brief A block for mapping objects to objects in an OFArray.
*
* @param object The object to map
* @param index The index of the object to map
* @return The object to map to
*/
typedef id _Nonnull (^OFArrayMapBlock)(id object, size_t index);
/**
* @brief A block for folding an OFArray.
*
* @param left The object to which the object has been folded so far
* @param right The object that should be added to the left object
* @return The left and right side folded into one object
*/
typedef id _Nullable (^OFArrayFoldBlock)(id _Nullable left, id right);
#endif
/**
* @class OFArray OFArray.h ObjFW/ObjFW.h
*
* @brief An abstract class for storing objects in an array.
*
* @note Subclasses must implement @ref count and @ref objectAtIndex:.
*/
@interface OFArray OF_GENERIC(ObjectType): OFObject
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
/**
* @brief The objects of the array as a C array.
*
* The result is valid until the autorelease pool is released. If you want to
* use the result outside the scope of the current autorelease pool, you have to
* copy it.
*/
@property (readonly, nonatomic)
ObjectType const __unsafe_unretained _Nonnull *_Nonnull objects;
/**
* @brief The first object of the array or `nil`.
*
* @warning The returned object is *not* retained and autoreleased for
* performance reasons!
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) ObjectType firstObject;
/**
* @brief The last object of the array or `nil`.
*
* @warning The returned object is *not* retained and autoreleased for
* performance reasons!
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) ObjectType lastObject;
/**
* @brief The array sorted in ascending order.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(ObjectType) *sortedArray;
/**
* @brief The array with the order reversed.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(ObjectType) *reversedArray;
/**
* @brief Creates a new OFArray.
*
* @return A new autoreleased OFArray
*/
+ (instancetype)array;
/**
* @brief Creates a new OFArray with the specified object.
*
* @param object An object
* @return A new autoreleased OFArray
*/
+ (instancetype)arrayWithObject: (ObjectType)object;
/**
* @brief Creates a new OFArray with the specified objects, terminated by `nil`.
*
* @param firstObject The first object in the array
* @return A new autoreleased OFArray
*/
+ (instancetype)arrayWithObjects: (ObjectType)firstObject, ... OF_SENTINEL;
/**
* @brief Creates a new OFArray with the objects from the specified array.
*
* @param array An array
* @return A new autoreleased OFArray
*/
+ (instancetype)arrayWithArray: (OFArray OF_GENERIC(ObjectType) *)array;
/**
* @brief Creates a new OFArray with the objects from the specified C array of
* the specified length.
*
* @param objects A C array of objects
* @param count The length of the C array
* @return A new autoreleased OFArray
*/
+ (instancetype)arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
count: (size_t)count;
/**
* @brief Initializes an OFArray with no objects.
*
* @return An initialized OFArray
*/
- (instancetype)init OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an OFArray with the specified object.
*
* @param object An object
* @return An initialized OFArray
*/
- (instancetype)initWithObject: (ObjectType)object;
/**
* @brief Initializes an OFArray with the specified objects.
*
* @param firstObject The first object
* @return An initialized OFArray
*/
- (instancetype)initWithObjects: (ObjectType)firstObject, ... OF_SENTINEL;
/**
* @brief Initializes an OFArray with the specified object and a va_list.
*
* @param firstObject The first object
* @param arguments A va_list
* @return An initialized OFArray
*/
- (instancetype)initWithObject: (ObjectType)firstObject
arguments: (va_list)arguments;
/**
* @brief Initializes an OFArray with the objects from the specified array.
*
* @param array An array
* @return An initialized OFArray
*/
- (instancetype)initWithArray: (OFArray OF_GENERIC(ObjectType) *)array;
/**
* @brief Initializes an OFArray with the objects from the specified C array of
* the specified length.
*
* @param objects A C array of objects
* @param count The length of the C array
* @return An initialized OFArray
*/
- (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
count: (size_t)count OF_DESIGNATED_INITIALIZER;
/**
* @brief Returns an OFEnumerator to enumerate through all objects of the array.
*
* @return An OFEnumerator to enumerate through all objects of the array
*/
- (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator;
/**
* @brief Returns the object at the specified index in the array.
*
* @warning The returned object is *not* retained and autoreleased for
* performance reasons!
*
* @param index The index of the object to return
* @return The object at the specified index in the array
*/
- (ObjectType)objectAtIndex: (size_t)index;
- (ObjectType)objectAtIndexedSubscript: (size_t)index;
/**
* @brief Returns the value for the specified key
*
* A new array with the value for the specified key for each object is
* returned.
*
* The special key `@count` can be used to retrieve the count as an OFNumber.
*
* @note Any nil values are replaced with @ref OFNull!
*
* @param key The key of the value to return
* @return The value for the specified key
*/
- (nullable id)valueForKey: (OFString *)key;
/**
* @brief Set the value for the specified key
*
* @ref setValue:forKey: is called for each object in the array.
*
* @note A @ref OFNull value is translated to nil!
*
* @param value The value for the specified key
* @param key The key of the value to set
*/
- (void)setValue: (nullable id)value forKey: (OFString *)key;
/**
* @brief Copies the objects at the specified range to the specified buffer.
*
* @param buffer The buffer to copy the objects to
* @param range The range to copy
*/
- (void)getObjects: (ObjectType __unsafe_unretained _Nonnull *_Nonnull)buffer
inRange: (OFRange)range;
/**
* @brief Returns the index of the first object that is equivalent to the
* specified object or `OFNotFound` if it was not found.
*
* @param object The object whose index is returned
* @return The index of the first object equivalent to the specified object
* or `OFNotFound` if it was not found
*/
- (size_t)indexOfObject: (ObjectType)object;
/**
* @brief Returns the index of the first object that has the same address as the
* specified object or `OFNotFound` if it was not found.
*
* @param object The object whose index is returned
* @return The index of the first object that has the same address as
* the specified object or `OFNotFound` if it was not found
*/
- (size_t)indexOfObjectIdenticalTo: (ObjectType)object;
/**
* @brief Checks whether the array contains an object equal to the specified
* object.
*
* @param object The object which is checked for being in the array
* @return A boolean whether the array contains the specified object
*/
- (bool)containsObject: (ObjectType)object;
/**
* @brief Checks whether the array contains an object with the specified
* address.
*
* @param object The object which is checked for being in the array
* @return A boolean whether the array contains an object with the specified
* address
*/
- (bool)containsObjectIdenticalTo: (ObjectType)object;
/**
* @brief Returns the objects in the specified range as a new OFArray.
*
* @param range The range for the subarray
* @return The subarray as a new autoreleased OFArray
*/
- (OFArray OF_GENERIC(ObjectType) *)objectsInRange: (OFRange)range;
/**
* @brief Creates a string by joining all objects of the array.
*
* @param separator The string with which the objects should be joined
* @return A string containing all objects joined by the separator
*/
- (OFString *)componentsJoinedByString: (OFString *)separator;
/**
* @brief Creates a string by joining all objects of the array.
*
* @param separator The string with which the objects should be joined
* @param options Options according to which the objects should be joined
* @return A string containing all objects joined by the separator
*/
- (OFString *)componentsJoinedByString: (OFString *)separator
options: (OFArrayJoinOptions)options;
/**
* @brief Creates a string by calling the selector on all objects of the array
* and joining the strings returned by calling the selector.
*
* @param separator The string with which the objects should be joined
* @param selector The selector to perform on the objects
* @return A string containing all objects joined by the separator
*/
- (OFString *)componentsJoinedByString: (OFString *)separator
usingSelector: (SEL)selector;
/**
* @brief Creates a string by calling the selector on all objects of the array
* and joining the strings returned by calling the selector.
*
* @param separator The string with which the objects should be joined
* @param selector The selector to perform on the objects
* @param options Options according to which the objects should be joined
* @return A string containing all objects joined by the separator
*/
- (OFString *)componentsJoinedByString: (OFString *)separator
usingSelector: (SEL)selector
options: (OFArrayJoinOptions)options;
/**
* @brief Performs the specified selector on all objects in the array.
*
* @param selector The selector to perform on all objects in the array
*/
- (void)makeObjectsPerformSelector: (SEL)selector;
/**
* @brief Performs the specified selector on all objects in the array with the
* specified object.
*
* @param selector The selector to perform on all objects in the array
* @param object The object to perform the selector with on all objects in the
* array
*/
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (nullable id)object;
/**
* @brief Returns a copy of the array sorted using the specified selector and
* options.
*
* @param selector The selector to use to sort the array. It's signature
* should be the same as that of -[compare:].
* @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
- (OFArray OF_GENERIC(ObjectType) *)
sortedArrayUsingSelector: (SEL)selector
options: (OFArraySortOptions)options;
/**
* @brief Returns a copy of the array sorted using the specified function and
* options.
*
* @param compare The function to use to sort the array
* @param context Context passed to the function to compare
* @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
- (OFArray OF_GENERIC(ObjectType) *)
sortedArrayUsingFunction: (OFCompareFunction)compare
context: (nullable void *)context
options: (OFArraySortOptions)options;
#ifdef OF_HAVE_BLOCKS
/**
* @brief Returns a copy of the array sorted using the specified selector and
* options.
*
* @param comparator The comparator to use to sort the array
* @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
- (OFArray OF_GENERIC(ObjectType) *)
sortedArrayUsingComparator: (OFComparator)comparator
options: (OFArraySortOptions)options;
#endif
/**
* @brief Creates a new array with the specified object added.
*
* @param object The object to add
* @return A new array with the specified object added
*/
- (OFArray OF_GENERIC(ObjectType) *)arrayByAddingObject: (ObjectType)object;
/**
* @brief Creates a new array with the objects from the specified array added.
*
* @param array The array with objects to add
* @return A new array with the objects from the specified array added
*/
- (OFArray OF_GENERIC(ObjectType) *)arrayByAddingObjectsFromArray:
(OFArray OF_GENERIC(ObjectType) *)array;
#ifdef OF_HAVE_BLOCKS
/**
* @brief Executes a block for each object.
*
* @param block The block to execute for each object
*/
- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block;
/**
* @brief Creates a new array, mapping each object using the specified block.
*
* @param block A block which maps an object for each object
* @return A new, autoreleased OFArray
*/
- (OFArray *)mappedArrayUsingBlock: (OFArrayMapBlock)block;
/**
* @brief Creates a new array, only containing the objects for which the block
* returns true.
*
* @param block A block which determines if the object should be in the new
* array
* @return A new, autoreleased OFArray
*/
- (OFArray OF_GENERIC(ObjectType) *)filteredArrayUsingBlock:
(OFArrayFilterBlock)block;
/**
* @brief Folds the array to a single object using the specified block.
*
* If the array is empty, it will return `nil`.
*
* If there is only one object in the array, that object will be returned and
* the block will not be invoked.
*
* If there are at least two objects, the block is invoked for each object
* except the first, where left is always to what the array has already been
* folded and right what should be added to left.
*
* @param block A block which folds two objects into one, which is called for
* all objects except the first
* @return The array folded to a single object
*/
- (nullable id)foldUsingBlock: (OFArrayFoldBlock)block;
#endif
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# undef ObjectType
#endif
@end
OF_ASSUME_NONNULL_END
#import "OFMutableArray.h"
#if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
/* Required for array literals to work */
@compatibility_alias NSArray OFArray;
#endif
objfw-1.3/src/OFArray.m 100644 001750 001750 00000045567 14767513633 014027 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#include
#import "OFArray.h"
#import "OFArray+Private.h"
#import "OFConcreteArray.h"
#import "OFData.h"
#import "OFJSONRepresentationPrivate.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFSubarray.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@interface OFArray ()
@end
@interface OFPlaceholderArray: OFArray
@end
@interface OFConcreteArraySingleton: OFConcreteArray
@end
static struct {
Class isa;
} placeholder;
static OFConcreteArraySingleton *emptyArray;
static void
emptyArrayInit(void)
{
emptyArray = [[OFConcreteArraySingleton alloc] init];
}
@implementation OFPlaceholderArray
#ifdef __clang__
/* We intentionally don't call into super, so silence the warning. */
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wobjc-designated-initializers"
#endif
- (instancetype)init
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, emptyArrayInit);
return (id)emptyArray;
}
- (instancetype)initWithObject: (id)object
{
return (id)[[OFConcreteArray alloc] initWithObject: object];
}
- (instancetype)initWithObjects: (id)firstObject, ...
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
ret = [[OFConcreteArray alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObject: (id)firstObject
arguments: (va_list)arguments
{
return (id)[[OFConcreteArray alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithArray: (OFArray *)array
{
return (id)[[OFConcreteArray alloc] initWithArray: array];
}
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
return (id)[[OFConcreteArray alloc] initWithObjects: objects
count: count];
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
OF_SINGLETON_METHODS
@end
@implementation OFConcreteArraySingleton
OF_SINGLETON_METHODS
@end
@implementation OFArray
+ (void)initialize
{
if (self == [OFArray class])
object_setClass((id)&placeholder, [OFPlaceholderArray class]);
}
+ (instancetype)alloc
{
if (self == [OFArray class])
return (id)&placeholder;
return [super alloc];
}
+ (instancetype)array
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)arrayWithObject: (id)object
{
return [[[self alloc] initWithObject: object] autorelease];
}
+ (instancetype)arrayWithObjects: (id)firstObject, ...
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
ret = [[[self alloc] initWithObject: firstObject
arguments: arguments] autorelease];
va_end(arguments);
return ret;
}
+ (instancetype)arrayWithArray: (OFArray *)array
{
return [[[self alloc] initWithArray: array] autorelease];
}
+ (instancetype)arrayWithObjects: (id const *)objects
count: (size_t)count
{
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- (instancetype)init
{
if ([self isMemberOfClass: [OFArray class]] ||
[self isMemberOfClass: [OFMutableArray class]]) {
@try {
[self doesNotRecognizeSelector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
abort();
}
return [super init];
}
- (instancetype)initWithObject: (id)object
{
return [self initWithObjects: &object count: 1];
}
- (instancetype)initWithObjects: (id)firstObject, ...
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
ret = [self initWithObject: firstObject arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
size_t count = 1;
va_list argumentsCopy;
id *objects;
if (firstObject == nil)
return [self init];
va_copy(argumentsCopy, arguments);
while (va_arg(argumentsCopy, id) != nil)
count++;
@try {
objects = OFAllocMemory(count, sizeof(id));
} @catch (id e) {
[self release];
@throw e;
}
@try {
objects[0] = firstObject;
for (size_t i = 1; i < count; i++) {
objects[i] = va_arg(arguments, id);
OFEnsure(objects[i] != nil);
}
self = [self initWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
return self;
}
- (instancetype)initWithArray: (OFArray *)array
{
id *objects;
size_t count;
@try {
count = array.count;
objects = OFAllocMemory(count, sizeof(id));
[array getObjects: objects
inRange: OFMakeRange(0, count)];
} @catch (id e) {
[self release];
@throw e;
}
@try {
self = [self initWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
return self;
}
#ifdef __clang__
/* We intentionally don't call into super, so silence the warning. */
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wobjc-designated-initializers"
#endif
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
OF_INVALID_INIT_METHOD
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)getObjects: (id *)buffer inRange: (OFRange)range
{
for (size_t i = 0; i < range.length; i++)
buffer[i] = [self objectAtIndex: range.location + i];
}
- (id const *)objects
{
size_t count = self.count;
id *buffer = OFAllocMemory(count, sizeof(id));
id const *ret;
@try {
[self getObjects: buffer inRange: OFMakeRange(0, count)];
ret = [[OFData dataWithItemsNoCopy: buffer
count: count
itemSize: sizeof(id)
freeWhenDone: true] items];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
return ret;
}
- (id)copy
{
return [self retain];
}
- (id)mutableCopy
{
return [[OFMutableArray alloc] initWithArray: self];
}
- (id)objectAtIndex: (size_t)idx
{
OF_UNRECOGNIZED_SELECTOR
}
- (id)objectAtIndexedSubscript: (size_t)idx
{
return [self objectAtIndex: idx];
}
- (id)valueForKey: (OFString *)key
{
id ret;
if ([key isEqual: @"@count"])
return [super valueForKey: @"count"];
ret = [OFMutableArray arrayWithCapacity: self.count];
for (id object in self) {
id value = [object valueForKey: key];
if (value == nil)
value = [OFNull null];
[ret addObject: value];
}
[ret makeImmutable];
return ret;
}
- (void)setValue: (id)value forKey: (OFString *)key
{
for (id object in self)
[object setValue: value forKey: key];
}
- (size_t)indexOfObject: (id)object
{
size_t i = 0;
if (object == nil)
return OFNotFound;
for (id objectIter in self) {
if ([objectIter isEqual: object])
return i;
i++;
}
return OFNotFound;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
size_t i = 0;
if (object == nil)
return OFNotFound;
for (id objectIter in self) {
if (objectIter == object)
return i;
i++;
}
return OFNotFound;
}
- (bool)containsObject: (id)object
{
return ([self indexOfObject: object] != OFNotFound);
}
- (bool)containsObjectIdenticalTo: (id)object
{
return ([self indexOfObjectIdenticalTo: object] != OFNotFound);
}
- (id)firstObject
{
if (self.count > 0)
return [self objectAtIndex: 0];
return nil;
}
- (id)lastObject
{
size_t count = self.count;
if (count > 0)
return [self objectAtIndex: count - 1];
return nil;
}
- (OFArray *)objectsInRange: (OFRange)range
{
OFArray *ret;
id *buffer;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length < self.count)
@throw [OFOutOfRangeException exception];
if (![self isKindOfClass: [OFMutableArray class]])
return [[[OFSubarray alloc] initWithArray: self
range: range] autorelease];
buffer = OFAllocMemory(range.length, sizeof(*buffer));
@try {
[self getObjects: buffer inRange: range];
ret = [OFArray arrayWithObjects: buffer count: range.length];
} @finally {
OFFreeMemory(buffer);
}
return ret;
}
- (OFString *)componentsJoinedByString: (OFString *)separator
{
return [self componentsJoinedByString: separator
usingSelector: @selector(description)
options: 0];
}
- (OFString *)componentsJoinedByString: (OFString *)separator
options: (OFArrayJoinOptions)options
{
return [self componentsJoinedByString: separator
usingSelector: @selector(description)
options: options];
}
- (OFString *)componentsJoinedByString: (OFString *)separator
usingSelector: (SEL)selector
{
return [self componentsJoinedByString: separator
usingSelector: selector
options: 0];
}
- (OFString *)componentsJoinedByString: (OFString *)separator
usingSelector: (SEL)selector
options: (OFArrayJoinOptions)options
{
OFMutableString *ret;
if (separator == nil)
@throw [OFInvalidArgumentException exception];
if (self.count == 0)
return @"";
if (self.count == 1) {
OFString *component =
[[self objectAtIndex: 0] performSelector: selector];
if (component == nil)
@throw [OFInvalidArgumentException exception];
return component;
}
ret = [OFMutableString string];
if (options & OFArraySkipEmptyComponents) {
for (id object in self) {
void *pool = objc_autoreleasePoolPush();
OFString *component =
[object performSelector: selector];
if (component == nil)
@throw [OFInvalidArgumentException exception];
if (component.length > 0) {
if (ret.length > 0)
[ret appendString: separator];
[ret appendString: component];
}
objc_autoreleasePoolPop(pool);
}
} else {
bool first = true;
for (id object in self) {
void *pool = objc_autoreleasePoolPush();
OFString *component =
[object performSelector: selector];
if (component == nil)
@throw [OFInvalidArgumentException exception];
if OF_UNLIKELY (first)
first = false;
else
[ret appendString: separator];
[ret appendString: component];
objc_autoreleasePoolPop(pool);
}
}
[ret makeImmutable];
return ret;
}
- (bool)isEqual: (id)object
{
/* FIXME: Optimize (for example, buffer of 16 for each) */
OFArray *otherArray;
size_t count;
if (object == self)
return true;
if (![object isKindOfClass: [OFArray class]])
return false;
otherArray = object;
count = self.count;
if (count != otherArray.count)
return false;
for (size_t i = 0; i < count; i++)
if (![[self objectAtIndex: i] isEqual:
[otherArray objectAtIndex: i]])
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
for (id object in self)
OFHashAddHash(&hash, [object hash]);
OFHashFinalize(&hash);
return hash;
}
- (OFString *)description
{
void *pool;
OFMutableString *ret;
if (self.count == 0)
return @"()";
pool = objc_autoreleasePoolPush();
ret = [[self componentsJoinedByString: @",\n"] mutableCopy];
@try {
[ret insertString: @"(\n" atIndex: 0];
[ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"];
[ret appendString: @"\n)"];
} @catch (id e) {
[ret release];
@throw e;
}
objc_autoreleasePoolPop(pool);
[ret makeImmutable];
return [ret autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
{
return [self of_JSONRepresentationWithOptions: options depth: 0];
}
- (OFString *)
of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
depth: (size_t)depth
{
OFMutableString *JSON = [OFMutableString stringWithString: @"["];
void *pool = objc_autoreleasePoolPush();
size_t i, count = self.count;
if (options & OFJSONRepresentationOptionPretty) {
OFMutableString *indentation = [OFMutableString string];
for (i = 0; i < depth; i++)
[indentation appendString: @"\t"];
[JSON appendString: @"\n"];
i = 0;
for (id object in self) {
void *pool2 = objc_autoreleasePoolPush();
[JSON appendString: indentation];
[JSON appendString: @"\t"];
[JSON appendString: [object
of_JSONRepresentationWithOptions: options
depth: depth + 1]];
if (++i < count)
[JSON appendString: @",\n"];
else
[JSON appendString: @"\n"];
objc_autoreleasePoolPop(pool2);
}
[JSON appendString: indentation];
} else {
i = 0;
for (id object in self) {
void *pool2 = objc_autoreleasePoolPush();
[JSON appendString: [object
of_JSONRepresentationWithOptions: options
depth: depth + 1]];
if (++i < count)
[JSON appendString: @","];
objc_autoreleasePoolPop(pool2);
}
}
[JSON appendString: @"]"];
[JSON makeImmutable];
objc_autoreleasePoolPop(pool);
return JSON;
}
- (OFData *)messagePackRepresentation
{
OFMutableData *data;
size_t i, count;
void *pool;
data = [OFMutableData data];
count = self.count;
if (count <= 15) {
uint8_t tmp = 0x90 | ((uint8_t)count & 0xF);
[data addItem: &tmp];
} else if (count <= UINT16_MAX) {
uint8_t type = 0xDC;
uint16_t tmp = OFToBigEndian16((uint16_t)count);
[data addItem: &type];
[data addItems: &tmp count: sizeof(tmp)];
} else if (count <= UINT32_MAX) {
uint8_t type = 0xDD;
uint32_t tmp = OFToBigEndian32((uint32_t)count);
[data addItem: &type];
[data addItems: &tmp count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
pool = objc_autoreleasePoolPush();
i = 0;
for (id object in self) {
void *pool2 = objc_autoreleasePoolPush();
OFData *child;
i++;
child = [object messagePackRepresentation];
[data addItems: child.items count: child.count];
objc_autoreleasePoolPop(pool2);
}
OFAssert(i == count);
[data makeImmutable];
objc_autoreleasePoolPop(pool);
return data;
}
- (void)makeObjectsPerformSelector: (SEL)selector
{
for (id object in self)
[object performSelector: selector];
}
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (id)object
{
for (id objectIter in self)
[objectIter performSelector: selector withObject: object];
}
- (OFArray *)sortedArray
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sort];
[new makeImmutable];
return new;
}
- (OFArray *)sortedArrayUsingSelector: (SEL)selector
options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingSelector: selector options: options];
[new makeImmutable];
return new;
}
- (OFArray *)sortedArrayUsingFunction: (OFCompareFunction)compare
context: (void *)context
options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingFunction: compare context: context options: options];
[new makeImmutable];
return new;
}
#ifdef OF_HAVE_BLOCKS
- (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator
options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingComparator: comparator options: options];
[new makeImmutable];
return new;
}
#endif
- (OFArray *)reversedArray
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new reverse];
[new makeImmutable];
return new;
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
static unsigned long dummyMutations;
OFRange range = OFMakeRange(state->state, count);
if (range.length > SIZE_MAX - range.location)
@throw [OFOutOfRangeException exception];
if (range.location + range.length > self.count)
range.length = self.count - range.location;
[self getObjects: objects inRange: range];
if (range.location + range.length > ULONG_MAX)
@throw [OFOutOfRangeException exception];
state->state = (unsigned long)(range.location + range.length);
state->itemsPtr = objects;
state->mutationsPtr = &dummyMutations;
return (int)range.length;
}
- (OFEnumerator *)objectEnumerator
{
return [[[OFArrayEnumerator alloc] initWithArray: self
mutationsPtr: NULL] autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
size_t i = 0;
bool stop = false;
for (id object in self) {
block(object, i++, &stop);
if (stop)
break;
}
}
#endif
- (OFArray *)arrayByAddingObject: (id)object
{
OFMutableArray *ret;
if (object == nil)
@throw [OFInvalidArgumentException exception];
ret = [[self mutableCopy] autorelease];
[ret addObject: object];
[ret makeImmutable];
return ret;
}
- (OFArray *)arrayByAddingObjectsFromArray: (OFArray *)array
{
OFMutableArray *ret = [[self mutableCopy] autorelease];
[ret addObjectsFromArray: array];
[ret makeImmutable];
return ret;
}
#ifdef OF_HAVE_BLOCKS
- (OFArray *)mappedArrayUsingBlock: (OFArrayMapBlock)block
{
OFArray *ret;
size_t count = self.count;
id *tmp = OFAllocMemory(count, sizeof(id));
@try {
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
tmp[idx] = block(object, idx);
}];
ret = [OFArray arrayWithObjects: tmp count: count];
} @finally {
OFFreeMemory(tmp);
}
return ret;
}
- (OFArray *)filteredArrayUsingBlock: (OFArrayFilterBlock)block
{
OFArray *ret;
size_t count = self.count;
id *tmp = OFAllocMemory(count, sizeof(id));
@try {
__block size_t i = 0;
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
if (block(object, idx))
tmp[i++] = object;
}];
ret = [OFArray arrayWithObjects: tmp count: i];
} @finally {
OFFreeMemory(tmp);
}
return ret;
}
- (id)foldUsingBlock: (OFArrayFoldBlock)block
{
size_t count = self.count;
__block id current;
if (count == 0)
return nil;
if (count == 1)
return [[[self objectAtIndex: 0] retain] autorelease];
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
id new;
if (idx == 0) {
current = [object retain];
return;
}
@try {
new = [block(current, object) retain];
} @finally {
[current release];
}
current = new;
}];
return [current autorelease];
}
#endif
@end
@implementation OFArrayEnumerator
- (instancetype)initWithArray: (OFArray *)array
mutationsPtr: (unsigned long *)mutationsPtr
{
self = [super init];
_array = [array retain];
_count = [array count];
_mutations = (mutationsPtr != NULL ? *mutationsPtr : 0);
_mutationsPtr = mutationsPtr;
return self;
}
- (void)dealloc
{
[_array release];
[super dealloc];
}
- (id)nextObject
{
if (_mutationsPtr != NULL && *_mutationsPtr != _mutations)
@throw [OFEnumerationMutationException
exceptionWithObject: _array];
if (_position < _count)
return [_array objectAtIndex: _position++];
return nil;
}
@end
objfw-1.3/src/OFAsyncIPSocketConnector.h 100644 001750 001750 00000003316 14767513633 017260 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDNSResolver.h"
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
OF_ASSUME_NONNULL_BEGIN
@protocol OFAsyncIPSocketConnecting
- (bool)of_createSocketForAddress: (const OFSocketAddress *)address
errNo: (int *)errNo;
- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
errNo: (int *)errNo;
- (void)of_closeSocket;
@end
@interface OFAsyncIPSocketConnector: OFObject
{
id _socket;
OFString *_host;
uint16_t _port;
id _Nullable _delegate;
id _Nullable _handler;
id _Nullable _exception;
OFData *_Nullable _socketAddresses;
size_t _socketAddressesIndex;
}
- (instancetype)initWithSocket: (id)sock
host: (OFString *)host
port: (uint16_t)port
delegate: (nullable id)delegate
handler: (nullable id)handler;
- (void)didConnect;
- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode;
- (void)startWithRunLoopMode: (OFRunLoopMode)runLoopMode;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFAsyncIPSocketConnector.m 100644 001750 001750 00000014350 14767513633 017265 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFAsyncIPSocketConnector.h"
#import "OFData.h"
#ifdef OF_HAVE_SCTP
# import "OFSCTPSocket.h"
#endif
#import "OFTCPSocket.h"
#import "OFThread.h"
#import "OFTimer.h"
#import "OFConnectIPSocketFailedException.h"
#import "OFInvalidFormatException.h"
@implementation OFAsyncIPSocketConnector
- (instancetype)initWithSocket: (id)sock
host: (OFString *)host
port: (uint16_t)port
delegate: (id)delegate
handler: (id)handler
{
self = [super init];
@try {
_socket = [sock retain];
_host = [host copy];
_port = port;
_delegate = [delegate retain];
_handler = [handler copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_socket release];
[_host release];
[_delegate release];
[_handler release];
[_exception release];
[_socketAddresses release];
[super dealloc];
}
- (void)didConnect
{
if (_exception == nil)
[_socket setCanBlock: true];
#ifdef OF_HAVE_BLOCKS
if (_handler != NULL) {
if ([_socket isKindOfClass: [OFTCPSocket class]])
((OFTCPSocketConnectedHandler)_handler)(_socket, _host,
_port, _exception);
# ifdef OF_HAVE_SCTP
else if ([_socket isKindOfClass: [OFSCTPSocket class]])
((OFSCTPSocketConnectedHandler)_handler)(_socket, _host,
_port, _exception);
# endif
else
OFEnsure(0);
} else {
#endif
if ([_delegate respondsToSelector:
@selector(socket:didConnectToHost:port:exception:)])
[_delegate socket: _socket
didConnectToHost: _host
port: _port
exception: _exception];
#ifdef OF_HAVE_BLOCKS
}
#endif
}
- (void)of_socketDidConnect: (id)sock exception: (id)exception
{
if (exception != nil) {
/*
* self might be retained only by the pending async requests,
* which we're about to cancel.
*/
[[self retain] autorelease];
[sock cancelAsyncRequests];
[sock of_closeSocket];
if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [exception retain];
[self didConnect];
} else {
/*
* We must not call it before returning, as otherwise
* the new socket would be removed from the queue upon
* return.
*/
OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
SEL selector =
@selector(tryNextAddressWithRunLoopMode:);
OFTimer *timer = [OFTimer
timerWithTimeInterval: 0
target: self
selector: selector
object: runLoop.currentMode
repeats: false];
[runLoop addTimer: timer forMode: runLoop.currentMode];
}
return;
}
[self didConnect];
}
- (id)of_connectionFailedExceptionForErrNo: (int)errNo
{
return [OFConnectIPSocketFailedException exceptionWithHost: _host
port: _port
socket: _socket
errNo: errNo];
}
- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode
{
OFSocketAddress address = *(const OFSocketAddress *)
[_socketAddresses itemAtIndex: _socketAddressesIndex++];
int errNo;
OFSocketAddressSetIPPort(&address, _port);
if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectIPSocketFailedException alloc]
initWithHost: _host
port: _port
socket: _socket
errNo: errNo];
[self didConnect];
return;
}
[self tryNextAddressWithRunLoopMode: runLoopMode];
return;
}
#if defined(OF_NINTENDO_3DS) || defined(OF_WII)
/*
* On Wii and 3DS, connect() fails if non-blocking is enabled.
*
* Additionally, on Wii, there is no getsockopt(), so it would not be
* possible to get the error (or success) after connecting anyway.
*
* So for now, connecting is blocking on Wii and 3DS.
*
* FIXME: Use a different thread as a work around.
*/
[_socket setCanBlock: true];
#else
[_socket setCanBlock: false];
#endif
if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
#if !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
# ifdef OF_WINDOWS
if (errNo == EINPROGRESS || errNo == EWOULDBLOCK) {
# else
if (errNo == EINPROGRESS) {
# endif
[OFRunLoop of_addAsyncConnectForSocket: _socket
mode: runLoopMode
delegate: self];
return;
} else {
#endif
[_socket of_closeSocket];
if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectIPSocketFailedException
alloc] initWithHost: _host
port: _port
socket: _socket
errNo: errNo];
[self didConnect];
return;
}
[self tryNextAddressWithRunLoopMode: runLoopMode];
return;
#if !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
}
#endif
}
#if defined(OF_NINTENDO_3DS) || defined(OF_WII)
[_socket setCanBlock: false];
#endif
[self didConnect];
}
- (void)resolver: (OFDNSResolver *)resolver
didResolveHost: (OFString *)host
addresses: (OFData *)addresses
exception: (id)exception
{
if (exception != nil) {
_exception = [exception retain];
[self didConnect];
return;
}
_socketAddresses = [addresses copy];
[self tryNextAddressWithRunLoopMode:
[OFRunLoop currentRunLoop].currentMode];
}
- (void)startWithRunLoopMode: (OFRunLoopMode)runLoopMode
{
@try {
OFSocketAddress address = OFSocketAddressParseIP(_host, _port);
_socketAddresses = [[OFData alloc]
initWithItems: &address
count: 1
itemSize: sizeof(address)];
[self tryNextAddressWithRunLoopMode: runLoopMode];
return;
} @catch (OFInvalidFormatException *e) {
}
[[OFThread DNSResolver]
asyncResolveAddressesForHost: _host
addressFamily: OFSocketAddressFamilyAny
runLoopMode: runLoopMode
delegate: self];
}
@end
objfw-1.3/src/OFAtomic.h 100644 001750 001750 00000007416 14767513633 014147 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include
#import "macros.h"
#ifndef OF_HAVE_ATOMIC_OPS
# error No atomic operations available!
#endif
#if !defined(OF_HAVE_THREADS)
static OF_INLINE int
OFAtomicIntAdd(volatile int *_Nonnull p, int i)
{
return (*p += i);
}
static OF_INLINE int32_t
OFAtomicInt32Add(volatile int32_t *_Nonnull p, int32_t i)
{
return (*p += i);
}
static OF_INLINE void *_Nullable
OFAtomicPointerAdd(void *volatile _Nullable *_Nonnull p, intptr_t i)
{
return (*(char *volatile *)p += i);
}
static OF_INLINE int
OFAtomicIntSubtract(volatile int *_Nonnull p, int i)
{
return (*p -= i);
}
static OF_INLINE int32_t
OFAtomicInt32Subtract(volatile int32_t *_Nonnull p, int32_t i)
{
return (*p -= i);
}
static OF_INLINE void *_Nullable
OFAtomicPointerSubtract(void *volatile _Nullable *_Nonnull p, intptr_t i)
{
return (*(char *volatile *)p -= i);
}
static OF_INLINE int
OFAtomicIntIncrease(volatile int *_Nonnull p)
{
return ++*p;
}
static OF_INLINE int32_t
OFAtomicInt32Increase(volatile int32_t *_Nonnull p)
{
return ++*p;
}
static OF_INLINE int
OFAtomicIntDecrease(volatile int *_Nonnull p)
{
return --*p;
}
static OF_INLINE int32_t
OFAtomicInt32Decrease(volatile int32_t *_Nonnull p)
{
return --*p;
}
static OF_INLINE unsigned int
OFAtomicIntOr(volatile unsigned int *_Nonnull p, unsigned int i)
{
return (*p |= i);
}
static OF_INLINE uint32_t
OFAtomicInt32Or(volatile uint32_t *_Nonnull p, uint32_t i)
{
return (*p |= i);
}
static OF_INLINE unsigned int
OFAtomicIntAnd(volatile unsigned int *_Nonnull p, unsigned int i)
{
return (*p &= i);
}
static OF_INLINE uint32_t
OFAtomicInt32And(volatile uint32_t *_Nonnull p, uint32_t i)
{
return (*p &= i);
}
static OF_INLINE unsigned int
OFAtomicIntXor(volatile unsigned int *_Nonnull p, unsigned int i)
{
return (*p ^= i);
}
static OF_INLINE uint32_t
OFAtomicInt32Xor(volatile uint32_t *_Nonnull p, uint32_t i)
{
return (*p ^= i);
}
static OF_INLINE bool
OFAtomicIntCompareAndSwap(volatile int *_Nonnull p, int o, int n)
{
if (*p == o) {
*p = n;
return true;
}
return false;
}
static OF_INLINE bool
OFAtomicInt32CompareAndSwap(volatile int32_t *_Nonnull p, int32_t o, int32_t n)
{
if (*p == o) {
*p = n;
return true;
}
return false;
}
static OF_INLINE bool
OFAtomicPointerCompareAndSwap(void *volatile _Nullable *_Nonnull p,
void *_Nullable o, void *_Nullable n)
{
if (*p == o) {
*p = n;
return true;
}
return false;
}
static OF_INLINE void
OFMemoryBarrier(void)
{
/* nop */
}
static OF_INLINE void
OFAcquireMemoryBarrier(void)
{
/* nop */
}
static OF_INLINE void
OFReleaseMemoryBarrier(void)
{
/* nop */
}
#elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__)
# import "platform/x86/OFAtomic.h"
#elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \
!defined(OF_AIX)
# import "platform/PowerPC/OFAtomic.h"
#elif defined(OF_HAVE_ATOMIC_BUILTINS)
# import "platform/GCC4.7/OFAtomic.h"
#elif defined(OF_HAVE_SYNC_BUILTINS)
# import "platform/GCC4/OFAtomic.h"
#elif defined(OF_HAVE_OSATOMIC)
# import "platform/macOS/OFAtomic.h"
#else
# error No atomic operations available!
#endif
objfw-1.3/src/OFBase64.h 100644 001750 001750 00000002274 14767513633 013754 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#import "macros.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFMutableData;
#ifdef __cplusplus
extern "C" {
#endif
extern OFString *_OFBase64Encode(const void *, size_t) OF_VISIBILITY_HIDDEN;
extern bool _OFBase64Decode(OFMutableData *, const char *, size_t)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFBase64.m 100644 001750 001750 00000007725 14767513633 013767 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFBase64.h"
#import "OFString.h"
#import "OFData.h"
static const unsigned char encodeTable[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b',
'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
static const signed char decodeTable[128] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, -1, -1, -1, -1, -1
};
OFString *
_OFBase64Encode(const void *data, size_t length)
{
OFMutableString *ret = [OFMutableString string];
uint8_t *buffer = (uint8_t *)data;
size_t i;
uint8_t rest;
char tb[4];
uint32_t sb;
rest = length % 3;
for (i = 0; i < length - rest; i += 3) {
sb = (buffer[i] << 16) | (buffer[i + 1] << 8) | buffer[i + 2];
tb[0] = encodeTable[(sb & 0xFC0000) >> 18];
tb[1] = encodeTable[(sb & 0x03F000) >> 12];
tb[2] = encodeTable[(sb & 0x000FC0) >> 6];
tb[3] = encodeTable[sb & 0x00003F];
[ret appendCString: tb
encoding: OFStringEncodingASCII
length: 4];
}
switch (rest) {
case 1:
tb[0] = encodeTable[buffer[i] >> 2];
tb[1] = encodeTable[(buffer[i] & 3) << 4];
tb[2] = tb[3] = '=';
[ret appendCString: tb
encoding: OFStringEncodingASCII
length: 4];
break;
case 2:
sb = (buffer[i] << 16) | (buffer[i + 1] << 8);
tb[0] = encodeTable[(sb & 0xFC0000) >> 18];
tb[1] = encodeTable[(sb & 0x03F000) >> 12];
tb[2] = encodeTable[(sb & 0x000FC0) >> 6];
tb[3] = '=';
[ret appendCString: tb
encoding: OFStringEncodingASCII
length: 4];
break;
}
[ret makeImmutable];
return ret;
}
bool
_OFBase64Decode(OFMutableData *data, const char *string, size_t length)
{
const uint8_t *buffer = (const uint8_t *)string;
size_t i;
if ((length & 3) != 0)
return false;
if (data.itemSize != 1)
return false;
for (i = 0; i < length; i += 4) {
uint32_t sb = 0;
uint8_t count = 3;
char db[3];
int8_t tmp;
if (buffer[i] > 0x7F || buffer[i + 1] > 0x7F ||
buffer[i + 2] > 0x7F || buffer[i + 3] > 0x7F)
return false;
if (buffer[i] == '=' || buffer[i + 1] == '=' ||
(buffer[i + 2] == '=' && buffer[i + 3] != '='))
return false;
if (buffer[i + 2] == '=')
count--;
if (buffer[i + 3] == '=')
count--;
if ((tmp = decodeTable[buffer[i]]) == -1)
return false;
sb |= tmp << 18;
if ((tmp = decodeTable[buffer[i + 1]]) == -1)
return false;
sb |= tmp << 12;
if ((tmp = decodeTable[buffer[i + 2]]) == -1)
return false;
sb |= tmp << 6;
if ((tmp = decodeTable[buffer[i + 3]]) == -1)
return false;
sb |= tmp;
db[0] = (sb & 0xFF0000) >> 16;
db[1] = (sb & 0x00FF00) >> 8;
db[2] = sb & 0x0000FF;
[data addItems: db count: count];
}
return true;
}
objfw-1.3/src/OFBitSetCharacterSet.h 100644 001750 001750 00000001611 14767513633 016405 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFCharacterSet.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFBitSetCharacterSet: OFCharacterSet
{
unsigned long *_bitSet;
size_t _size;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFBitSetCharacterSet.m 100644 001750 001750 00000003717 14767513633 016423 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFBitSetCharacterSet.h"
#import "OFString.h"
#import "OFOutOfRangeException.h"
@implementation OFBitSetCharacterSet
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithCharactersInString: (OFString *)string
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
const OFUnichar *characters = string.characters;
size_t length = string.length;
for (size_t i = 0; i < length; i++) {
OFUnichar c = characters[i];
if (c / OF_ULONG_BIT >= _size) {
size_t newSize;
if (UINT32_MAX - c < 1)
@throw [OFOutOfRangeException
exception];
newSize = OFRoundUpToPowerOf2(OF_ULONG_BIT,
c + 1) / OF_ULONG_BIT;
_bitSet = OFResizeMemory(_bitSet, newSize,
sizeof(unsigned long));
memset(_bitSet + _size, '\0',
(newSize - _size) * sizeof(unsigned long));
_size = newSize;
}
OFBitSetSet(_bitSet, c);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
OFFreeMemory(_bitSet);
[super dealloc];
}
- (bool)characterIsMember: (OFUnichar)character
{
if (character / OF_ULONG_BIT >= _size)
return false;
return OFBitSetIsSet(_bitSet, character);
}
@end
objfw-1.3/src/OFBlock.h 100644 001750 001750 00000004366 14767513633 013766 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFBlock OFBlock.h ObjFW/ObjFW.h
*
* @brief The class for all blocks, since all blocks are also objects.
*/
@interface OFBlock: OFObject
+ (instancetype)alloc OF_UNAVAILABLE;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_SUBCLASSING_RESTRICTED
@interface OFStackBlock: OFBlock
@end
OF_SUBCLASSING_RESTRICTED
@interface OFGlobalBlock: OFBlock
@end
OF_SUBCLASSING_RESTRICTED
@interface OFMallocBlock: OFBlock
@end
#ifdef __cplusplus
extern "C" {
#endif
extern void *_Nullable _Block_copy(const void *_Nullable);
extern void _Block_release(const void *_Nullable);
# if defined(OF_WINDOWS) && \
(defined(OF_NO_SHARED) || defined(OF_COMPILING_OBJFW))
/*
* Clang has implicit declarations for these, but they are dllimport. When
* compiling ObjFW itself or using it as a static library, these need to be
* dllexport. Interestingly, this still works when using it as a shared library.
*/
extern __declspec(dllexport) struct objc_class _NSConcreteStackBlock;
extern __declspec(dllexport) struct objc_class _NSConcreteGlobalBlock;
extern __declspec(dllexport) void _Block_object_assign(void *, const void *,
const int);
extern __declspec(dllexport) void _Block_object_dispose(const void *,
const int);
# endif
#ifdef __cplusplus
}
#endif
#ifndef Block_copy
# define Block_copy(...) \
((__typeof__(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
#endif
#ifndef Block_release
# define Block_release(...) _Block_release((const void *)(__VA_ARGS__))
#endif
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFBlock.m 100644 001750 001750 00000027764 14767513633 014002 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#include
#include
#import "OFBlock.h"
#ifdef OF_HAVE_ATOMIC_OPS
# import "OFAtomic.h"
#endif
#ifdef OF_HAVE_THREADS
# import "OFPlainMutex.h"
#endif
#import "OFString.h"
#import "OFAllocFailedException.h"
#import "OFInitializationFailedException.h"
#if defined(OF_OBJFW_RUNTIME)
# import "runtime/private.h"
#endif
struct Block {
Class isa;
int flags;
int reserved;
void (*invoke)(void *block, ...);
struct {
unsigned long reserved;
unsigned long size;
void (*copyHelper)(void *dest, void *src);
void (*disposeHelper)(void *src);
const char *signature;
} *descriptor;
};
struct Byref {
Class isa;
struct Byref *forwarding;
int flags;
int size;
void (*keepByref)(void *dest, void *src);
void (*disposeByref)(void *);
};
enum {
OFBlockHasCopyDispose = (1 << 25),
OFBlockHasCtor = (1 << 26),
OFBlockIsGlobal = (1 << 28),
OFBlockHasStret = (1 << 29),
OFBlockHasSignature = (1 << 30)
};
#define OFBlockRefCountMask 0xFFFF
enum {
OFBlockFieldIsObject = 3,
OFBlockFieldIsBlock = 7,
OFBlockFieldIsByref = 8,
OFBlockFieldIsWeak = 16,
OFBlockByrefCaller = 128
};
@protocol RetainRelease
- (instancetype)retain;
- (void)release;
@end
#ifdef OF_OBJFW_RUNTIME
/* Begin of ObjC module */
static struct objc_class _NSConcreteStackBlock_metaclass = {
Nil, Nil, "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS,
sizeof(_NSConcreteStackBlock_metaclass), NULL, NULL
};
struct objc_class _NSConcreteStackBlock = {
&_NSConcreteStackBlock_metaclass, (Class)(void *)"OFBlock",
"OFStackBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(struct Block),
NULL, NULL
};
static struct objc_class _NSConcreteGlobalBlock_metaclass = {
Nil, Nil, "OFGlobalBlock", 8, OBJC_CLASS_INFO_METACLASS,
sizeof(_NSConcreteGlobalBlock_metaclass), NULL, NULL
};
struct objc_class _NSConcreteGlobalBlock = {
&_NSConcreteGlobalBlock_metaclass, (Class)(void *)"OFBlock",
"OFGlobalBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(struct Block),
NULL, NULL
};
static struct objc_class _NSConcreteMallocBlock_metaclass = {
Nil, Nil, "OFMallocBlock", 8, OBJC_CLASS_INFO_METACLASS,
sizeof(_NSConcreteMallocBlock_metaclass), NULL, NULL
};
struct objc_class _NSConcreteMallocBlock = {
&_NSConcreteMallocBlock_metaclass, (Class)(void *)"OFBlock",
"OFMallocBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(struct Block),
NULL, NULL
};
static struct {
unsigned long unknown;
struct objc_selector *selectorRefs;
uint16_t classDefsCount, categoryDefsCount;
void *defs[4];
} symtab = {
0, NULL, 3, 0,
{
&_NSConcreteStackBlock, &_NSConcreteGlobalBlock,
&_NSConcreteMallocBlock, NULL
}
};
static struct _objc_module module = {
8, sizeof(module), NULL, (struct objc_symtab *)&symtab
};
OF_CONSTRUCTOR()
{
__objc_exec_class(&module);
}
/* End of ObjC module */
#elif defined(OF_APPLE_RUNTIME)
extern Class objc_initializeClassPair(Class, const char *, Class, Class);
struct class {
struct class *isa, *superclass;
const char *name;
long version, info, instanceSize;
struct ivar_list *iVars;
struct method_list **methodList;
struct cache *cache;
struct protocol_list *protocols;
const char *iVarLayout;
struct class_ext *ext;
};
struct class _NSConcreteStackBlock;
struct class _NSConcreteGlobalBlock;
struct class _NSConcreteMallocBlock;
# if defined(__OBJC2__) && !defined(OF_POWERPC64)
struct class _NSConcreteStackBlock_metaclass;
struct class _NSConcreteGlobalBlock_metaclass;
struct class _NSConcreteMallocBlock_metaclass;
# endif
#endif
static struct {
Class isa;
} allocFailedException;
#ifndef OF_HAVE_ATOMIC_OPS
# define numSpinlocks 8 /* needs to be a power of 2 */
# define SPINLOCK_HASH(p) ((uintptr_t)p >> 4) & (numSpinlocks - 1)
static OFSpinlock blockSpinlocks[numSpinlocks];
static OFSpinlock byrefSpinlocks[numSpinlocks];
#endif
void *
_Block_copy(const void *block_)
{
struct Block *block = (struct Block *)block_;
if ([(id)block isMemberOfClass: (Class)&_NSConcreteStackBlock]) {
struct Block *copy;
if ((copy = malloc(block->descriptor->size)) == NULL) {
object_setClass((id)&allocFailedException,
[OFAllocFailedException class]);
@throw (OFAllocFailedException *)&allocFailedException;
}
memcpy(copy, block, block->descriptor->size);
object_setClass((id)copy, (Class)&_NSConcreteMallocBlock);
copy->flags++;
if (block->flags & OFBlockHasCopyDispose)
block->descriptor->copyHelper(copy, block);
return copy;
}
if ([(id)block isMemberOfClass: (Class)&_NSConcreteMallocBlock]) {
#ifdef OF_HAVE_ATOMIC_OPS
OFAtomicIntIncrease(&block->flags);
#else
unsigned hash = SPINLOCK_HASH(block);
OFEnsure(OFSpinlockLock(&blockSpinlocks[hash]) == 0);
block->flags++;
OFEnsure(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0);
#endif
}
return block;
}
void
_Block_release(const void *block_)
{
struct Block *block = (struct Block *)block_;
if (object_getClass((id)block) != (Class)&_NSConcreteMallocBlock)
return;
#ifdef OF_HAVE_ATOMIC_OPS
if ((OFAtomicIntDecrease(&block->flags) & OFBlockRefCountMask) == 0) {
if (block->flags & OFBlockHasCopyDispose)
block->descriptor->disposeHelper(block);
free(block);
}
#else
unsigned hash = SPINLOCK_HASH(block);
OFEnsure(OFSpinlockLock(&blockSpinlocks[hash]) == 0);
if ((--block->flags & OFBlockRefCountMask) == 0) {
OFEnsure(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0);
if (block->flags & OFBlockHasCopyDispose)
block->descriptor->disposeHelper(block);
free(block);
return;
}
OFEnsure(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0);
#endif
}
void
_Block_object_assign(void *dst_, const void *src_, const int flags_)
{
int flags = flags_ & (OFBlockFieldIsBlock | OFBlockFieldIsObject |
OFBlockFieldIsByref);
if (src_ == NULL)
return;
switch (flags) {
case OFBlockFieldIsBlock:
*(struct Block **)dst_ = _Block_copy(src_);
break;
case OFBlockFieldIsObject:
if (!(flags_ & OFBlockByrefCaller))
*(id *)dst_ = [(id)src_ retain];
break;
case OFBlockFieldIsByref:;
struct Byref *src = (struct Byref *)src_;
struct Byref **dst = (struct Byref **)dst_;
src = src->forwarding;
if ((src->flags & OFBlockRefCountMask) == 0) {
if ((*dst = malloc(src->size)) == NULL) {
object_setClass((id)&allocFailedException,
[OFAllocFailedException class]);
@throw (OFAllocFailedException *)
&allocFailedException;
}
memcpy(*dst, src, src->size);
(*dst)->flags =
((*dst)->flags & ~OFBlockRefCountMask) | 1;
(*dst)->forwarding = *dst;
if (src->flags & OFBlockHasCopyDispose)
src->keepByref(*dst, src);
#ifdef OF_HAVE_ATOMIC_OPS
if (!OFAtomicPointerCompareAndSwap(
(void **)&src->forwarding, src, *dst)) {
src->disposeByref(*dst);
free(*dst);
*dst = src->forwarding;
}
#else
unsigned hash = SPINLOCK_HASH(src);
OFEnsure(OFSpinlockLock(&byrefSpinlocks[hash]) == 0);
if (src->forwarding == src)
src->forwarding = *dst;
else {
src->disposeByref(*dst);
free(*dst);
*dst = src->forwarding;
}
OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
#endif
} else
*dst = src;
#ifdef OF_HAVE_ATOMIC_OPS
OFAtomicIntIncrease(&(*dst)->flags);
#else
unsigned hash = SPINLOCK_HASH(*dst);
OFEnsure(OFSpinlockLock(&byrefSpinlocks[hash]) == 0);
(*dst)->flags++;
OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
#endif
break;
}
}
void
_Block_object_dispose(const void *object_, const int flags_)
{
const int flags = flags_ & (OFBlockFieldIsBlock | OFBlockFieldIsObject |
OFBlockFieldIsByref);
if (object_ == NULL)
return;
switch (flags) {
case OFBlockFieldIsBlock:
_Block_release(object_);
break;
case OFBlockFieldIsObject:
if (!(flags_ & OFBlockByrefCaller))
[(id)object_ release];
break;
case OFBlockFieldIsByref:;
struct Byref *object = (struct Byref *)object_;
object = object->forwarding;
#ifdef OF_HAVE_ATOMIC_OPS
if ((OFAtomicIntDecrease(&object->flags) &
OFBlockRefCountMask) == 0) {
if (object->flags & OFBlockHasCopyDispose)
object->disposeByref(object);
free(object);
}
#else
unsigned hash = SPINLOCK_HASH(object);
OFEnsure(OFSpinlockLock(&byrefSpinlocks[hash]) == 0);
if ((--object->flags & OFBlockRefCountMask) == 0) {
OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
if (object->flags & OFBlockHasCopyDispose)
object->disposeByref(object);
free(object);
}
OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
#endif
break;
}
}
@implementation OFBlock
+ (void)load
{
#ifndef OF_HAVE_ATOMIC_OPS
for (size_t i = 0; i < numSpinlocks; i++)
if (OFSpinlockNew(&blockSpinlocks[i]) != 0 ||
OFSpinlockNew(&byrefSpinlocks[i]) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: self];
#endif
#ifdef OF_APPLE_RUNTIME
Class tmp;
# if defined(__OBJC2__) && !defined(OF_POWERPC64)
tmp = objc_initializeClassPair(self, "OFStackBlock",
(Class)&_NSConcreteStackBlock,
(Class)&_NSConcreteStackBlock_metaclass);
if (tmp == Nil)
@throw [OFInitializationFailedException
exceptionWithClass: self];
objc_registerClassPair(tmp);
tmp = objc_initializeClassPair(self, "OFGlobalBlock",
(Class)&_NSConcreteGlobalBlock,
(Class)&_NSConcreteGlobalBlock_metaclass);
if (tmp == Nil)
@throw [OFInitializationFailedException
exceptionWithClass: self];
objc_registerClassPair(tmp);
tmp = objc_initializeClassPair([OFBlock class], "OFMallocBlock",
(Class)&_NSConcreteMallocBlock,
(Class)&_NSConcreteMallocBlock_metaclass);
if (tmp == Nil)
@throw [OFInitializationFailedException
exceptionWithClass: self];
objc_registerClassPair(tmp);
# else
/*
* There is no objc_initializeClassPair in 10.5.
* However, objc_allocateClassPair does not register the new class with
* the subclass in the ObjC1 runtime like the ObjC2 runtime does, so
* this workaround should be fine.
*/
if ((tmp = objc_allocateClassPair(self, "OFStackBlock", 0)) == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: self];
memcpy(&_NSConcreteStackBlock, tmp, sizeof(_NSConcreteStackBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteStackBlock);
if ((tmp = objc_allocateClassPair(self, "OFGlobalBlock", 0)) == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: self];
memcpy(&_NSConcreteGlobalBlock, tmp, sizeof(_NSConcreteGlobalBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteGlobalBlock);
if ((tmp = objc_allocateClassPair(self, "OFMallocBlock", 0)) == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: self];
memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock));
free(tmp);
objc_registerClassPair((Class)&_NSConcreteMallocBlock);
# endif
#endif
}
+ (instancetype)alloc
{
OF_UNRECOGNIZED_SELECTOR
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)retain
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
return Block_copy(self);
return self;
}
- (id)copy
{
return Block_copy(self);
}
- (instancetype)autorelease
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
return [super autorelease];
return self;
}
- (unsigned int)retainCount
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
return ((struct Block *)self)->flags & OFBlockRefCountMask;
return OFMaxRetainCount;
}
- (void)release
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
Block_release(self);
}
- (void)dealloc
{
OF_DEALLOC_UNSUPPORTED
}
@end
objfw-1.3/src/OFCNAMEDNSResourceRecord.h 100644 001750 001750 00000003570 14767513633 016767 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDNSResourceRecord.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFCNAMEDNSResourceRecord OFCNAMEDNSResourceRecord.h ObjFW/ObjFW.h
*
* @brief A class representing a CNAME DNS resource record.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFCNAMEDNSResourceRecord: OFDNSResourceRecord
{
OFString *_alias;
}
/**
* @brief The alias of the resource record.
*/
@property (readonly, nonatomic) OFString *alias;
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
recordType: (OFDNSRecordType)recordType
TTL: (uint32_t)TTL OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFCNAMEDNSResourceRecord with the
* specified name, class, alias and time to live.
*
* @param name The name for the resource record
* @param DNSClass The class code for the resource record
* @param alias The alias for the resource record
* @param TTL The time to live for the resource record
* @return An initialized OFCNAMEDNSResourceRecord
*/
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
alias: (OFString *)alias
TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFCNAMEDNSResourceRecord.m 100644 001750 001750 00000004774 14767513633 017003 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFCNAMEDNSResourceRecord.h"
@implementation OFCNAMEDNSResourceRecord
@synthesize alias = _alias;
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
recordType: (OFDNSRecordType)recordType
TTL: (uint32_t)TTL
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithName: (OFString *)name
DNSClass: (OFDNSClass)DNSClass
alias: (OFString *)alias
TTL: (uint32_t)TTL
{
self = [super initWithName: name
DNSClass: DNSClass
recordType: OFDNSRecordTypeCNAME
TTL: TTL];
@try {
_alias = [alias copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_alias release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFCNAMEDNSResourceRecord *record;
if (object == self)
return true;
if (![object isKindOfClass: [OFCNAMEDNSResourceRecord class]])
return false;
record = object;
if (record->_name != _name && ![record->_name isEqual: _name])
return false;
if (record->_DNSClass != _DNSClass)
return false;
if (record->_recordType != _recordType)
return false;
if (record->_alias != _alias && ![record->_alias isEqual: _alias])
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
OFHashAddHash(&hash, _name.hash);
OFHashAddByte(&hash, _DNSClass >> 8);
OFHashAddByte(&hash, _DNSClass);
OFHashAddByte(&hash, _recordType >> 8);
OFHashAddByte(&hash, _recordType);
OFHashAddHash(&hash, _alias.hash);
OFHashFinalize(&hash);
return hash;
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"<%@:\n"
@"\tName = %@\n"
@"\tClass = %@\n"
@"\tAlias = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
self.className, _name, OFDNSClassName(_DNSClass), _alias, _TTL];
}
@end
objfw-1.3/src/OFCRC16.h 100644 001750 001750 00000002046 14767513633 013503 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#import "macros.h"
#ifdef __cplusplus
extern "C" {
#endif
extern uint16_t _OFCRC16(uint16_t crc, const void *_Nonnull bytes,
size_t length) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
objfw-1.3/src/OFCRC16.m 100644 001750 001750 00000002105 14767513633 013504 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFCRC16.h"
static const uint16_t CRC16Magic = 0xA001;
uint16_t
_OFCRC16(uint16_t CRC, const void *bytes_, size_t length)
{
const unsigned char *bytes = bytes_;
for (size_t i = 0; i < length; i++) {
CRC ^= bytes[i];
for (uint8_t j = 0; j < 8; j++)
CRC = (CRC >> 1) ^ (CRC16Magic & (~(CRC & 1) + 1));
}
return CRC;
}
objfw-1.3/src/OFCRC32.h 100644 001750 001750 00000002046 14767513633 013501 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#import "macros.h"
#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t _OFCRC32(uint32_t crc, const void *_Nonnull bytes,
size_t length) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
objfw-1.3/src/OFCRC32.m 100644 001750 001750 00000002111 14767513633 013477 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFCRC32.h"
static const uint32_t CRC32Magic = 0xEDB88320;
uint32_t
_OFCRC32(uint32_t CRC, const void *bytes_, size_t length)
{
const unsigned char *bytes = bytes_;
for (size_t i = 0; i < length; i++) {
CRC ^= bytes[i];
for (uint8_t j = 0; j < 8; j++)
CRC = (CRC >> 1) ^ (CRC32Magic & (~(CRC & 1) + 1));
}
return CRC;
}
objfw-1.3/src/OFCharacterSet.h 100644 001750 001750 00000005617 14767513633 015304 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFObject.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFCharacterSet OFCharacterSet.h ObjFW/ObjFW.h
*
* @brief A class cluster representing a character set.
*
* @note Subclasses must implement @ref characterIsMember:.
*/
@interface OFCharacterSet: OFObject
{
OF_RESERVE_IVARS(OFCharacterSet, 4)
}
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic) OFCharacterSet *whitespaceCharacterSet;
#endif
/**
* @brief The inverted set, containing only the characters that do not exist in
* the receiver.
*/
@property (readonly, nonatomic) OFCharacterSet *invertedSet;
/**
* @brief Creates a new character set containing the characters of the
* specified string.
*
* @param characters The characters for the character set
* @return A new OFCharacterSet
*/
+ (instancetype)characterSetWithCharactersInString: (OFString *)characters;
/**
* @brief Creates a new character set containing the characters in the specified
* range.
*
* @param range The range of characters for the character set
* @return A new OFCharacterSet
*/
+ (instancetype)characterSetWithRange: (OFRange)range;
/**
* @brief A character set containing all Unicode characters in the category
* `Zs` plus CHARACTER TABULATION (U+0009).
*/
+ (OFCharacterSet *)whitespaceCharacterSet;
/**
* @brief Initializes an already allocated character set with the characters of
* the specified string.
*
* @param characters The characters for the character set
* @return An initialized OFCharacterSet
*/
- (instancetype)initWithCharactersInString: (OFString *)characters;
/**
* @brief Initializes an already allocated character set with the characters in
* the specified range.
*
* @param range The range of characters for the character set
* @return An initialized OFCharacterSet
*/
- (instancetype)initWithRange: (OFRange)range;
/**
* @brief Returns whether the specified character is a member of the character
* set.
*
* @param character The character that is checked for being a member of the
* character set
* @return Whether the specified character is a member of the character set.
*/
- (bool)characterIsMember: (OFUnichar)character;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFCharacterSet.m 100644 001750 001750 00000006574 14767513633 015314 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFCharacterSet.h"
#import "OFBitSetCharacterSet.h"
#import "OFInvertedCharacterSet.h"
#import "OFOnce.h"
#import "OFRangeCharacterSet.h"
@interface OFPlaceholderCharacterSet: OFCharacterSet
@end
@interface OFWhitespaceCharacterSet: OFCharacterSet
@end
static struct {
Class isa;
} placeholder;
static OFCharacterSet *whitespaceCharacterSet = nil;
static void
initWhitespaceCharacterSet(void)
{
whitespaceCharacterSet = [[OFWhitespaceCharacterSet alloc] init];
}
@implementation OFPlaceholderCharacterSet
- (instancetype)init
{
return (id)[[OFBitSetCharacterSet alloc] init];
}
- (instancetype)initWithCharactersInString: (OFString *)characters
{
return (id)[[OFBitSetCharacterSet alloc]
initWithCharactersInString: characters];
}
- (instancetype)initWithRange: (OFRange)range
{
return (id)[[OFRangeCharacterSet alloc] initWithRange: range];
}
OF_SINGLETON_METHODS
@end
@implementation OFCharacterSet
+ (void)initialize
{
if (self == [OFCharacterSet class])
object_setClass((id)&placeholder,
[OFPlaceholderCharacterSet class]);
}
+ (instancetype)alloc
{
if (self == [OFCharacterSet class])
return (id)&placeholder;
return [super alloc];
}
+ (instancetype)characterSetWithCharactersInString: (OFString *)characters
{
return [[[self alloc] initWithCharactersInString: characters]
autorelease];
}
+ (instancetype)characterSetWithRange: (OFRange)range
{
return [[[self alloc] initWithRange: range] autorelease];
}
+ (OFCharacterSet *)whitespaceCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initWhitespaceCharacterSet);
return whitespaceCharacterSet;
}
- (instancetype)init
{
if ([self isMemberOfClass: [OFCharacterSet class]]) {
@try {
[self doesNotRecognizeSelector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
abort();
}
return [super init];
}
- (instancetype)initWithCharactersInString: (OFString *)characters
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithRange: (OFRange)range
{
OF_INVALID_INIT_METHOD
}
- (bool)characterIsMember: (OFUnichar)character
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFCharacterSet *)invertedSet
{
return [[[OFInvertedCharacterSet alloc]
initWithCharacterSet: self] autorelease];
}
@end
@implementation OFWhitespaceCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
switch (character) {
case 0x0009:
case 0x0020:
case 0x00A0:
case 0x1680:
case 0x2000:
case 0x2001:
case 0x2002:
case 0x2003:
case 0x2004:
case 0x2005:
case 0x2006:
case 0x2007:
case 0x2008:
case 0x2009:
case 0x200A:
case 0x202F:
case 0x205F:
case 0x3000:
return true;
default:
return false;
}
}
OF_SINGLETON_METHODS
@end
objfw-1.3/src/OFCollection.h 100644 001750 001750 00000002557 14767513633 015027 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFEnumerator.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @protocol OFCollection OFCollection.h ObjFW/ObjFW.h
*
* @brief A protocol with methods common for all collections.
*/
@protocol OFCollection
/**
* @brief The number of objects in the collection
*/
@property (readonly, nonatomic) size_t count;
/**
* @brief Checks whether the collection contains an object equal to the
* specified object.
*
* @param object The object which is checked for being in the collection
* @return A boolean whether the collection contains the specified object
*/
- (bool)containsObject: (id)object;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFColor.h 100644 001750 001750 00000014001 14767513633 013775 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFColor OFColor.h ObjFW/ObjFW.h
*
* @brief A class for storing a color.
*/
@interface OFColor: OFObject
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic) OFColor *black;
@property (class, readonly, nonatomic) OFColor *silver;
@property (class, readonly, nonatomic) OFColor *gray;
@property (class, readonly, nonatomic) OFColor *grey
OF_DEPRECATED(ObjFW, 1, 1, "Use +[gray] instead");
@property (class, readonly, nonatomic) OFColor *white;
@property (class, readonly, nonatomic) OFColor *maroon;
@property (class, readonly, nonatomic) OFColor *red;
@property (class, readonly, nonatomic) OFColor *purple;
@property (class, readonly, nonatomic) OFColor *fuchsia;
@property (class, readonly, nonatomic) OFColor *green;
@property (class, readonly, nonatomic) OFColor *lime;
@property (class, readonly, nonatomic) OFColor *olive;
@property (class, readonly, nonatomic) OFColor *yellow;
@property (class, readonly, nonatomic) OFColor *navy;
@property (class, readonly, nonatomic) OFColor *blue;
@property (class, readonly, nonatomic) OFColor *teal;
@property (class, readonly, nonatomic) OFColor *aqua;
#endif
/**
* @brief Creates a new color with the specified red, green, blue and alpha
* value.
*
* @param red The red value of the color, between 0.0 and 1.0
* @param green The green value of the color, between 0.0 and 1.0
* @param blue The blue value of the color, between 0.0 and 1.0
* @param alpha The alpha value of the color, between 0.0 and 1.0
* @return A new color with the specified red, green, blue and alpha value
*/
+ (instancetype)colorWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha;
/**
* @brief Returns the HTML color `black`.
*
* The RGBA value is (0, 0, 0, 1).
*
* @return The HTML color `black`
*/
+ (OFColor *)black;
/**
* @brief Returns the HTML color `silver`.
*
* The RGBA value is (0.75, 0.75, 0.75, 1).
*
* @return The HTML color `silver`
*/
+ (OFColor *)silver;
/**
* @brief Returns the HTML color `gray`.
*
* The RGBA value is (0.5, 0.5, 0.5, 1).
*
* @return The HTML color `gray`
*/
+ (OFColor *)gray;
/**
* @brief Returns the HTML color `gray`.
*
* @deprecated Use @ref gray instead.
*
* The RGBA value is (0.5, 0.5, 0.5, 1).
*
* @return The HTML color `gray`
*/
+ (OFColor *)grey OF_DEPRECATED(ObjFW, 1, 1, "Use +[gray] instead");
/**
* @brief Returns the HTML color `white`.
*
* The RGBA value is (1, 1, 1, 1).
*
* @return The HTML color `white`
*/
+ (OFColor *)white;
/**
* @brief Returns the HTML color `maroon`.
*
* The RGBA value is (0.5, 0, 0, 1).
*
* @return The HTML color `maroon`
*/
+ (OFColor *)maroon;
/**
* @brief Returns the HTML color `red`.
*
* The RGBA value is (1, 0, 0, 1).
*
* @return The HTML color `red`
*/
+ (OFColor *)red;
/**
* @brief Returns the HTML color `purple`.
*
* The RGBA value is (0.5, 0, 0.5, 1).
*
* @return The HTML color `purple`
*/
+ (OFColor *)purple;
/**
* @brief Returns the HTML color `fuchsia`.
*
* The RGBA value is (1, 0, 1, 1).
*
* @return The HTML color `fuchsia`
*/
+ (OFColor *)fuchsia;
/**
* @brief Returns the HTML color `green`.
*
* The RGBA value is (0, 0.5, 0, 1).
*
* @return The HTML color `green`
*/
+ (OFColor *)green;
/**
* @brief Returns the HTML color `lime`.
*
* The RGBA value is (0, 1, 0, 1).
*
* @return The HTML color `lime`
*/
+ (OFColor *)lime;
/**
* @brief Returns the HTML color `olive`.
*
* The RGBA value is (0.5, 0.5, 0, 1).
*
* @return The HTML color `olive`
*/
+ (OFColor *)olive;
/**
* @brief Returns the HTML color `yellow`.
*
* The RGBA value is (1, 1, 0, 1).
*
* @return The HTML color `yellow`
*/
+ (OFColor *)yellow;
/**
* @brief Returns the HTML color `navy`.
*
* The RGBA value is (0, 0, 0.5, 1).
*
* @return The HTML color `navy`
*/
+ (OFColor *)navy;
/**
* @brief Returns the HTML color `blue`.
*
* The RGBA value is (0, 0, 1, 1).
*
* @return The HTML color `blue`
*/
+ (OFColor *)blue;
/**
* @brief Returns the HTML color `teal`.
*
* The RGBA value is (0, 0.5, 0.5, 1).
*
* @return The HTML color `teal`
*/
+ (OFColor *)teal;
/**
* @brief Returns the HTML color `aqua`.
*
* The RGBA value is (0, 1, 1, 1).
*
* @return The HTML color `aqua`
*/
+ (OFColor *)aqua;
/**
* @brief Initializes an already allocated color with the specified red, green,
* blue and alpha value.
*
* @param red The red value of the color, between 0.0 and 1.0
* @param green The green value of the color, between 0.0 and 1.0
* @param blue The blue value of the color, between 0.0 and 1.0
* @param alpha The alpha value of the color, between 0.0 and 1.0
* @return A color initialized with the specified red, green, blue and alpha
* value
*/
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha;
/**
* @brief Returns the red, green, blue and alpha value of the color.
*
* @param red A pointer to store the red value of the color
* @param green A pointer to store the green value of the color
* @param blue A pointer to store the blue value of the color
* @param alpha An optional pointer to store the alpha of the color
*/
- (void)getRed: (float *)red
green: (float *)green
blue: (float *)blue
alpha: (nullable float *)alpha;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFColor.m 100644 001750 001750 00000013454 14767513633 014015 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFColor.h"
#import "OFConcreteColor.h"
#import "OFOnce.h"
#import "OFString.h"
#import "OFTaggedPointerColor.h"
@interface OFPlaceholderColor: OFColor
@end
@interface OFConcreteColorSingleton: OFConcreteColor
@end
static struct {
Class isa;
} placeholder;
#ifdef OF_OBJFW_RUNTIME
static const float allowedImprecision = 0.0000001;
#endif
@implementation OFPlaceholderColor
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
#ifdef OF_OBJFW_RUNTIME
uint8_t redInt = roundf(red * 255);
uint8_t greenInt = roundf(green * 255);
uint8_t blueInt = roundf(blue * 255);
if (fabsf(red * 255 - redInt) < allowedImprecision &&
fabsf(green * 255 - greenInt) < allowedImprecision &&
fabsf(blue * 255 - blueInt) < allowedImprecision && alpha == 1) {
id ret = [OFTaggedPointerColor colorWithRed: redInt
green: greenInt
blue: blueInt];
if (ret != nil)
return ret;
}
#endif
return (id)[[OFConcreteColor alloc] initWithRed: red
green: green
blue: blue
alpha: alpha];
}
OF_SINGLETON_METHODS
@end
@implementation OFConcreteColorSingleton
OF_SINGLETON_METHODS
@end
@implementation OFColor
+ (void)initialize
{
if (self == [OFColor class])
object_setClass((id)&placeholder, [OFPlaceholderColor class]);
}
+ (instancetype)alloc
{
if (self == [OFColor class])
return (id)&placeholder;
return [super alloc];
}
#define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \
static OFColor *name##Color = nil; \
\
static void \
initPredefinedColor_##name(void) \
{ \
name##Color = [[OFConcreteColorSingleton alloc] \
initWithRed: redValue \
green: greenValue \
blue: blueValue \
alpha: 1]; \
} \
\
+ (OFColor *)name \
{ \
static OFOnceControl onceControl = OFOnceControlInitValue; \
OFOnce(&onceControl, initPredefinedColor_##name); \
\
return name##Color; \
}
PREDEFINED_COLOR(black, 0.00f, 0.00f, 0.00f)
PREDEFINED_COLOR(silver, 0.75f, 0.75f, 0.75f)
PREDEFINED_COLOR(gray, 0.50f, 0.50f, 0.50f)
PREDEFINED_COLOR(white, 1.00f, 1.00f, 1.00f)
PREDEFINED_COLOR(maroon, 0.50f, 0.00f, 0.00f)
PREDEFINED_COLOR(red, 1.00f, 0.00f, 0.00f)
PREDEFINED_COLOR(purple, 0.50f, 0.00f, 0.50f)
PREDEFINED_COLOR(fuchsia, 1.00f, 0.00f, 1.00f)
PREDEFINED_COLOR(green, 0.00f, 0.50f, 0.00f)
PREDEFINED_COLOR(lime, 0.00f, 1.00f, 0.00f)
PREDEFINED_COLOR(olive, 0.50f, 0.50f, 0.00f)
PREDEFINED_COLOR(yellow, 1.00f, 1.00f, 0.00f)
PREDEFINED_COLOR(navy, 0.00f, 0.00f, 0.50f)
PREDEFINED_COLOR(blue, 0.00f, 0.00f, 1.00f)
PREDEFINED_COLOR(teal, 0.00f, 0.50f, 0.50f)
PREDEFINED_COLOR(aqua, 0.00f, 1.00f, 1.00f)
+ (OFColor *)grey
{
return [self gray];
}
+ (instancetype)colorWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
return [[[self alloc] initWithRed: red
green: green
blue: blue
alpha: alpha] autorelease];
}
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
if ([self isMemberOfClass: [OFColor class]]) {
@try {
[self doesNotRecognizeSelector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
abort();
}
return [super init];
}
- (bool)isEqual: (id)object
{
OFColor *other;
float red, green, blue, alpha;
float otherRed, otherGreen, otherBlue, otherAlpha;
if (object == self)
return true;
if (![object isKindOfClass: [OFColor class]])
return false;
other = object;
[self getRed: &red green: &green blue: &blue alpha: &alpha];
[other getRed: &otherRed
green: &otherGreen
blue: &otherBlue
alpha: &otherAlpha];
if (otherRed != red)
return false;
if (otherGreen != green)
return false;
if (otherBlue != blue)
return false;
if (otherAlpha != alpha)
return false;
return true;
}
- (unsigned long)hash
{
float red, green, blue, alpha;
unsigned long hash;
float tmp;
[self getRed: &red green: &green blue: &blue alpha: &alpha];
OFHashInit(&hash);
tmp = OFToLittleEndianFloat(red);
for (uint_fast8_t i = 0; i < sizeof(float); i++)
OFHashAddByte(&hash, ((char *)&tmp)[i]);
tmp = OFToLittleEndianFloat(green);
for (uint_fast8_t i = 0; i < sizeof(float); i++)
OFHashAddByte(&hash, ((char *)&tmp)[i]);
tmp = OFToLittleEndianFloat(blue);
for (uint_fast8_t i = 0; i < sizeof(float); i++)
OFHashAddByte(&hash, ((char *)&tmp)[i]);
tmp = OFToLittleEndianFloat(alpha);
for (uint_fast8_t i = 0; i < sizeof(float); i++)
OFHashAddByte(&hash, ((char *)&tmp)[i]);
OFHashFinalize(&hash);
return hash;
}
- (void)getRed: (float *)red
green: (float *)green
blue: (float *)blue
alpha: (float *)alpha
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFString *)description
{
float red, green, blue, alpha;
[self getRed: &red green: &green blue: &blue alpha: &alpha];
return [OFString stringWithFormat:
@"<%@ red=%f green=%f blue=%f alpha=%f>",
self.class, red, green, blue, alpha];
}
@end
objfw-1.3/src/OFConcreteArray.h 100644 001750 001750 00000001575 14767513633 015474 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFArray.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMutableData;
@interface OFConcreteArray: OFArray
{
OFMutableData *_array;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteArray.m 100644 001750 001750 00000014717 14767513633 015503 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFConcreteArray.h"
#import "OFConcreteMutableArray.h"
#import "OFConcreteSubarray.h"
#import "OFData.h"
#import "OFString.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteArray
- (instancetype)init
{
self = [super init];
@try {
_array = [[OFMutableData alloc] initWithItemSize: sizeof(id)];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)object
{
self = [self init];
@try {
if (object == nil)
@throw [OFInvalidArgumentException exception];
[_array addItem: &object];
[object retain];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
[_array addItem: &firstObject];
[firstObject retain];
while ((object = va_arg(arguments, id)) != nil) {
[_array addItem: &object];
[object retain];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithArray: (OFArray *)array
{
id const *objects;
size_t count;
self = [super init];
if (array == nil)
return self;
@try {
objects = array.objects;
count = array.count;
_array = [[OFMutableData alloc] initWithItemSize: sizeof(id)
capacity: count];
} @catch (id e) {
[self release];
@throw e;
}
@try {
for (size_t i = 0; i < count; i++)
[objects[i] retain];
[_array addItems: objects count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
/* Prevent double-release of objects */
[_array release];
_array = nil;
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
self = [super init];
@try {
bool ok = true;
for (size_t i = 0; i < count; i++) {
if (objects[i] == nil)
ok = false;
[objects[i] retain];
}
if (!ok)
@throw [OFInvalidArgumentException exception];
_array = [[OFMutableData alloc] initWithItemSize: sizeof(id)
capacity: count];
[_array addItems: objects count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
return self;
}
- (size_t)count
{
return _array.count;
}
- (id const *)objects
{
return _array.items;
}
- (id)objectAtIndex: (size_t)idx
{
return *((id *)[_array itemAtIndex: idx]);
}
- (id)objectAtIndexedSubscript: (size_t)idx
{
return *((id *)[_array itemAtIndex: idx]);
}
- (void)getObjects: (id *)buffer inRange: (OFRange)range
{
id const *objects = _array.items;
size_t count = _array.count;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > count)
@throw [OFOutOfRangeException exception];
for (size_t i = 0; i < range.length; i++)
buffer[i] = objects[range.location + i];
}
- (size_t)indexOfObject: (id)object
{
id const *objects;
size_t count;
if (object == nil)
return OFNotFound;
objects = _array.items;
count = _array.count;
for (size_t i = 0; i < count; i++)
if ([objects[i] isEqual: object])
return i;
return OFNotFound;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
id const *objects;
size_t count;
if (object == nil)
return OFNotFound;
objects = _array.items;
count = _array.count;
for (size_t i = 0; i < count; i++)
if (objects[i] == object)
return i;
return OFNotFound;
}
- (OFArray *)objectsInRange: (OFRange)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _array.count)
@throw [OFOutOfRangeException exception];
if ([self isKindOfClass: [OFMutableArray class]])
return [OFArray
arrayWithObjects: (id *)_array.items + range.location
count: range.length];
return [[[OFConcreteSubarray alloc] initWithArray: self
range: range] autorelease];
}
- (bool)isEqual: (id)object
{
OFArray *otherArray;
id const *objects, *otherObjects;
size_t count;
if (object == self)
return true;
if (![object isKindOfClass: [OFConcreteArray class]] &&
![object isKindOfClass: [OFConcreteMutableArray class]])
return [super isEqual: object];
otherArray = object;
count = _array.count;
if (count != otherArray.count)
return false;
objects = _array.items;
otherObjects = otherArray.objects;
for (size_t i = 0; i < count; i++)
if (![objects[i] isEqual: otherObjects[i]])
return false;
return true;
}
- (unsigned long)hash
{
id const *objects = _array.items;
size_t count = _array.count;
unsigned long hash;
OFHashInit(&hash);
for (size_t i = 0; i < count; i++)
OFHashAddHash(&hash, [objects[i] hash]);
OFHashFinalize(&hash);
return hash;
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count_
{
static unsigned long dummyMutations;
size_t count = _array.count;
if (count > INT_MAX)
/*
* Use the implementation from OFArray, which is slower, but can
* enumerate in chunks.
*/
return [super countByEnumeratingWithState: state
objects: objects
count: count_];
if (state->state >= count)
return 0;
state->state = (unsigned long)count;
state->itemsPtr = (id *)_array.items;
state->mutationsPtr = &dummyMutations;
return (int)count;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
id const *objects = _array.items;
size_t count = _array.count;
bool stop = false;
for (size_t i = 0; i < count && !stop; i++)
block(objects[i], i, &stop);
}
#endif
- (void)dealloc
{
id const *objects = _array.items;
size_t count = _array.count;
for (size_t i = 0; i < count; i++)
[objects[i] release];
[_array release];
[super dealloc];
}
@end
objfw-1.3/src/OFConcreteColor.h 100644 001750 001750 00000001562 14767513633 015470 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFColor.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteColor: OFColor
{
float _red, _green, _blue, _alpha;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteColor.m 100644 001750 001750 00000002773 14767513633 015502 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFConcreteColor.h"
#import "OFInvalidArgumentException.h"
@implementation OFConcreteColor
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
self = [super init];
@try {
if (red < 0.0 || red > 1.0 ||
green < 0.0 || green > 1.0 ||
blue < 0.0 || blue > 1.0 ||
alpha < 0.0 || alpha > 1.0)
@throw [OFInvalidArgumentException exception];
_red = red;
_green = green;
_blue = blue;
_alpha = alpha;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)getRed: (float *)red
green: (float *)green
blue: (float *)blue
alpha: (float *)alpha
{
*red = _red;
*green = _green;
*blue = _blue;
if (alpha != NULL)
*alpha = _alpha;
}
@end
objfw-1.3/src/OFConcreteCountedSet.h 100644 001750 001750 00000001611 14767513633 016462 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFCountedSet.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMapTable;
@interface OFConcreteCountedSet: OFCountedSet
{
OFMapTable *_mapTable;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteCountedSet.m 100644 001750 001750 00000007310 14767513633 016471 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFConcreteCountedSet.h"
#import "OFArray.h"
#import "OFConcreteMutableSet.h"
#import "OFMapTable.h"
#import "OFString.h"
#import "OFXMLAttribute.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteCountedSet
+ (void)initialize
{
if (self == [OFConcreteCountedSet class])
[self inheritMethodsFromClass: [OFConcreteMutableSet class]];
}
- (instancetype)initWithSet: (OFSet *)set
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ([set isKindOfClass: [OFCountedSet class]]) {
OFCountedSet *countedSet = (OFCountedSet *)set;
for (id object in countedSet) {
size_t count =
[countedSet countForObject: object];
for (size_t i = 0; i < count; i++)
[self addObject: object];
}
} else
for (id object in set)
[self addObject: object];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithArray: (OFArray *)array
{
self = [self init];
@try {
id const *objects = array.objects;
size_t count = array.count;
for (size_t i = 0; i < count; i++)
[self addObject: objects[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
self = [self init];
@try {
for (size_t i = 0; i < count; i++)
[self addObject: objects[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
[self addObject: firstObject];
while ((object = va_arg(arguments, id)) != nil)
[self addObject: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (size_t)countForObject: (id)object
{
return (size_t)(uintptr_t)[_mapTable objectForKey: object];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block
{
@try {
[_mapTable enumerateKeysAndObjectsUsingBlock:
^ (void *key, void *object, bool *stop) {
block(key, (size_t)(uintptr_t)object, stop);
}];
} @catch (OFEnumerationMutationException *e) {
@throw [OFEnumerationMutationException
exceptionWithObject: self];
}
}
#endif
- (void)addObject: (id)object
{
size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object];
if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1)
@throw [OFOutOfRangeException exception];
[_mapTable setObject: (void *)(uintptr_t)(count + 1) forKey: object];
}
- (void)removeObject: (id)object
{
size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object];
if (count == 0)
return;
count--;
if (count > 0)
[_mapTable setObject: (void *)(uintptr_t)count forKey: object];
else
[_mapTable removeObjectForKey: object];
}
- (void)removeAllObjects
{
[_mapTable removeAllObjects];
}
- (void)makeImmutable
{
}
@end
objfw-1.3/src/OFConcreteData.h 100644 001750 001750 00000001650 14767513633 015261 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFData.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteData: OFData
{
unsigned char *_Nullable _items;
size_t _capacity, _count, _itemSize;
bool _freeWhenDone;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteData.m 100644 001750 001750 00000004507 14767513633 015272 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#include
#import "OFConcreteData.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteData
- (instancetype)init
{
return [self initWithItemSize: 1];
}
- (instancetype)initWithItemSize: (size_t)itemSize
{
self = [super init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
_itemSize = itemSize;
_freeWhenDone = true;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithItems: (const void *)items
count: (size_t)count
itemSize: (size_t)itemSize
{
self = [super init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
_items = OFAllocMemory(count, itemSize);
_capacity = _count = count;
_itemSize = itemSize;
_freeWhenDone = true;
memcpy(_items, items, count * itemSize);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithItemsNoCopy: (void *)items
count: (size_t)count
itemSize: (size_t)itemSize
freeWhenDone: (bool)freeWhenDone
{
self = [super init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
_items = (unsigned char *)items;
_capacity = _count = count;
_itemSize = itemSize;
_freeWhenDone = freeWhenDone;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
if (_freeWhenDone)
OFFreeMemory(_items);
[super dealloc];
}
- (size_t)count
{
return _count;
}
- (size_t)itemSize
{
return _itemSize;
}
- (const void *)items
{
return _items;
}
@end
objfw-1.3/src/OFConcreteDate.h 100644 001750 001750 00000001545 14767513633 015270 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDate.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteDate: OFDate
{
OFTimeInterval _seconds;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteDate.m 100644 001750 001750 00000002003 14767513633 015263 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFConcreteDate.h"
@implementation OFConcreteDate
- (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds
{
self = [super initWithTimeIntervalSince1970: seconds];
_seconds = seconds;
return self;
}
- (OFTimeInterval)timeIntervalSince1970
{
return _seconds;
}
@end
objfw-1.3/src/OFConcreteDictionary.h 100644 001750 001750 00000001733 14767513633 016517 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDictionary.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMapTable;
@class OFMapTableEnumerator;
@interface OFConcreteDictionary: OFDictionary
{
OFMapTable *_mapTable;
}
- (instancetype)initWithCapacity: (size_t)capacity;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteDictionary.m 100644 001750 001750 00000016733 14767513633 016532 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFConcreteDictionary.h"
#import "OFArray.h"
#import "OFConcreteMutableDictionary.h"
#import "OFMapTable+Private.h"
#import "OFMapTable.h"
#import "OFString.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
static void *
copy(void *object)
{
return [(id)object copy];
}
static void *
retain(void *object)
{
return [(id)object retain];
}
static void
release(void *object)
{
[(id)object release];
}
static unsigned long
hash(void *object)
{
return [(id)object hash];
}
static bool
equal(void *object1, void *object2)
{
return [(id)object1 isEqual: (id)object2];
}
static const OFMapTableFunctions keyFunctions = {
.retain = copy,
.release = release,
.hash = hash,
.equal = equal
};
static const OFMapTableFunctions objectFunctions = {
.retain = retain,
.release = release,
.hash = hash,
.equal = equal
};
@implementation OFConcreteDictionary
- (instancetype)init
{
return [self initWithCapacity: 0];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
self = [super init];
@try {
_mapTable = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions
capacity: capacity];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
size_t count;
if (dictionary == nil)
return [self init];
if ([dictionary isKindOfClass: [OFConcreteDictionary class]] ||
[dictionary isKindOfClass: [OFConcreteMutableDictionary class]]) {
self = [super init];
@try {
OFConcreteDictionary *dictionary_ =
(OFConcreteDictionary *)dictionary;
_mapTable = [dictionary_->_mapTable copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
@try {
count = dictionary.count;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithCapacity: count];
@try {
void *pool = objc_autoreleasePoolPush();
OFEnumerator *keyEnumerator, *objectEnumerator;
id key, object;
keyEnumerator = [dictionary keyEnumerator];
objectEnumerator = [dictionary objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
[_mapTable setObject: object forKey: key];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)object forKey: (id)key
{
self = [self initWithCapacity: 1];
@try {
[_mapTable setObject: object forKey: key];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
count: (size_t)count
{
self = [self initWithCapacity: count];
@try {
size_t i;
for (i = 0; i < count; i++)
[_mapTable setObject: objects[i] forKey: keys[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
self = [super init];
@try {
va_list argumentsCopy;
id key, object;
size_t i, count;
va_copy(argumentsCopy, arguments);
if (firstKey == nil)
@throw [OFInvalidArgumentException exception];
key = firstKey;
if ((object = va_arg(arguments, id)) == nil)
@throw [OFInvalidArgumentException exception];
count = 1;
for (; va_arg(argumentsCopy, id) != nil; count++);
if (count % 2 != 0)
@throw [OFInvalidArgumentException exception];
count /= 2;
_mapTable = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions
capacity: count];
[_mapTable setObject: object forKey: key];
for (i = 1; i < count; i++) {
key = va_arg(arguments, id);
object = va_arg(arguments, id);
if (key == nil || object == nil)
@throw [OFInvalidArgumentException exception];
[_mapTable setObject: object forKey: key];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_mapTable release];
[super dealloc];
}
- (id)objectForKey: (id)key
{
return [_mapTable objectForKey: key];
}
- (size_t)count
{
return _mapTable.count;
}
- (bool)isEqual: (id)object
{
OFConcreteDictionary *dictionary;
if (object == self)
return true;
if (![object isKindOfClass: [OFConcreteDictionary class]] &&
![object isKindOfClass: [OFConcreteMutableDictionary class]])
return [super isEqual: object];
dictionary = (OFConcreteDictionary *)object;
return [dictionary->_mapTable isEqual: _mapTable];
}
- (bool)containsObject: (id)object
{
return [_mapTable containsObject: object];
}
- (bool)containsObjectIdenticalTo: (id)object
{
return [_mapTable containsObjectIdenticalTo: object];
}
- (OFArray *)allKeys
{
OFArray *ret;
id *keys;
size_t count;
count = _mapTable.count;
keys = OFAllocMemory(count, sizeof(*keys));
@try {
void *pool = objc_autoreleasePoolPush();
OFMapTableEnumerator *enumerator;
void **keyPtr;
size_t i;
i = 0;
enumerator = [_mapTable keyEnumerator];
while ((keyPtr = [enumerator nextObject]) != NULL) {
OFAssert(i < count);
keys[i++] = (id)*keyPtr;
}
objc_autoreleasePoolPop(pool);
ret = [OFArray arrayWithObjects: keys count: count];
} @finally {
OFFreeMemory(keys);
}
return ret;
}
- (OFArray *)allObjects
{
OFArray *ret;
id *objects;
size_t count;
count = _mapTable.count;
objects = OFAllocMemory(count, sizeof(*objects));
@try {
void *pool = objc_autoreleasePoolPush();
OFMapTableEnumerator *enumerator;
void **objectPtr;
size_t i;
i = 0;
enumerator = [_mapTable objectEnumerator];
while ((objectPtr = [enumerator nextObject]) != NULL) {
OFAssert(i < count);
objects[i++] = (id)*objectPtr;
}
objc_autoreleasePoolPop(pool);
ret = [OFArray arrayWithObjects: objects count: count];
} @finally {
OFFreeMemory(objects);
}
return ret;
}
- (OFEnumerator *)keyEnumerator
{
return [[[OFMapTableEnumeratorWrapper alloc]
initWithEnumerator: [_mapTable keyEnumerator]
object: self] autorelease];
}
- (OFEnumerator *)objectEnumerator
{
return [[[OFMapTableEnumeratorWrapper alloc]
initWithEnumerator: [_mapTable objectEnumerator]
object: self] autorelease];
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
return [_mapTable countByEnumeratingWithState: state
objects: objects
count: count];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock: (OFDictionaryEnumerationBlock)block
{
@try {
[_mapTable enumerateKeysAndObjectsUsingBlock:
^ (void *key, void *object, bool *stop) {
block(key, object, stop);
}];
} @catch (OFEnumerationMutationException *e) {
@throw [OFEnumerationMutationException
exceptionWithObject: self];
}
}
#endif
- (unsigned long)hash
{
return _mapTable.hash;
}
@end
objfw-1.3/src/OFConcreteMutableArray.h 100644 001750 001750 00000001646 14767513633 017005 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFArray.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMutableData;
@interface OFConcreteMutableArray: OFMutableArray
{
OFMutableData *_array;
unsigned long _mutations;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteMutableArray.m 100644 001750 001750 00000017347 14767513633 017017 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFConcreteMutableArray.h"
#import "OFConcreteArray.h"
#import "OFArray+Private.h"
#import "OFData.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteMutableArray
+ (void)initialize
{
if (self == [OFConcreteMutableArray class])
[self inheritMethodsFromClass: [OFConcreteArray class]];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
self = [super init];
@try {
_array = [[OFMutableData alloc] initWithItemSize: sizeof(id)
capacity: capacity];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)addObject: (id)object
{
if (object == nil)
@throw [OFInvalidArgumentException exception];
[_array addItem: &object];
[object retain];
_mutations++;
}
- (void)insertObject: (id)object atIndex: (size_t)idx
{
if (object == nil)
@throw [OFInvalidArgumentException exception];
@try {
[_array insertItem: &object atIndex: idx];
} @catch (OFOutOfRangeException *e) {
@throw [OFOutOfRangeException exception];
}
[object retain];
_mutations++;
}
- (void)insertObjectsFromArray: (OFArray *)array atIndex: (size_t)idx
{
id const *objects = array.objects;
size_t count = array.count;
@try {
[_array insertItems: objects atIndex: idx count: count];
} @catch (OFOutOfRangeException *e) {
@throw [OFOutOfRangeException exception];
}
for (size_t i = 0; i < count; i++)
[objects[i] retain];
_mutations++;
}
- (void)replaceObject: (id)oldObject withObject: (id)newObject
{
id *objects;
size_t count;
if (oldObject == nil || newObject == nil)
@throw [OFInvalidArgumentException exception];
objects = _array.mutableItems;
count = _array.count;
for (size_t i = 0; i < count; i++) {
if ([objects[i] isEqual: oldObject]) {
[newObject retain];
[objects[i] release];
objects[i] = newObject;
}
}
}
- (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object
{
id *objects;
id oldObject;
if (object == nil)
@throw [OFInvalidArgumentException exception];
objects = _array.mutableItems;
if (idx >= _array.count)
@throw [OFOutOfRangeException exception];
oldObject = objects[idx];
objects[idx] = [object retain];
[oldObject release];
}
- (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject
{
id *objects;
size_t count;
if (oldObject == nil || newObject == nil)
@throw [OFInvalidArgumentException exception];
objects = _array.mutableItems;
count = _array.count;
for (size_t i = 0; i < count; i++) {
if (objects[i] == oldObject) {
[newObject retain];
[objects[i] release];
objects[i] = newObject;
return;
}
}
}
- (void)removeObject: (id)object
{
id const *objects;
size_t count;
if (object == nil)
@throw [OFInvalidArgumentException exception];
objects = _array.items;
count = _array.count;
for (size_t i = 0; i < count; i++) {
if ([objects[i] isEqual: object]) {
id tmp = objects[i];
[_array removeItemAtIndex: i];
_mutations++;
[tmp release];
objects = _array.items;
i--;
count--;
continue;
}
}
}
- (void)removeObjectIdenticalTo: (id)object
{
id const *objects;
size_t count;
if (object == nil)
@throw [OFInvalidArgumentException exception];
objects = _array.items;
count = _array.count;
for (size_t i = 0; i < count; i++) {
if (objects[i] == object) {
[_array removeItemAtIndex: i];
_mutations++;
[object release];
objects = _array.items;
i--;
count--;
continue;
}
}
}
- (void)removeObjectAtIndex: (size_t)idx
{
#ifndef __clang_analyzer__
id object = [self objectAtIndex: idx];
[_array removeItemAtIndex: idx];
[object release];
_mutations++;
#endif
}
- (void)removeAllObjects
{
id const *objects = _array.items;
size_t count = _array.count;
for (size_t i = 0; i < count; i++)
[objects[i] release];
[_array removeAllItems];
}
- (void)removeObjectsInRange: (OFRange)range
{
id const *objects = _array.items;
size_t count = _array.count;
id *copy;
if (range.length > SIZE_MAX - range.location ||
range.location >= count || range.length > count - range.location)
@throw [OFOutOfRangeException exception];
copy = OFAllocMemory(range.length, sizeof(*copy));
memcpy(copy, objects + range.location, range.length * sizeof(id));
@try {
[_array removeItemsInRange: range];
_mutations++;
for (size_t i = 0; i < range.length; i++)
[copy[i] release];
} @finally {
OFFreeMemory(copy);
}
}
- (void)removeLastObject
{
#ifndef __clang_analyzer__
size_t count = _array.count;
id object;
if (count == 0)
return;
object = [self objectAtIndex: count - 1];
[_array removeLastItem];
[object release];
_mutations++;
#endif
}
- (void)exchangeObjectAtIndex: (size_t)idx1 withObjectAtIndex: (size_t)idx2
{
id *objects = _array.mutableItems;
size_t count = _array.count;
id tmp;
if (idx1 >= count || idx2 >= count)
@throw [OFOutOfRangeException exception];
tmp = objects[idx1];
objects[idx1] = objects[idx2];
objects[idx2] = tmp;
}
- (void)reverse
{
id *objects = _array.mutableItems;
size_t i, j, count = _array.count;
if (count == 0 || count == 1)
return;
for (i = 0, j = count - 1; i < j; i++, j--) {
id tmp = objects[i];
objects[i] = objects[j];
objects[j] = tmp;
}
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count_
{
size_t count = _array.count;
if (count > INT_MAX) {
/*
* Use the implementation from OFArray (OFMutableArray does not
* have one), which is slower, but can enumerate in chunks, and
* set the mutations pointer.
*/
int ret = [super countByEnumeratingWithState: state
objects: objects
count: count_];
state->mutationsPtr = &_mutations;
return ret;
}
if (state->state >= count)
return 0;
state->state = (unsigned long)count;
state->itemsPtr = (id *)_array.items;
state->mutationsPtr = &_mutations;
return (int)count;
}
- (OFEnumerator *)objectEnumerator
{
return [[[OFArrayEnumerator alloc]
initWithArray: self
mutationsPtr: &_mutations] autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
id const *objects = _array.items;
size_t count = _array.count;
bool stop = false;
unsigned long mutations = _mutations;
for (size_t i = 0; i < count && !stop; i++) {
if (_mutations != mutations)
@throw [OFEnumerationMutationException
exceptionWithObject: self];
block(objects[i], i, &stop);
}
}
- (void)replaceObjectsUsingBlock: (OFArrayReplaceBlock)block
{
id *objects = _array.mutableItems;
size_t count = _array.count;
unsigned long mutations = _mutations;
for (size_t i = 0; i < count; i++) {
id new;
if (_mutations != mutations)
@throw [OFEnumerationMutationException
exceptionWithObject: self];
new = block(objects[i], i);
if (new == nil)
@throw [OFInvalidArgumentException exception];
if (new != objects[i]) {
[objects[i] release];
objects[i] = [new retain];
}
}
}
#endif
- (void)makeImmutable
{
object_setClass(self, [OFConcreteArray class]);
}
@end
objfw-1.3/src/OFConcreteMutableData.h 100644 001750 001750 00000001675 14767513633 016602 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFMutableData.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteMutableData: OFMutableData
{
unsigned char *_Nullable _items;
size_t _capacity, _count, _itemSize;
bool _freeWhenDone;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteMutableData.m 100644 001750 001750 00000010655 14767513633 016605 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#include
#import "OFConcreteMutableData.h"
#import "OFConcreteData.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteMutableData
+ (void)initialize
{
if (self == [OFConcreteMutableData class])
[self inheritMethodsFromClass: [OFConcreteData class]];
}
- (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity
{
self = [super init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
_items = OFAllocMemory(capacity, itemSize);
_itemSize = itemSize;
_capacity = capacity;
_freeWhenDone = true;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithItemsNoCopy: (void *)items
count: (size_t)count
itemSize: (size_t)itemSize
freeWhenDone: (bool)freeWhenDone
{
self = [self initWithItems: items count: count itemSize: itemSize];
if (freeWhenDone)
OFFreeMemory(items);
return self;
}
- (void *)mutableItems
{
return _items;
}
- (void)addItem: (const void *)item
{
if (SIZE_MAX - _count < 1)
@throw [OFOutOfRangeException exception];
if (_count + 1 > _capacity) {
_items = OFResizeMemory(_items, _count + 1, _itemSize);
_capacity = _count + 1;
}
memcpy(_items + _count * _itemSize, item, _itemSize);
_count++;
}
- (void)addItems: (const void *)items count: (size_t)count
{
if (count > SIZE_MAX - _count)
@throw [OFOutOfRangeException exception];
if (_count + count > _capacity) {
_items = OFResizeMemory(_items, _count + count, _itemSize);
_capacity = _count + count;
}
memcpy(_items + _count * _itemSize, items, count * _itemSize);
_count += count;
}
- (void)insertItems: (const void *)items
atIndex: (size_t)idx
count: (size_t)count
{
if (count > SIZE_MAX - _count || idx > _count)
@throw [OFOutOfRangeException exception];
if (_count + count > _capacity) {
_items = OFResizeMemory(_items, _count + count, _itemSize);
_capacity = _count + count;
}
memmove(_items + (idx + count) * _itemSize, _items + idx * _itemSize,
(_count - idx) * _itemSize);
memcpy(_items + idx * _itemSize, items, count * _itemSize);
_count += count;
}
- (void)increaseCountBy: (size_t)count
{
if (count > SIZE_MAX - _count)
@throw [OFOutOfRangeException exception];
if (_count + count > _capacity) {
_items = OFResizeMemory(_items, _count + count, _itemSize);
_capacity = _count + count;
}
memset(_items + _count * _itemSize, '\0', count * _itemSize);
_count += count;
}
- (void)removeItemsInRange: (OFRange)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _count)
@throw [OFOutOfRangeException exception];
memmove(_items + range.location * _itemSize,
_items + (range.location + range.length) * _itemSize,
(_count - range.location - range.length) * _itemSize);
_count -= range.length;
@try {
_items = OFResizeMemory(_items, _count, _itemSize);
_capacity = _count;
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
- (void)removeLastItem
{
if (_count == 0)
return;
_count--;
@try {
_items = OFResizeMemory(_items, _count, _itemSize);
_capacity = _count;
} @catch (OFOutOfMemoryException *e) {
/* We don't care, as we only made it smaller */
}
}
- (void)removeAllItems
{
OFFreeMemory(_items);
_items = NULL;
_count = 0;
_capacity = 0;
}
- (void)makeImmutable
{
if (_capacity != _count) {
@try {
_items = OFResizeMemory(_items, _count, _itemSize);
_capacity = _count;
} @catch (OFOutOfMemoryException *e) {
/* We don't care, as we only made it smaller */
}
}
object_setClass(self, [OFConcreteData class]);
}
@end
objfw-1.3/src/OFConcreteMutableDictionary.h 100644 001750 001750 00000001627 14767513633 020033 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFDictionary.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMapTable;
@interface OFConcreteMutableDictionary: OFMutableDictionary
{
OFMapTable *_mapTable;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteMutableDictionary.m 100644 001750 001750 00000003412 14767513633 020032 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFConcreteMutableDictionary.h"
#import "OFConcreteDictionary.h"
#import "OFMapTable.h"
#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"
@implementation OFConcreteMutableDictionary
+ (void)initialize
{
if (self == [OFConcreteMutableDictionary class])
[self inheritMethodsFromClass: [OFConcreteDictionary class]];
}
- (void)setObject: (id)object forKey: (id)key
{
[_mapTable setObject: object forKey: key];
}
- (void)removeObjectForKey: (id)key
{
[_mapTable removeObjectForKey: key];
}
- (void)removeAllObjects
{
[_mapTable removeAllObjects];
}
#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (OFDictionaryReplaceBlock)block
{
@try {
[_mapTable replaceObjectsUsingBlock:
^ void *(void *key, void *object) {
return block(key, object);
}];
} @catch (OFEnumerationMutationException *e) {
@throw [OFEnumerationMutationException
exceptionWithObject: self];
}
}
#endif
- (void)makeImmutable
{
object_setClass(self, [OFConcreteDictionary class]);
}
@end
objfw-1.3/src/OFConcreteMutableSet.h 100644 001750 001750 00000001611 14767513633 016452 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFMutableSet.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMapTable;
@interface OFConcreteMutableSet: OFMutableSet
{
OFMapTable *_mapTable;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteMutableSet.m 100644 001750 001750 00000002424 14767513633 016462 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFConcreteMutableSet.h"
#import "OFConcreteSet.h"
#import "OFMapTable.h"
@implementation OFConcreteMutableSet
+ (void)initialize
{
if (self == [OFConcreteMutableSet class])
[self inheritMethodsFromClass: [OFConcreteSet class]];
}
- (void)addObject: (id)object
{
[_mapTable setObject: (void *)1 forKey: object];
}
- (void)removeObject: (id)object
{
[_mapTable removeObjectForKey: object];
}
- (void)removeAllObjects
{
[_mapTable removeAllObjects];
}
- (void)makeImmutable
{
object_setClass(self, [OFConcreteSet class]);
}
@end
objfw-1.3/src/OFConcreteNumber.h 100644 001750 001750 00000001700 14767513633 015634 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFNumber.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteNumber: OFNumber
{
union {
double float_;
long long signed_;
unsigned long long unsigned_;
} _value;
char _typeEncoding;
}
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteNumber.m 100644 001750 001750 00000012742 14767513633 015651 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#include
#import "OFConcreteNumber.h"
#import "OFInvalidFormatException.h"
static bool
isUnsigned(OFNumber *number)
{
switch (*number.objCType) {
case 'B':
case 'C':
case 'S':
case 'I':
case 'L':
case 'Q':
return true;
default:
return false;
}
}
static bool
isSigned(OFNumber *number)
{
switch (*number.objCType) {
case 'c':
case 's':
case 'i':
case 'l':
case 'q':
return true;
default:
return false;
}
}
static bool
isFloat(OFNumber *number)
{
switch (*number.objCType) {
case 'f':
case 'd':
return true;
default:
return false;
}
}
@implementation OFConcreteNumber
- (instancetype)initWithBytes: (const void *)bytes
objCType: (const char *)objCType
{
#define CASE(type, method) \
if (strcmp(objCType, @encode(type)) == 0) { \
type value; \
memcpy(&value, bytes, sizeof(type)); \
return [self method value]; \
}
CASE(bool, initWithBool:)
CASE(signed char, initWithChar:)
CASE(short, initWithShort:)
CASE(int, initWithInt:)
CASE(long, initWithLong:)
CASE(long long, initWithLongLong:)
CASE(unsigned char, initWithUnsignedChar:)
CASE(unsigned short, initWithUnsignedShort:)
CASE(unsigned int, initWithUnsignedInt:)
CASE(unsigned long, initWithUnsignedLong:)
CASE(unsigned long long, initWithUnsignedLongLong:)
CASE(float, initWithFloat:)
CASE(double, initWithDouble:)
[self release];
@throw [OFInvalidFormatException exception];
}
- (instancetype)initWithBool: (bool)value
{
self = [super initWithBytes: &value objCType: @encode(bool)];
_value.unsigned_ = value;
_typeEncoding = *@encode(bool);
return self;
}
- (instancetype)initWithChar: (signed char)value
{
self = [super initWithBytes: &value objCType: @encode(signed char)];
_value.signed_ = value;
_typeEncoding = *@encode(signed char);
return self;
}
- (instancetype)initWithShort: (short)value
{
self = [super initWithBytes: &value objCType: @encode(short)];
_value.signed_ = value;
_typeEncoding = *@encode(short);
return self;
}
- (instancetype)initWithInt: (int)value
{
self = [super initWithBytes: &value objCType: @encode(int)];
_value.signed_ = value;
_typeEncoding = *@encode(int);
return self;
}
- (instancetype)initWithLong: (long)value
{
self = [super initWithBytes: &value objCType: @encode(long)];
_value.signed_ = value;
_typeEncoding = *@encode(long);
return self;
}
- (instancetype)initWithLongLong: (long long)value
{
self = [super initWithBytes: &value objCType: @encode(long long)];
_value.signed_ = value;
_typeEncoding = *@encode(long long);
return self;
}
- (instancetype)initWithUnsignedChar: (unsigned char)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned char)];
_value.unsigned_ = value;
_typeEncoding = *@encode(unsigned long);
return self;
}
- (instancetype)initWithUnsignedShort: (unsigned short)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned short)];
_value.unsigned_ = value;
_typeEncoding = *@encode(unsigned short);
return self;
}
- (instancetype)initWithUnsignedInt: (unsigned int)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned int)];
_value.unsigned_ = value;
_typeEncoding = *@encode(unsigned int);
return self;
}
- (instancetype)initWithUnsignedLong: (unsigned long)value
{
self = [super initWithBytes: &value objCType: @encode(unsigned long)];
_value.unsigned_ = value;
_typeEncoding = *@encode(unsigned long);
return self;
}
- (instancetype)initWithUnsignedLongLong: (unsigned long long)value
{
self = [super initWithBytes: &value
objCType: @encode(unsigned long long)];
_value.unsigned_ = value;
_typeEncoding = *@encode(unsigned long long);
return self;
}
- (instancetype)initWithFloat: (float)value
{
self = [super initWithBytes: &value objCType: @encode(float)];
_value.float_ = value;
_typeEncoding = *@encode(float);
return self;
}
- (instancetype)initWithDouble: (double)value
{
self = [super initWithBytes: &value objCType: @encode(double)];
_value.float_ = value;
_typeEncoding = *@encode(double);
return self;
}
- (const char *)objCType
{
return &_typeEncoding;
}
- (long long)longLongValue
{
if (isFloat(self))
return _value.float_;
else if (isSigned(self))
return _value.signed_;
else if (isUnsigned(self))
return _value.unsigned_;
else
@throw [OFInvalidFormatException exception];
}
- (unsigned long long)unsignedLongLongValue
{
if (isFloat(self))
return _value.float_;
else if (isSigned(self))
return _value.signed_;
else if (isUnsigned(self))
return _value.unsigned_;
else
@throw [OFInvalidFormatException exception];
}
- (double)doubleValue
{
if (isFloat(self))
return _value.float_;
else if (isSigned(self))
return _value.signed_;
else if (isUnsigned(self))
return _value.unsigned_;
else
@throw [OFInvalidFormatException exception];
}
@end
objfw-1.3/src/OFConcreteSet.h 100644 001750 001750 00000001651 14767513633 015144 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFSet.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMapTable;
@interface OFConcreteSet: OFSet
{
OFMapTable *_mapTable;
}
- (instancetype)initWithCapacity: (size_t)capacity;
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteSet.m 100644 001750 001750 00000012214 14767513633 015146 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFConcreteSet.h"
#import "OFArray.h"
#import "OFConcreteCountedSet.h"
#import "OFConcreteMutableSet.h"
#import "OFMapTable+Private.h"
#import "OFMapTable.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFEnumerationMutationException.h"
static void *
retain(void *object)
{
return [(id)object retain];
}
static void
release(void *object)
{
[(id)object release];
}
static unsigned long
hash(void *object)
{
return [(id)object hash];
}
static bool
equal(void *object1, void *object2)
{
return [(id)object1 isEqual: (id)object2];
}
static const OFMapTableFunctions keyFunctions = {
.retain = retain,
.release = release,
.hash = hash,
.equal = equal
};
static const OFMapTableFunctions objectFunctions = { NULL };
@implementation OFConcreteSet
- (instancetype)init
{
return [self initWithCapacity: 0];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
self = [super init];
@try {
_mapTable = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions
capacity: capacity];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSet: (OFSet *)set
{
size_t count;
if (set == nil)
return [self init];
@try {
count = set.count;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithCapacity: count];
@try {
for (id object in set)
[_mapTable setObject: (void *)1 forKey: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithArray: (OFArray *)array
{
size_t count;
if (array == nil)
return self;
@try {
count = array.count;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithCapacity: count];
@try {
for (id object in array)
[_mapTable setObject: (void *)1 forKey: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
self = [self initWithCapacity: count];
@try {
for (size_t i = 0; i < count; i++)
[_mapTable setObject: (void *)1 forKey: objects[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
self = [super init];
@try {
id object;
va_list argumentsCopy;
size_t count;
va_copy(argumentsCopy, arguments);
for (count = 1; va_arg(argumentsCopy, id) != nil; count++);
_mapTable = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions
capacity: count];
[_mapTable setObject: (void *)1 forKey: firstObject];
while ((object = va_arg(arguments, id)) != nil)
[_mapTable setObject: (void *)1 forKey: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_mapTable release];
[super dealloc];
}
- (size_t)count
{
return [_mapTable count];
}
- (bool)containsObject: (id)object
{
if (object == nil)
return false;
return ([_mapTable objectForKey: object] != nil);
}
- (bool)isEqual: (id)object
{
OFConcreteSet *set;
if (object == self)
return true;
if (![object isKindOfClass: [OFConcreteSet class]] &&
![object isKindOfClass: [OFConcreteMutableSet class]] &&
![object isKindOfClass: [OFConcreteCountedSet class]])
return [super isEqual: object];
set = object;
return [set->_mapTable isEqual: _mapTable];
}
- (id)anyObject
{
void *pool = objc_autoreleasePoolPush();
void **objectPtr;
id object;
objectPtr = [[_mapTable keyEnumerator] nextObject];
if (objectPtr == NULL) {
objc_autoreleasePoolPop(pool);
return nil;
}
object = [(id)*objectPtr retain];
objc_autoreleasePoolPop(pool);
return [object autorelease];
}
- (OFEnumerator *)objectEnumerator
{
return [[[OFMapTableEnumeratorWrapper alloc]
initWithEnumerator: [_mapTable keyEnumerator]
object: self] autorelease];
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
return [_mapTable countByEnumeratingWithState: state
objects: objects
count: count];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (OFSetEnumerationBlock)block
{
@try {
[_mapTable enumerateKeysAndObjectsUsingBlock:
^ (void *key, void *object, bool *stop) {
block(key, stop);
}];
} @catch (OFEnumerationMutationException *e) {
@throw [OFEnumerationMutationException
exceptionWithObject: self];
}
}
#endif
@end
objfw-1.3/src/OFConcreteSubarray.h 100644 001750 001750 00000001523 14767513633 016177 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#import "OFSubarray.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFConcreteSubarray: OFSubarray
@end
OF_ASSUME_NONNULL_END
objfw-1.3/src/OFConcreteSubarray.m 100644 001750 001750 00000003317 14767513633 016207 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* .
*/
#include "config.h"
#import "OFConcreteSubarray.h"
#import "OFConcreteArray.h"
#import "OFConcreteMutableArray.h"
@implementation OFConcreteSubarray
- (const id *)objects
{
return _array.objects + _range.location;
}
- (bool)isEqual: (id)object
{
OFArray *otherArray;
id const *objects, *otherObjects;
if (object == self)
return true;
if (![object isKindOfClass: [OFConcreteArray class]] &&
![object isKindOfClass: [OFConcreteMutableArray class]])
return [super isEqual: object];
otherArray = object;
if (_range.length != otherArray.count)
return false;
objects = self.objects;
otherObjects = otherArray.objects;
for (size_t i = 0; i < _range.length; i++)
if (![objects[i] isEqual: otherObjects[i]])
return false;
return true;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
id const *objects = self.objects;
bool stop = false;
for (size_t i = 0; i < _range.length && !stop; i++)
block(objects[i], i, &stop);
}
#endif
@end
objfw-1.3/src/OFConcreteValue.h 100644 001750 001750 00000001576 14767513633 015473 0 ustar 00js js 000000 000000 /*
* Copyright (c) 2008-2025 Jonathan Schleifer
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3.0 only,
* as published by the Free Software Foundation.
*
* 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 Lesser General Public License
* version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
*