Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial upload of skeleton API

  • Loading branch information...
commit e282512d60e3a3d3101ea7b5ca479640ad09e1d0 0 parents
Pieter Hintjens hintjens authored
Showing with 4,576 additions and 0 deletions.
  1. +8 −0 AUTHORS
  2. +674 −0 COPYING
  3. +206 −0 COPYING.LESSER
  4. 0  ChangeLog
  5. +4 −0 Makefile.am
  6. +1 −0  NEWS
  7. 0  README
  8. +399 −0 README.md
  9. +66 −0 README.txt
  10. +43 −0 autogen.sh
  11. +520 −0 c
  12. +214 −0 configure.in
  13. +37 −0 doc/Makefile.am
  14. +57 −0 doc/asciidoc.conf
  15. +109 −0 doc/zapi.txt
  16. +48 −0 doc/zctx.txt
  17. +49 −0 doc/zframe.txt
  18. +51 −0 doc/zloop.txt
  19. +59 −0 doc/zmsg.txt
  20. +35 −0 doc/zstr.txt
  21. +44 −0 include/zapi.h
  22. +120 −0 include/zapi_prelude.h
  23. +54 −0 include/zctx.h
  24. +60 −0 include/zframe.h
  25. +61 −0 include/zloop.h
  26. +70 −0 include/zmsg.h
  27. +43 −0 include/zstr.h
  28. +37 −0 src/Makefile.am
  29. +55 −0 src/zapi_selftest.c
  30. +140 −0 src/zctx.c
  31. +136 −0 src/zframe.c
  32. +132 −0 src/zloop.c
  33. +213 −0 src/zmsg.c
  34. +70 −0 src/zstr.c
  35. +18 −0 win32/.gitignore
  36. +17 −0 win32/README.txt
  37. +29 −0 win32/zapi.sln
  38. +505 −0 win32/zapi.vcproj
  39. +192 −0 win32/zapi_selftest.vcproj
8 AUTHORS
@@ -0,0 +1,8 @@
+Authors
+=======
+
+Pieter Hintjens <ph@imatix.com>
+
+Contributors
+============
+
674 COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ 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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 <http://www.gnu.org/licenses/>.
+
+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:
+
+ <program> Copyright (C) <year> <name of author>
+ 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
+<http://www.gnu.org/licenses/>.
+
+ 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
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
206 COPYING.LESSER
@@ -0,0 +1,206 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ 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.
+
+--------------------------------------------------------------------------------
+
+ SPECIAL EXCEPTION GRANTED BY IMATIX
+
+As a special exception, iMatix gives you permission to link this library with
+independent modules to produce an executable, regardless of the license terms
+of these independent modules, and to copy and distribute the resulting
+executable under terms of your choice, provided that you also meet, for each
+linked independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from or based on
+this library. If you modify this library, you must extend this exception to your
+version of the library.
+
+--------------------------------------------------------------------------------
+
+Parts of the software are licensed under the MIT (X11) license as follows:
+
+Copyright (c) 2007-2011 Contributors as listed in AUTHORS
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
0  ChangeLog
No changes.
4 Makefile.am
@@ -0,0 +1,4 @@
+ACLOCAL_AMFLAGS = -I config
+
+SUBDIRS = src doc
+DIST_SUBDIRS = src doc
1  NEWS
@@ -0,0 +1 @@
+See git log.
0  README
No changes.
399 README.md
@@ -0,0 +1,399 @@
+
+<A name="toc1-3" title="ZFL - ØMQ Function Library" />
+# ZFL - ØMQ Function Library
+
+<A name="toc2-6" title="Contents" />
+## Contents
+
+
+**<a href="#toc2-11">Overview</a>**
+&emsp;<a href="#toc3-14">Scope and Goals</a>
+&emsp;<a href="#toc3-23">Ownership and License</a>
+&emsp;<a href="#toc3-30">Contributing</a>
+
+**<a href="#toc2-41">Using ZFL</a>**
+&emsp;<a href="#toc3-44">Building and Installing</a>
+&emsp;<a href="#toc3-65">Linking with an Application</a>
+&emsp;<a href="#toc3-76">The Class Model</a>
+&emsp;<a href="#toc3-109">ZFL Classes</a>
+&emsp;<a href="#toc3-126">Predefined Macros</a>
+&emsp;<a href="#toc3-167">Error Handling</a>
+
+**<a href="#toc2-172">Design Ideology</a>**
+&emsp;<a href="#toc3-175">The Problem with C</a>
+&emsp;<a href="#toc3-184">A Simple Class Model</a>
+&emsp;<a href="#toc3-211">Naming Style</a>
+&emsp;<a href="#toc3-220">Containers</a>
+&emsp;<a href="#toc3-232">Inheritance</a>
+&emsp;<a href="#toc3-241">Portability</a>
+&emsp;<a href="#toc3-267">Technical Aspects</a>
+
+**<a href="#toc2-283">Under the Hood</a>**
+&emsp;<a href="#toc3-286">Adding a New Class</a>
+&emsp;<a href="#toc3-299">Coding Style</a>
+&emsp;<a href="#toc3-318">Assertions</a>
+&emsp;<a href="#toc3-336">Documentation</a>
+&emsp;<a href="#toc3-341">Porting ZFL</a>
+&emsp;<a href="#toc3-354">Memory Leak Testing</a>
+&emsp;<a href="#toc3-367">This Document</a>
+
+<A name="toc2-11" title="Overview" />
+## Overview
+
+<A name="toc3-14" title="Scope and Goals" />
+### Scope and Goals
+
+ZFL is the ØMQ Function Library, a thin portability & function library for ZeroMQ applications in C/C++. It is written as clear readable C classes, portable to all ØMQ platforms, and licensed under the LGPL.
+
+The main goal is to allow the construction of industrial-scale ØMQ services and devices that integrate properly with the operating system, while staying 100% portable. ZFL acts as a primary abstraction layer on top of the ØMQ API, mainly for C applications but also for other languages. ZFL is inspired by the iMatix Standard Function Library (SFL), and borrows liberally from it. See http://legacy.imatix.com/html/sfl/.
+
+ZFL is meant to be lightweight, consistent, class-based, minimalistic, highly efficient, and aimed at making it faster and easier to develop realistic, secure, and portable ØMQ devices and applications.
+
+<A name="toc3-23" title="Ownership and License" />
+### Ownership and License
+
+ZFL is maintained by Pieter Hintjens and Martin Hurton (code) and Mikko Koppanen (build system). Its other authors and contributors are listed in the AUTHORS file. It is held by the ZeroMQ organization at github.com.
+
+The authors of ZFL grant you use of this software under the terms of the GNU Lesser General Public License (LGPL). For details see the files `COPYING` and `COPYING.LESSER` in this directory.
+
+<A name="toc3-30" title="Contributing" />
+### Contributing
+
+To submit an issue use the [issue tracker](http://github.com/zeromq/zfl/issues). All discussion happens on the [zeromq-dev](zeromq-dev@lists.zeromq.org) list or #zeromq IRC channel at irc.freenode.net.
+
+The proper way to submit patches is to clone this repository, make your changes, and use git to create a patch. See http://www.zeromq.org/docs:contributing. All contributors are listed in AUTHORS.
+
+All classes are maintained by a single person, who is the responsible editor for that class and who is named in the header as such. This is usually the originator of the class. When several people collaborate on a class, one single person is always the lead maintainer and the one to blame when it breaks.
+
+The general rule is, if you contribute code to ZFL you must be willing to maintain it as long as there are users of it. Code with no active maintainer will in general be deprecated and/or removed.
+
+<A name="toc2-41" title="Using ZFL" />
+## Using ZFL
+
+<A name="toc3-44" title="Building and Installing" />
+### Building and Installing
+
+ZFL uses autotools for packaging. To build from git (all example commands are for Linux):
+
+ git clone git://github.com/zeromq/zfl.git
+ cd zfl
+ sh autogen.sh
+ ./configure
+ make all
+ sudo make install
+ sudo ldconfig
+
+You will need the libtool and autotools packages. On FreeBSD, you may need to specify the default directories for configure:
+
+ ./configure --with-zeromq=/usr/local
+
+After building, you can run the ZFL selftests:
+
+ make check
+
+<A name="toc3-65" title="Linking with an Application" />
+### Linking with an Application
+
+Include `zfl.h` in your application and link with libzfl. Here is a typical gcc link command:
+
+ gcc -lzfl -lzmq myapp.c -o myapp
+
+You should read `zfl.h`. This file includes `zmq.h` and the system header files that typical ØMQ applications will need. The provided 'c' shell script lets you write simple portable build scripts:
+
+ c -lzfl -lzmq -l myapp
+
+<A name="toc3-76" title="The Class Model" />
+### The Class Model
+
+ZFL consists of classes, each class consisting of a .h and a .c. Classes may depend on other classes.
+
+`zfl.h` includes all classes header files, all the time. For the user, ZFL forms one single package. All classes start by including `zfl.h`. All applications that use ZFL start by including `zfl.h`. `zfl.h` also defines a limited number of small, useful macros and typedefs that have proven useful for writing clearer C code.
+
+The canonical example for ZFL style is the zfl_base class, which defines the template for all other classes. The nomenclature for all classes is consistent. We use zfl_base as an example:
+
+* Source files: zfl_base.c, zfl_base.h
+* Methods: zfl_base_test, zfl_base_print, ...
+
+All classes are based on a flat C class system and follow these rules:
+
+* Class typedef: `zfl_base_t`
+* Constructor: `zfl_base_new`
+* Destructor: `zfl_base_destroy`
+* Property methods: `zfl_base_property_set`, `zfl_base_property`
+* Class structures are private (defined in the .c source but not the .h)
+* Properties are accessed only via methods named as described above.
+* In the class source code the object is always called `self`.
+* The constructor may take arbitrary arguments, and returns NULL on failure, or a new object.
+* The destructor takes a pointer to an object reference and nullifies it.
+
+Return values for methods are:
+
+* For methods that return an object reference, either the reference, or NULL on failure.
+* For methods that signal success/failure, a return value of 0 means sucess, -1 failure.
+
+Private/static functions in a class are named `s_functionname` and are not exported via the header file.
+
+All classes have a test method called `zfl_classname_test`.
+
+<A name="toc3-109" title="ZFL Classes" />
+### ZFL Classes
+
+These are the existing ZFL classes:
+
+* zfl_base - base class for ZFL
+* zfl_blob - binary long object
+* zfl_clock - system timer & date functions
+* zfl_config - work with configuration files
+* zfl_device - configure a device or device socket
+* zfl_hash - expandable hash table container
+* zfl_list - singly-linked list container
+* zfl_msg - multipart ØMQ message
+* zfl_rpcd - server side reliable RPC
+* zfl_rpc - client side reliable RPC
+* zfl_thread - work with operating system threads
+
+<A name="toc3-126" title="Predefined Macros" />
+### Predefined Macros
+
+The file zfl_prelude.h defines a number of macros including these:
+
+ #define FOREVER for (;;) // FOREVER { ... }
+ #define until(expr) while (!(expr)) // do { ... } until (expr)
+ #define streq(s1,s2) (!strcmp ((s1), (s2)))
+ #define strneq(s1,s2) (strcmp ((s1), (s2)))
+ #define strused(s) (*(s) != 0)
+ #define strnull(s) (*(s) == 0)
+ #define strclr(s) (*(s) = 0)
+ #define strlast(s) ((s) [strlen (s) - 1])
+ #define strterm(s) ((s) [strlen (s)])
+
+ #define tblsize(x) (sizeof (x) / sizeof ((x) [0]))
+ #define tbllast(x) (x [tblsize (x) - 1])
+
+ #define randomof(num) (int) (((float) num) * rand () / (RAND_MAX + 1.0))
+ #define randomize() srand ((uint) apr_time_usec (apr_time_now ()))
+
+ #if (!defined (MIN))
+ # define MIN(a,b) (((a) < (b))? (a): (b))
+ # define MAX(a,b) (((a) > (b))? (a): (b))
+ #endif
+
+ //- Assertion that pointer value is as expect -------------------------------
+
+ #define assert_eq(value,const) \
+ if ((value) != (const)) {\
+ printf ("Assertion failed, expected=%d actual=%d", (const), (value));\
+ assert ((value) == (const));\
+ }
+
+ //- Boolean operators and constants -----------------------------------------
+
+ #if (!defined (TRUE))
+ # define TRUE 1 // ANSI standard
+ # define FALSE 0
+ #endif
+
+<A name="toc3-167" title="Error Handling" />
+### Error Handling
+
+Functions that create or search objects return object references success and NULL on failure. Functions that perform work return 0 on success and -1 on failure.
+
+<A name="toc2-172" title="Design Ideology" />
+## Design Ideology
+
+<A name="toc3-175" title="The Problem with C" />
+### The Problem with C
+
+C has the significant advantage of being a small language that, if we take a little care with formatting and naming, can be easily interchanged between developers. Every C developer will use much the same 90% of the language. Larger languages like C++ provide powerful abstractions like STL containers but at the cost of interchange. Every C++ developer will use a different 20% of the language.
+
+The huge problem with C is that any realistic application needs packages of functionality to bring the language up to the levels we expect for the 21st century. Much can be done by using external libraries but every additional library is a dependency that makes the resulting applications harder to build and port. While C itself is a highly portable language (and can be made more so by careful use of the preprocessor), most C libraries consider themselves part of the operating system, and as such do not attempt to be portable.
+
+The answer to this, as we learned from building enterprise-level C applications at iMatix from 1995-2005, is to create our own fully portable, high-quality libraries of pre-packaged functionality, in C. Doing this right solves both the requirements of richness of the language, and of portability of the final applications.
+
+<A name="toc3-184" title="A Simple Class Model" />
+### A Simple Class Model
+
+C has no standard API style. It is one thing to write a useful component, but something else to provide an API that is consistent and obvious across many components. We learned from building [OpenAMQ](http://www.openamq.org), a messaging client and server of 0.5M LoC, that a consistent model for extending C makes life for the application developer much easier.
+
+The general model is that of a class (the source package) that provides objects (in fact C structures). The application creates objects and then works with them. When done, the application destroys the object. In C, we tend to use the same name for the object as the class, when we can, and it looks like this (to take a fictitious ZFL class):
+
+ zfl_regexp_t *regexp = zfl_regexp_new (regexp_string);
+ if (!regexp)
+ printf ("E: invalid regular expression: %s\n", regexp_string);
+ else
+ if (zfl_regexp_match (regexp, input_buffer))
+ printf ("I: successful match for %s\n", input buffer);
+ zfl_regexp_destroy (&regexp);
+
+As far as the C program is concerned, the object is a reference to a structure (not a void pointer). We pass the object reference to all methods, since this is still C. We could do weird stuff like put method addresses into the structure so that we can emulate a C++ syntax but it's not worthwhile. The goal is not to emulate an OO system, it's simply to gain consistency. The constructor returns an object reference, or NULL if it fails. The destructor nullifies the class pointer, and is idempotent.
+
+What we aim at here is the simplest possible consistent syntax.
+
+No model is fully consistent, and classes can define their own rules if it helps make a better result. For example:
+
+* Some classes may not be opaque. For example, we have cases of generated serialization classes that encode and decode structures to/from binary buffers. It feels clumsy to have to use methods to access the properties of these classes.
+
+* While every class has a new method that is the formal constructor, some methods may also act as constructors. For example, a "dup" method might take one object and return a second object.
+
+* While every class has a destroy method that is the formal destructor, some methods may also act as destructors. For example, a method that sends an object may also destroy the object (so that ownership of any buffers can passed to background threads). Such methods take the same "pointer to a reference" argument as the destroy method.
+
+<A name="toc3-211" title="Naming Style" />
+### Naming Style
+
+ZFL aims for short, consistent names, following the theory that names we use most often should be shortest. Classes get one-word names, unless they are part of a family of classes in which case they may be two words, the first being the family name. Methods, similarly, get one-word names and we aim for consistency across classes (so a method that does something semantically similar in two classes will get the same name in both). So the canonical name for any method is:
+
+ zfl_classname_methodname
+
+And the reader can easily parse this without needing special syntax to separate the class name from the method name.
+
+<A name="toc3-220" title="Containers" />
+### Containers
+
+After a long experiment with containers, we've decided that we need exactly two containers:
+
+* A singly-linked list.
+* A hash table using text keys.
+
+These are zfl_list and zfl_hash, respectively. Both store void pointers, with no attempt to manage the details of contained objects. You can use these containers to create lists of lists, hashes of lists, hashes of hashes, etc.
+
+We assume that at some point we'll need to switch to a doubly-linked list.
+
+<A name="toc3-232" title="Inheritance" />
+### Inheritance
+
+ZFL provides two ways to do inheritance from base classes to higher level classes. First, by code copying. You may laugh but it works. The zfl_base class defines a basic syntactic structure. If we decide to change some of the ground rules shared by all classes, we modify the zfl_base class and then we manually make the same modifications in all other ZFL classes. Obviously as the number of classes in ZFL grows this becomes progressively harder, which is good: we don't want the basics to change more than they need to.
+
+The second way is by straight encapsulation. For example if I want to make a specialized container that has some intelligence about the objects it contains, I can take the list or hash class, wrap that in a new class and add the necessary code on top. There is no attempt, nor need, to export methods or properties automatically. If I want this, I do it by hand.
+
+Writing such code by hand may seem laborious but when we work with ruthlessly consistent style and semantics, it is easy, safe, and often the shortest path from problem to solution.
+
+<A name="toc3-241" title="Portability" />
+### Portability
+
+Creating a portable C application can be rewarding in terms of maintaining a single code base across many platforms, and keeping (expensive) system-specific knowledge separate from application developers. In most projects (like ØMQ core), there is no portability layer and application code does conditional compilation for all mixes of platforms. This leads to quite messy code.
+
+ZFL is explicitly meant to become a portability layer, similar to but thinner than libraries like the [Apache Portable Runtime](http://apr.apache.org) (APR).
+
+These are the places a C application is subject to arbitrary system differences:
+
+* Different compilers may offer slightly different variants of the C language, often lacking specific types or using neat non-portable names. Windows is a big culprit here. We solve this by 'patching' the language in zfl_prelude.h, e.g. defining int64_t on Windows.
+* System header files are inconsistent, i.e. you need to include different files depending on the OS type and version. We solve this by pulling in all necessary header files in zfl_prelude.h. This is a proven brute-force approach that increases recompilation times but eliminates a major source of pain.
+* System libraries are inconsistent, i.e. you need to link with different libraries depending on the OS type and version. We solve this with an external compilation tool, 'C', which detects the OS type and version (at runtime) and builds the necessary link commands.
+* System functions are inconsistent, i.e. you need to call different functions depending, again, on OS type and version. We solve this by building small abstract classes that handle specific areas of functionality, and doing conditional compilation in these.
+
+An example of the last:
+
+ #if (defined (__UNIX__))
+ pid = GetCurrentProcessId();
+ #elif (defined (__WINDOWS__))
+ pid = getpid ();
+ #else
+ pid = 0;
+ #endif
+
+ZFL uses the GNU autotools system, so non-portable code can use the macros this defines. It can also use macros defined by the zfl_prelude.h header file.
+
+<A name="toc3-267" title="Technical Aspects" />
+### Technical Aspects
+
+* *Thread safety*: the use of opaque structures is thread safe, though ØMQ applications should not share state between threads in any case.
+* *Name spaces*: we prefix class names with `zfl_`, which ensures that all exported functions are globally safe.
+* *Library versioning*: we don't make any attempt to version the library at this stage. Classes are in our experience highly stable once they are built and tested, the only changes typically being added methods.
+* *Performance*: for critical path processing, you may want to avoid creating and destroying classes. However on modern Linux systems the heap allocator is very fast. Individual classes can choose whether or not to nullify their data on allocation.
+* *Self-testing*: every class has a `selftest` method that runs through the methods of the class. In theory, calling all selftest functions of all classes does a full unit test of the library. The `zfl_selftest` application does this.
+* *Portability*: the ZFL library is aimed at becoming a portability layer (like Apache APR or the older iMatix SFL) but that depends on it actually being ported. See section on 'Porting ZFL' below.
+* *Memory management*: ZFL classes do not use any special memory management techiques to detect leaks. We've done this in the past but it makes the code relatively complex. Instead, we do memory leak testing using tools like mtrace:
+
+ gcc -g -o zfl_selftest zfl*.c -lzmq
+ export MALLOC_TRACE=mtrace.txt
+ zfl_selftest
+ mtrace zfl_selftest mtrace.txt
+
+<A name="toc2-283" title="Under the Hood" />
+## Under the Hood
+
+<A name="toc3-286" title="Adding a New Class" />
+### Adding a New Class
+
+If you define a new ZFL class `myclass` you need to:
+
+* Write the `zfl_myclass.c` and `zfl_myclass.h` source files, in `zfl/src` and `zfl/include` respectively.
+* Add`#include <zfl_myclass.h>` to `zfl/include/zfl.h`.
+* Add the myclass header and test call to `src/zfl_selftest.c`.
+* Add a reference documentation to 'doc/zfl_myclass.txt'.
+* Add myclass to 'src/Makefile.am` and `doc/Makefile.am`.
+
+The `bin/newclass.sh` shell script will automate these steps for you.
+
+<A name="toc3-299" title="Coding Style" />
+### Coding Style
+
+In general the zfl_base class defines the style for the whole library. The overriding rules for coding style are consistency, clarity, and ease of maintenance. We use the C99 standard for syntax including principally:
+
+* The // comment style.
+* Variables definitions placed in or before the code that uses them.
+
+So while ANSI C code might say:
+
+ zfl_blob_t *file_buffer; /* Buffer for our file */
+ ... (100 lines of code)
+ file_buffer = zfl_blob_new ();
+ ...
+
+The style in ZFL would be:
+
+ zfl_blob_t *file_buffer = zfl_blob_new ();
+
+<A name="toc3-318" title="Assertions" />
+### Assertions
+
+We use assertions heavily to catch bad argument values. The ZFL classes do not attempt to validate arguments and report errors; bad arguments are treated as fatal application programming errors.
+
+We also use assertions heavily on calls to system functions that are never supposed to fail, where failure is to be treated as a fatal non-recoverable error (e.g. running out of memory).
+
+Assertion code should always take this form:
+
+ int rc = some_function (arguments);
+ assert (rc == 0);
+
+Rather than the side-effect form:
+
+ assert (some_function (arguments) == 0);
+
+Since assertions may be removed by an optimizing compiler.
+
+<A name="toc3-336" title="Documentation" />
+### Documentation
+
+Each ZFL class has its own man page in the doc directory. The contents of the man page are cut/paste from the class header and source files. Please maintain the doc file as you add new methods or modify the class test method (which for most classes acts as the EXAMPLE code).
+
+<A name="toc3-341" title="Porting ZFL" />
+### Porting ZFL
+
+When you try ZFL on an OS that it's not been used on (ever, or for a while), you will hit code that does not compile. In some cases the patches are trivial, in other cases (usually when porting to Windows), the work needed to build equivalent functionality may be quite heavy. In any case, the benefit is that once ported, the functionality is available to all applications.
+
+Before attempting to patch code for portability, please read the `zfl_prelude.h` header file. There are several typical types of changes you may need to make to get functionality working on a specific operating system:
+
+* Defining typedefs which are missing on that specific compiler: do this in zfl_prelude.h.
+* Defining macros that rename exotic library functions to more conventional names: do this in zfl_prelude.h.
+* Reimplementing specific methods to use a non-standard API: this is typically needed on Windows. Do this in the relevant class, using #ifdefs to properly differentiate code for different platforms.
+
+The canonical 'standard operating system' for all ZFL code is Linux, gcc, POSIX.
+
+<A name="toc3-354" title="Memory Leak Testing" />
+### Memory Leak Testing
+
+To test against memory leaks we use the mtrace tool under Linux. The zfl_selftest.c program calls MALLOC_TRACE, which zfl_prelude.h sets to mtrace() under Linux. This is how we build and run the selftests with mtrace:
+
+ # Run selftests and check memory
+ gcc -g -o zfl_selftest zfl*.c -lzmq
+ export MALLOC_TRACE=mtrace.txt
+ zfl_selftest -v
+ mtrace zfl_selftest mtrace.txt
+
+Note that mtrace is not threadsafe and will not work consistently in multithreaded applications or test cases. All test cases should therefore be single-threaded.
+
+<A name="toc3-367" title="This Document" />
+### This Document
+
+This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown).
66 README.txt
@@ -0,0 +1,66 @@
+.set GIT=http://github.com/zeromq/zapi
+.sub 0MQ=ØMQ
+
+# zapi - 0MQ Function Library
+
+## Contents
+
+.toc
+
+## Overview
+
+### Scope and Goals
+
+zapi has these goals:
+
+* To wrap the 0MQ core API in semantics that are natural and lead to shorter, more readable applications.
+* To hide the differences between versions of 0MQ.
+* To provide a space for development of more sophisticated API semantics.
+
+### Ownership and License
+
+zapi is maintained by Pieter Hintjens and Mikko Koppanen (build system). Its other authors and contributors are listed in the AUTHORS file. It is held by the ZeroMQ organization at github.com.
+
+The authors of zapi grant you use of this software under the terms of the GNU Lesser General Public License (LGPL). For details see the files `COPYING` and `COPYING.LESSER` in this directory.
+
+### Contributing
+
+To submit an issue use the [issue tracker](http://github.com/zeromq/zapi/issues). All discussion happens on the [zeromq-dev](zeromq-dev@lists.zeromq.org) list or #zeromq IRC channel at irc.freenode.net.
+
+The proper way to submit patches is to clone this repository, make your changes, and use git to create a patch or a pull request. See http://www.zeromq.org/docs:contributing. All contributors are listed in AUTHORS.
+
+All classes are maintained by a single person, who is the responsible editor for that class and who is named in the header as such. This is usually the originator of the class. When several people collaborate on a class, one single person is always the lead maintainer and the one to blame when it breaks.
+
+The general rule is, if you contribute code to zapi you must be willing to maintain it as long as there are users of it. Code with no active maintainer will in general be deprecated and/or removed.
+
+## Using zapi
+
+### Building and Installing
+
+zapi uses autotools for packaging. To build from git (all example commands are for Linux):
+
+ git clone git://github.com/zeromq/zapi.git
+ cd zapi
+ sh autogen.sh
+ ./configure
+ make all
+ sudo make install
+ sudo ldconfig
+
+You will need the libtool and autotools packages. On FreeBSD, you may need to specify the default directories for configure:
+
+ ./configure --with-zeromq=/usr/local
+
+After building, you can run the zapi selftests:
+
+ make check
+
+### Linking with an Application
+
+Include `zapi.h` in your application and link with libzapi. Here is a typical gcc link command:
+
+ gcc -lzapi -lzmq myapp.c -o myapp
+
+### This Document
+
+This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown).
43 autogen.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright (c) 1991-2011 iMatix Corporation and contributors
+#
+# This file is part of ZFL, the 0MQ Function Library.
+#
+# This 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 software 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 <http://www.gnu.org/licenses/>.
+
+# Script to generate all required files from fresh git checkout.
+
+command -v libtool >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ echo "autogen.sh: error: could not find libtool. libtool is required to run autogen.sh." 1>&2
+ exit 1
+fi
+
+command -v autoreconf >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ echo "autogen.sh: error: could not find autoreconf. autoconf and automake are required to run autogen.sh." 1>&2
+ exit 1
+fi
+
+mkdir -p ./config
+if [ $? -ne 0 ]; then
+ echo "autogen.sh: error: could not create directory: ./config." 1>&2
+ exit 1
+fi
+
+autoreconf --install --force --verbose -I config
+if [ $? -ne 0 ]; then
+ echo "autogen.sh: error: autoreconf exited with status $?" 1>&2
+ exit 1
+fi
520 c
@@ -0,0 +1,520 @@
+#! /bin/sh
+#
+# c - C compile command
+#
+# Copyright (c) 1996-2009 iMatix Corporation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# For information on alternative licensing for OEMs, please contact
+# iMatix Corporation.
+#
+
+# Syntax: c filename... Compile ANSI C program(s)
+# c -c filename... (Backwards compatible: compile C programs)
+# c -l main... Compile and link main program(s)
+# c -L main... Link main program(s), no compile
+# c -S Report detected system name
+# c -C Report C compiler command syntax
+# c -r lib file... Replace object file(s) into library
+# -li path Local include path, additional to INCDIR
+# -ll path Local library path, additional to LIBDIR
+# -g Compile and link with debug information
+# -p Use C++ compiler instead of C
+# When linking, link with C++ runtime
+# When replacing, replace .opp file
+# -v Be verbose
+# -q Be quiet
+# -<xxxx> Arbitrary switch passed to compiler/linker
+#
+# Requires: Bourne shell
+# Usage: Compiles a subroutine or compiles/links a main program.
+#
+# The following variables can be set to control the program:
+# CCDEFINES Options required for ANSI C/C++ compilation
+# CCLIBS Options required for ANSI C/C++ linking
+# CCNAME Name of C compiler if not default
+# CCPLUS Name of C++ compiler if not default
+# CCCAT Command used to print listings (cat)
+# INCDIR Directory to search for include files
+# LIBDIR Directory to search for libraries
+#
+# When using iMatix Boom, if the IBASE environment variable is set and
+# conflicts with INCDIR or LIBDIR, c will issue a warning.
+#
+# To make compile/link errors less verbose, set CCCAT to "head".
+#
+# Note that these environment variables have different semantics to the
+# "standard" GNU variables such as CFLAGS which is why these are not
+# used in this script.
+#
+#----------------------------------------------------------------------------
+
+#
+# Utility functions for parsing BOOM_MODEL
+#
+
+# Returns a list of all BOOM_MODEL_$MODEL variables set
+boom_model_list () {
+ set |
+ awk 'BEGIN { FS="[=_]" }
+ /^BOOM_MODEL_[A-Z0-9]*=1$/ { print $3 }'
+}
+
+# Expands $BOOM_MODEL into individual BOOM_MODEL_$MODEL variables
+boom_model_expand () {
+ # Clear any existing settings
+ for MODEL in `boom_model_list`; do
+ eval unset BOOM_MODEL_$MODEL
+ done
+ # Iterate over BOOM_MODEL using ',' as FS
+ OLD_IFS=$IFS
+ IFS=,
+ for MODEL in $BOOM_MODEL; do
+ MODEL=`echo $MODEL | tr \[a-z\] \[A-Z\]`
+ eval BOOM_MODEL_$MODEL=1
+ eval export BOOM_MODEL_$MODEL
+ done
+ IFS=$OLD_IFS
+}
+
+# If not already known, detect UNIX system type.
+
+if [ -z "$UTYPE" ]; then
+ UTYPE=Generic # Default system name
+ if [ -s /usr/bin/uname ]; then UTYPE=`/usr/bin/uname`; fi
+ if [ -s /bin/uname ]; then UTYPE=`/bin/uname`; fi
+fi
+
+#
+# Set default values for BOOM_MODEL
+#
+# Default is release,mt on all platforms.
+#
+if [ -z "$BOOM_MODEL" ]; then
+ BOOM_MODEL=release,mt
+fi
+boom_model_expand
+if [ "$BOOM_MODEL_RELEASE" != "1" ]; then
+ if [ "$BOOM_MODEL_DEBUG" != "1" ]; then
+ BOOM_MODEL_RELEASE=1
+ BOOM_MODEL="$BOOM_MODEL,release"
+ fi
+fi
+if [ "$BOOM_MODEL_ST" != "1" ]; then
+ if [ "$BOOM_MODEL_MT" != "1" ]; then
+ BOOM_MODEL_MT=1
+ BOOM_MODEL="$BOOM_MODEL,mt"
+ fi
+fi
+
+# Set specific system compiler options and other flags
+# CCNAME Name of compiler
+# CCOPTS Compiler options, except -c
+# LINKTYPE One of (before, after, gnu)
+# RANLIB Use ranlib command to reindex library; else use 'ar rs'
+#
+# CCOPTS has no sensible default; so has to be either set by the
+# general configuration variables, or detected based on system type
+# and compiler. If CCOPTS is set, we assume the other values are
+# set or the defaults are correct.
+#
+# NOTE: CCNAME default is set below these checks, so that we can test
+# on CCNAME when setting CCOPTS, and/or set CCNAME and CCOPTS together.
+#
+CCCAT="${CCCAT:-cat}" # By default, "cat"
+RANLIB="${RANLIB:-0}" # By default, "ar rs" is used
+LINKTYPE="${LINKPATH:-after}" # By default, accept '-lsfl... -L.'
+
+#
+# First, check if GCC is present. If we can't find it and the
+# user hasn't specified an alternative, then exit.
+#
+if [ -z "$CCNAME" -a -z "$CCOPTS" ]; then
+ if type gcc >/dev/null 2>/dev/null; then
+ CCNAME="gcc"
+ CCPLUS="g++"
+ else
+ cat <<EOM 1>&2
+E: Could not find 'gcc' on PATH. 'c' requires gcc to build.
+E: For other alternatives that may be available on your platform
+E: please consult the 'c' script.
+EOM
+ exit 1
+ fi
+fi
+
+#
+# Generic modern GCC system
+#
+if [ "$CCNAME" = "gcc" ]; then
+ [ -z "$BOOM_MODEL_NOOPT" ] && CCDEBUG="-O2"
+ [ -z "$BOOM_MODEL_NOOPT" ] && CCNODEBUG="$CCNODEBUG -O2"
+ CCOPTS="-D_REENTRANT -D_GNU_SOURCE -Wall -Wno-unused -fno-strict-aliasing"
+ # We assume the following standard libraries are all present.
+ # If your build is failing because of missing libraries then
+ # either you are missing development packages, or are on a non-standard/old
+ # system and should add a special case.
+ STDLIBS="-lpthread -lm"
+
+ #
+ # Linux-specific subsection
+ #
+ if [ "$UTYPE" = "Linux" ]; then
+ # Use -start-group / -end-group for linking
+ STDLIBS="$STDLIBS -lrt -lcrypt"
+ LINKTYPE="gnu"
+ #
+ # Darwin-specific subsection
+ #
+ elif [ "$UTYPE" = "Darwin" ]; then
+ # Use -start-group / -end-group for linking
+ STDLIBS="$STDLIBS -lstdc++"
+ LINKTYPE="after"
+ #
+ # Solaris-specific subsection
+ #
+ elif [ "$UTYPE" = "SunOS" ]; then
+ # Extra system libraries needed to link on Solaris
+ STDLIBS="$STDLIBS -lrt -lcrypt -lsocket -lnsl -lsendfile"
+ # Standard "dumb" linker
+ LINKTYPE="before"
+ # For MT release builds, pick the best possible memory allocator
+ # out of the available options. mtmalloc is available in
+ # at least Solaris 8 and newer, umem is available in
+ # Solaris 9 update 3 and newer. If either is available,
+ # request iCL use direct memory allocator by default for
+ # MT release builds.
+ if [ "$BOOM_MODEL_MT" -a "$BOOM_MODEL_RELEASE" ]; then
+ if [ -f /usr/lib/libumem.so ]; then
+ STDLIBS="$STDLIBS -lumem"
+ elif [ -f /usr/lib/libmtmalloc.so ]; then
+ STDLIBS="$STDLIBS -lmtmalloc"
+ fi
+ fi
+ # Workaround for FOR-24
+ STDLIBS="-lapr $STDLIBS"
+ fi
+#
+# AIX with xlc
+#
+elif [ "$UTYPE" = "AIX" -a "$CCNAME" = "xlc_r" ]; then
+ [ -z "$BOOM_MODEL_NOOPT" ] && CCNODEBUG="-O"
+ CCNAME="xlc_r" # Use VAC Threaded Mode
+ CCPLUS="xlC_r" # Use VAC Threaded Mode
+ CCOPTS="$CCOPTS -D_REENTRANT"
+ STDLIBS="-lpthread"
+fi
+
+# Patch together the CC options and defines into one variable
+CCOPTS="$CCOPTS $CCDEFINES"
+if [ "$BOOM_MODEL_DEBUG" ]; then
+ CCOPTS="-g -DDEBUG $CCDEBUG $CCOPTS"
+else
+ CCOPTS="$CCNODEBUG $CCOPTS"
+fi
+
+# Select ST or MT build for iMatix Base2 framework
+if [ "$BOOM_MODEL_MT" ]; then
+ CCOPTS="$CCOPTS -DBASE_THREADSAFE"
+fi
+
+# Parse command line arguments, figure out what we are doing
+# (Parsing is currently fairly simplistic, and depends on ordering
+# of flags. Could be improved later if required.)
+LINKUP=no
+COMPILE=yes
+USECPP=no
+VERBOSE=${VERBOSE:-no}
+QUIET=${QUIET:-no} # Default is non-verbose messages
+LOCALLIBDIR=. # By default, search current directory twice
+
+if [ -n "$IBASE" ]; then
+ if [ -z "$INCDIR" ]; then
+ INCDIR=$IBASE/include
+ else
+ if [ "$INCDIR" != "$IBASE/include" ]; then
+ echo "W: INCDIR=$INCDIR is in conflict with IBASE=$IBASE" 1>&2
+ fi
+ fi
+ if [ -z "$LIBDIR" ]; then
+ LIBDIR=$IBASE/lib
+ else
+ if [ "$LIBDIR" != "$IBASE/lib" ]; then
+ echo "W: LIBDIR=$LIBDIR is in conflict with IBASE=$IBASE" 1>&2
+ fi
+ fi
+else
+ if [ -z "$INCDIR" ]; then
+ INCDIR=.
+ fi
+ if [ -z "$LIBDIR" ]; then
+ LIBDIR=.
+ fi
+fi
+
+# Process switches in no particular order until there are none left
+while true; do
+ # -v means verbose reports
+ if [ /$1/ = /-v/ ]; then
+ VERBOSE=yes
+ shift
+
+ # -q means quiet
+ elif [ /$1/ = /-q/ ]; then
+ QUIET=yes
+ shift
+
+ # -g means compile/link with debugging symbols
+ elif [ /$1/ = /-g/ ]; then
+ BOOM_MODEL_DEBUG=1
+ unset BOOM_MODEL_RELEASE
+ shift
+
+ # -p means use C++ compiler
+ elif [ /$1/ = /-p/ ]; then
+ USECPP=yes
+ shift
+
+ # -S means report detected system type
+ elif [ /$1/ = /-S/ ]; then
+ echo "$UTYPE"
+ exit
+
+ # -C means report compiler syntax type
+ elif [ /$1/ = /-C/ ]; then
+ echo "$CCNAME -c -I$INCDIR $CCOPTS"
+ exit
+
+ # -c means compile the object -- we were going to do that anyway,
+ # but this ensures backwards compatibility
+ elif [ /$1/ = /-c/ ]; then
+ shift
+
+ # -r means replace object file into library
+ # The RANLIB symbol should be set to 1 if 'ar rs' does not work.
+ elif [ /$1/ = /-r/ ]; then
+ LIBRARY=$2
+ LIBNAME=`echo $LIBRARY | cut -d"." -f1`
+ shift; shift
+
+ for i in $*; do
+ shift
+ OBJECT=`echo $i | cut -d"." -f1`
+ if [ "$USECPP" = "no" ]; then
+ OBJECT=$OBJECT.o
+ else
+ OBJECT=$OBJECT.opp
+ fi
+
+ TRACE="Replacing object $OBJECT in library $LIBRARY"
+ if [ -f $LIBNAME.a ]; then
+ AR_CREATE_OPT=""
+ else
+ AR_CREATE_OPT="c"
+ fi
+ if [ "$RANLIB" = "1" ]; then
+ COMMAND="ar ${AR_CREATE_OPT}r $LIBNAME.a $OBJECT"
+ else
+ COMMAND="ar ${AR_CREATE_OPT}rs $LIBNAME.a $OBJECT"
+ fi
+ if [ "$QUIET" = "no" ]; then
+ if [ "$VERBOSE" = "no" ]; then
+ echo "$TRACE..."
+ else
+ echo "$TRACE ($COMMAND)..."
+ fi
+ fi
+ if [ ! -z "$CCTRACE" ]; then
+ echo "$TRACE ($COMMAND)">>$CCTRACE
+ fi
+ $COMMAND
+
+ # Run ranlib if necessary
+ if [ "$RANLIB" = "1" ]; then
+ ranlib $LIBNAME.a
+ fi
+ done
+ exit
+
+ # Compile/link main if -l is first argument
+ elif [ /$1/ = /-l/ ]; then
+ LINKUP=yes
+ shift
+
+ # Link main if -L is first argument (assumed to already be compiled)
+ elif [ /$1/ = /-L/ ]; then
+ LINKUP=yes
+ COMPILE=no
+ shift
+
+ # -li means use local include path as well as INCDIR
+ elif [ /$1/ = /-li/ ]; then
+ CCOPTS="-I$2 $CCOPTS"
+ shift; shift
+
+ # -ll means use local library path as well as LIBDIR
+ elif [ /$1/ = /-ll/ ]; then
+ LOCALLIBDIR=$2
+ shift; shift
+
+ elif [ /`echo $1 | cut -c1`/ = /-/ ]; then
+ EXTRA="$EXTRA $1"
+ shift
+
+ else
+ break # Not a switch
+ fi
+done
+
+# If we will be linking, then build list of libraries to link with.
+
+if [ "$LINKUP" = "yes" -o /$1/ = // ]; then
+ LIBLIST=""
+ for LIBRARY in lib*.a $LOCALLIBDIR/lib*.a $LIBDIR/lib*.a; do
+ if [ ! -f $LIBRARY ]; then
+ continue
+ fi
+ # Pull out the xxx from libxxx.a (or similar)
+ LIBNAME=`basename $LIBRARY | sed -e 's/^...\([^\.]*\)\..*$/\1/'`
+ LIBLIST="$LIBLIST -l$LIBNAME"
+ done
+ LIBLIST="$LIBLIST $STDLIBS $CCLIBS"
+fi
+
+CCOPTS="$EXTRA $CCOPTS"
+# Show help if no arguments
+if [ /$1/ = // ]; then
+ echo "Detected system=$UTYPE, compiles with:"
+ echo " $CCNAME -c -I$INCDIR $CCOPTS"
+ echo "Syntax: c filename... Compile ANSI C program(s)"
+ echo " c -c filename... Compile ANSI C programs(s)"
+ echo " c -l main... Compile and link main program(s)"
+ echo " c -L main... Link main(s) with" ${LIBLIST-"no libraries"}
+ echo " c -S Report detected system name"
+ echo " c -C Report C compiler command syntax"
+ echo " c -r lib file Replace file into specified library"
+ echo " -li path Local include path, additional to INCDIR"
+ echo " -ll path Local library path, additional to LIBDIR"
+ echo " -g Compile and link with debug information"
+ echo " -p Use C++ compiler instead of C"
+ echo " When linking, link with C++ runtime"
+ echo " When replacing, replace .opp file"
+ echo " -v Be verbose"
+ echo " -q Be quiet"
+ echo " -<xxxx> Arbitrary switch passed to compiler/linker"
+ exit
+fi
+
+# Compile and maybe link each filename on the command line
+for i in $*; do
+ if [ "$i" = "-o" ]; then
+ exit 0 # Skip -o filename
+ fi
+ FILENAME=`echo $i | cut -d"." -f1`
+
+ # Compile, if required
+ if [ "$USECPP" = "no" ]; then
+ OBJEXT=o
+ else
+ OBJEXT=opp
+ fi
+ if [ "$COMPILE" = "yes" -o ! -f $FILENAME.$OBJEXT ]; then
+ if [ -f $FILENAME.$OBJEXT ]; then
+ rm $FILENAME.$OBJEXT
+ fi
+
+ TRACE="Compiling $FILENAME"
+ if [ "$USECPP" = "no" ]; then
+ COMMAND="$CCNAME -c $CCOPTS -I$INCDIR $FILENAME.c"
+ else
+ COMMAND="$CCPLUS -c $CCOPTS -I$INCDIR -o $FILENAME.opp $FILENAME.cpp"
+ fi
+ if [ "$QUIET" = "no" ]; then
+ if [ "$VERBOSE" = "no" ]; then
+ echo "$TRACE..."
+ else
+ echo "$TRACE ($COMMAND)..."
+ fi
+ fi
+ if [ ! -z "$CCTRACE" ]; then
+ echo "$TRACE ($COMMAND)">>$CCTRACE
+ fi
+
+ # Need to remove any quotes in command string to pass as macro
+ SYNTAX=`echo $COMMAND | sed -e "s/\"//g"`
+ $COMMAND -DCCOPTS="\"$SYNTAX\"" >$FILENAME.lst 2>&1
+
+ # Show listing and abort if there was a compile error
+ if [ $? -eq 0 ]; then
+ cat $FILENAME.lst
+ rm $FILENAME.lst
+ else
+ # Only show start of listing if there was an error
+ $CCCAT $FILENAME.lst
+ if [ ! -z "$CCTRACE" ]; then
+ cat $FILENAME.lst >>$CCTRACE
+ fi
+ exit 1
+ fi
+ fi
+
+ # If okay, link if required
+ if [ "$LINKUP" = "yes" ]; then
+ TRACE="Linking $FILENAME"
+ if [ "$USECPP" = "no" ]; then
+ COMMAND="$CCNAME $CCOPTS $FILENAME.o -o $FILENAME"
+ else
+ COMMAND="$CCPLUS $CCOPTS $FILENAME.opp -o $FILENAME"
+ fi
+ case "$LINKTYPE" in
+ gnu)
+ COMMAND="$COMMAND -Wl,--start-group $LIBLIST -Wl,--end-group -L. -L$LOCALLIBDIR -L$LIBDIR $STDLIBS"
+ ;;
+ before)
+ COMMAND="$COMMAND -L. -L$LOCALLIBDIR -L$LIBDIR $LIBLIST $LIBLIST $STDLIBS"
+ ;;
+ after)
+ COMMAND="$COMMAND $LIBLIST $LIBLIST -L. -L$LOCALLIBDIR -L$LIBDIR $STDLIBS"
+ ;;
+ esac
+
+ if [ "$QUIET" = "no" ]; then
+ if [ "$VERBOSE" = "no" ]; then
+ echo "$TRACE..."
+ else
+ echo "$TRACE ($COMMAND)..."
+ fi
+ fi
+ if [ ! -z "$CCTRACE" ]; then
+ echo "$TRACE ($COMMAND)">>$CCTRACE
+ fi
+
+ $COMMAND 2> $FILENAME.lst
+
+ # Show listing and abort if there was a link error
+ if [ $? -eq 0 ]; then
+ cat $FILENAME.lst
+ rm $FILENAME.lst
+ else
+ if [ "$VERBOSE" = "yes" ]; then
+ cat $FILENAME.lst
+ else
+ # Show first page of link errors only
+ head $FILENAME.lst
+ fi
+ if [ ! -z "$CCTRACE" ]; then
+ cat $FILENAME.lst >>$CCTRACE
+ fi
+ exit 1
+ fi
+ fi
+done
214 configure.in
@@ -0,0 +1,214 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.61)
+#
+# Change the version number below after doing a public release.
+# The version in git should reflect the *next* version planned.
+# Version must be MAJOR.MINOR.PATCH otherwise things will break.
+#
+AC_INIT([zapi],[1.0.0],[zeromq-dev@lists.zeromq.org])
+
+AC_CONFIG_AUX_DIR(config)
+AC_CONFIG_MACRO_DIR(config)
+AM_CONFIG_HEADER(src/platform.h)
+AM_INIT_AUTOMAKE(tar-ustar)
+
+# This defines PACKAGE_VERSION_... in src/platform.h
+PV_MAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
+PV_MINOR=`echo $PACKAGE_VERSION | cut -d . -f 2`
+PV_PATCH=`echo $PACKAGE_VERSION | cut -d . -f 3`
+AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],[$PV_MAJOR],
+ [ZAPI major version])
+AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],[$PV_MINOR],
+ [ZAPI minor version])
+AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCH],[$PV_PATCH],
+ [ZAPI patchlevel])
+# This lets us use PACKAGE_VERSION in Makefiles
+AC_SUBST(PACKAGE_VERSION)
+
+#
+# Libtool -version-info (ABI version)
+#
+# Currently 0.0.0 ("unstable"). Don't change this unless you
+# know exactly what you're doing and have read and understand
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+#
+# libzapi -version-info
+LTVER="0:0:0"
+AC_SUBST(LTVER)
+
+# Capture c flags
+ZAPI_ORIG_CFLAGS="${CFLAGS:-none}"
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_CC_C99
+AM_PROG_CC_C_O
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
+AC_PROG_SED
+AC_PROG_AWK
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_create])
+
+AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no],
+ [With GCC Code Coverage reporting.])],
+ [ZAPI_GCOV="$withval"])
+
+if test "x${ZAPI_GCOV}" == "xyes"; then
+ CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+
+ if test "x${ZAPI_ORIG_CFLAGS}" != "xnone"; then
+ CFLAGS="${CFLAGS} ${ZAPI_ORIG_CFLAGS}"
+ fi
+fi
+
+# zmq location
+AC_ARG_WITH([zeromq],
+ [AS_HELP_STRING([--with-zeromq],
+ [Specify ZeroMQ prefix])],
+ [zapi_search_zeromq="yes"],
+ [])
+
+if test "x$zapi_search_zeromq" = "xyes"; then
+ if test -r "${with_zeromq}/include/zmq.h"; then
+ CFLAGS="-I${with_zeromq}/include ${CFLAGS}"
+ LDFLAGS="-L${with_zeromq}/lib ${LDFLAGS}"
+ else
+ AC_MSG_ERROR([${with_zeromq}/include/zmq.h not found. Please check ZeroMQ prefix])
+ fi
+fi
+
+AC_CHECK_LIB(zmq, zmq_init, ,[AC_MSG_ERROR([cannot link with -lzmq, install ZeroMQ.])])
+
+AC_MSG_CHECKING([whether ZeroMQ installation works])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <zmq.h>],
+ [zmq_init(1);])
+ ],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_ERROR([no. Please specify ZeroMQ installation prefix using --with-zeromq])])
+
+#Whether we are on mingw or not.
+zapi_on_mingw32="no"
+
+# Host speciffic checks
+AC_CANONICAL_HOST
+
+# Determine whether or not documentation should be built and installed.
+zapi_build_doc="yes"
+zapi_install_man="yes"
+
+# Check for asciidoc and xmlto and don't build the docs if these are not installed.
+AC_CHECK_PROG(zapi_have_asciidoc, asciidoc, yes, no)
+AC_CHECK_PROG(zapi_have_xmlto, xmlto, yes, no)
+if test "x$zapi_have_asciidoc" = "xno" -o "x$zapi_have_xmlto" = "xno"; then
+ zapi_build_doc="no"
+ # Tarballs built with 'make dist' ship with prebuilt documentation.
+ if ! test -f doc/zapi.7; then
+ zapi_install_man="no"
+ AC_MSG_WARN([You are building an unreleased version of ZAPI and asciidoc or xmlto are not installed.])
+ AC_MSG_WARN([Documentation will not be built and manual pages will not be installed.])
+ fi
+fi
+AC_MSG_CHECKING([whether to build documentation])
+AC_MSG_RESULT([$zapi_build_doc])
+AC_MSG_CHECKING([whether to install manpages])
+AC_MSG_RESULT([$zapi_install_man])
+
+# Set some default features required by ZAPI code.
+CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS"
+
+# OS-specific tests
+case "${host_os}" in
+ *linux*)
+ # Define on Linux to enable all library features
+ CPPFLAGS="-D_GNU_SOURCE -DLINUX $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_LINUX, 1, [Have Linux OS])
+ ;;
+ *solaris*)
+ # Define on Solaris to enable all library features
+ CPPFLAGS="-D_PTHREADS $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_SOLARIS, 1, [Have Solaris OS])
+ ;;
+ *freebsd*)
+ # Define on FreeBSD to enable all library features
+ CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_FREEBSD, 1, [Have FreeBSD OS])
+ ;;
+ *darwin*)
+ # Define on Darwin to enable all library features
+ CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_OSX, 1, [Have DarwinOSX OS])
+ ;;
+ *netbsd*)
+ # Define on NetBSD to enable all library features
+ CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_NETBSD, 1, [Have NetBSD OS])
+ ;;
+ *openbsd*)
+ # Define on OpenBSD to enable all library features
+ CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_OPENBSD, 1, [Have OpenBSD OS])
+ ;;
+ *nto-qnx*)
+ AC_DEFINE(ZAPI_HAVE_QNXNTO, 1, [Have QNX Neutrino OS])
+ ;;
+ *aix*)
+ AC_DEFINE(ZAPI_HAVE_AIX, 1, [Have AIX OS])
+ ;;
+ *hpux*)
+ # Define on HP-UX to enable all library features
+ CPPFLAGS="-D_POSIX_C_SOURCE=200112L"
+ AC_DEFINE(ZAPI_HAVE_HPUX, 1, [Have HPUX OS])
+ ;;
+ *mingw32*)
+ AC_DEFINE(ZAPI_HAVE_WINDOWS, 1, [Have Windows OS])
+ AC_DEFINE(ZAPI_HAVE_MINGW32, 1, [Have MinGW32])
+ AC_CHECK_HEADERS(windows.h)
+ zapi_on_mingw32="yes"
+ zapi_install_man="no"
+ ;;
+ *cygwin*)
+ # Define on Cygwin to enable all library features
+ CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
+ AC_DEFINE(ZAPI_HAVE_CYGWIN, 1, [Have Cygwin])
+ ;;
+ *)
+ AC_MSG_ERROR([unsupported system: ${host_os}.])
+ ;;
+esac
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \
+stdlib.h string.h sys/socket.h sys/time.h unistd.h limits.h)
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_HEADER_TIME
+AC_TYPE_UINT32_T
+AC_C_VOLATILE
+
+# Math libraries
+AC_CHECK_LIB([m], [pow])
+
+# These options are GNU compiler specific.
+if test "x$GCC" = "xyes"; then
+ CPPFLAGS="-pedantic -Werror -Wall -Wno-unused ${CPPFLAGS}"
+fi
+
+AM_CONDITIONAL(ON_MINGW, test "x$zapi_on_mingw32" = "xyes")
+AM_CONDITIONAL(INSTALL_MAN, test "x$zapi_install_man" = "xyes")
+AM_CONDITIONAL(BUILD_DOC, test "x$zapi_build_doc" = "xyes")
+
+# Checks for library functions.
+AC_TYPE_SIGNAL
+AC_CHECK_FUNCS(perror gettimeofday memset)
+
+AC_OUTPUT(Makefile src/Makefile doc/Makefile src/libzapi.pc examples/Makefile)
+
37 doc/Makefile.am
@@ -0,0 +1,37 @@
+MAN1 =
+MAN3 =
+MAN7 = zapi.7 \
+ zctx.7 \
+ zframe.7 \
+ zloop.7 \
+ zmsg.7 \
+ zstr.7
+MAN_DOC = $(MAN1) $(MAN3) $(MAN7)
+
+MAN_TXT = $(MAN1:%.1=%.txt)
+MAN_TXT += $(MAN3:%.3=%.txt)
+MAN_TXT += $(MAN7:%.7=%.txt)
+
+if INSTALL_MAN
+dist_man_MANS = $(MAN_DOC)
+endif
+
+EXTRA_DIST = asciidoc.conf $(MAN_TXT)
+
+MAINTAINERCLEANFILES = $(MAN_DOC)
+
+dist-hook : $(MAN_DOC)
+
+if BUILD_DOC
+SUFFIXES=.txt .xml .1 .3 .7
+
+.txt.xml:
+ asciidoc -d manpage -b docbook -f asciidoc.conf \
+ -azapi_version=@PACKAGE_VERSION@ $<
+.xml.1:
+ xmlto man $<
+.xml.3:
+ xmlto man $<
+.xml.7:
+ xmlto man $<
+endif
57 doc/asciidoc.conf
@@ -0,0 +1,57 @@
+[paradef-default]
+literal-style=template="literalparagraph"
+
+[macros]
+(?su)[\\]?(?P<name>linkzfl):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
+
+ifdef::backend-docbook[]
+[linkzfl-inlinemacro]
+{0%{target}}
+{0#<citerefentry>}
+{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
+{0#</citerefentry>}
+endif::backend-docbook[]
+
+ifdef::backend-xhtml11[]
+[linkzfl-inlinemacro]
+<a href="{target}.html">{target}{0?({0})}</a>
+endif::backend-xhtml11[]
+
+ifdef::doctype-manpage[]
+ifdef::backend-docbook[]
+[header]
+template::[header-declarations]
+<refentry>
+<refmeta>
+<refentrytitle>{mantitle}</refentrytitle>
+<manvolnum>{manvolnum}</manvolnum>
+<refmiscinfo class="source">ZFL</refmiscinfo>
+<refmiscinfo class="version">{zfl_version}</refmiscinfo>
+<refmiscinfo class="manual">ZFL Manual</refmiscinfo>
+</refmeta>
+<refnamediv>
+ <refname>{manname}</refname>
+ <refpurpose>{manpurpose}</refpurpose>
+</refnamediv>
+[footer]
+<refsect1 id="_authors">
+<title>AUTHORS</title>
+<simpara>The ZFL reference manual was written by Pieter Hintjens&lt;<ulink url="mailto:ph@imatix.com">ph@imatix.com</ulink>&gt;.</simpara>
+</refsect1>
+<refsect1 id="_resources">
+<title>RESOURCES</title>
+<simpara>Main web site: <ulink url="http://zfl.zeromq.org/">http://zfl.zeromq.org/</ulink></simpara>
+<simpara>Report bugs to the 0MQ development mailing list: &lt;<ulink url="mailto:zeromq-dev@lists.zeromq.org">zeromq-dev@lists.zeromq.org</ulink>&gt;</simpara>
+</refsect1>
+<refsect1 id="_copyright">
+<title>COPYRIGHT</title>
+<simpara>Copyright (c) 1991-2010 iMatix Corporation and contributors. License LGPLv3+: GNU LGPL 3 or later &lt;<ulink url="http://gnu.org/licenses/lgpl.html">http://gnu.org/licenses/lgpl.html</ulink>&gt;. This is free software: you are free to change it and redistribute it. There is NO WARRANTY, to the extent permitted by law. For details see the files <literal>COPYING</literal> and <literal>COPYING.LESSER</literal> included with the ZFL distribution.</simpara>
+</refsect1>
+</refentry>
+endif::backend-docbook[]
+endif::doctype-manpage[]
+
+[replacements]
+ifdef::backend-xhtml11[]
+0MQ=ØMQ
+endif::backend-xhtml11[]
109 doc/zapi.txt
@@ -0,0 +1,109 @@
+zapi(7)
+=======
+
+
+NAME
+----
+zapi - 0MQ C Binding
+
+
+SYNOPSIS
+--------
+*#include <zapi.h>*
+
+*cc* ['flags'] 'files' *-lzmq* *-lzapi* ['libraries']
+
+
+DESCRIPTION
+-----------
+
+Scope and Goals
+~~~~~~~~~~~~~~~
+
+zapi has these goals:
+
+* To wrap the 0MQ core API in semantics that are natural and lead to shorter, more readable applications.
+* To hide the differences between versions of 0MQ.
+* To provide a space for development of more sophisticated API semantics.
+
+Ownership and License
+~~~~~~~~~~~~~~~~~~~~~
+
+zapi is maintained by Pieter Hintjens. Its other authors and contributors are listed in the AUTHORS file. It is held by the ZeroMQ organization at github.com.
+
+The authors of zapi grant you free use of this software under the terms of the GNU Lesser General Public License (LGPL). For details see the files `COPYING` and `COPYING.LESSER` in this directory.
+
+Contributing
+~~~~~~~~~~~~
+
+To submit an issue use the [issue tracker](http://github.com/zeromq/zapi/issues). All discussion happens on the [zeromq-dev](zeromq-dev@lists.zeromq.org) list or #zeromq IRC channel at irc.freenode.net.
+
+The proper way to submit patches is to clone this repository, make your changes, and use git to create a patch or a pull request. See http://www.zeromq.org/docs:contributing. All contributors are listed in AUTHORS.
+
+All classes are maintained by a single person, who is the responsible editor for that class and who is named in the header as such. This is usually the originator of the class. When several people collaborate on a class, one single person is always the lead maintainer and the one to blame when it breaks.
+
+The general rule is, if you contribute code to zapi you must be willing to maintain it as long as there are users of it. Code with no active maintainer will in general be deprecated and/or removed.
+
+USING ZAPI
+----------
+
+Building and Installing
+~~~~~~~~~~~~~~~~~~~~~~~
+
+zapi uses autotools for packaging. To build from git (all example commands are for Linux):
+----
+git clone git://github.com/zeromq/zapi.git
+cd zapi
+sh autogen.sh
+./configure
+make all
+sudo make install
+sudo ldconfig
+----
+You will need the pkg-config, libtool, and autoreconf packages. Set the LD_LIBRARY_PATH to /usr/local/libs unless you install elsewhere.
+
+After building, you can run the zapi selftests:
+----
+cd src
+./zapi_selftest
+----
+
+Linking with an Application
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Include `zapi.h` in your application and link with libzapi. Here is a typical gcc link command:
+----
+gcc -lzapi -lzmq myapp.c -o myapp
+----
+You should read `zapi.h`. This file includes `zmq.h` and the system header files that typical 0MQ applications will need. The provided 'c' shell script lets you write simple portable build scripts:
+----
+c -lzapi -lzmq -l myapp
+----
+
+The Class Model
+~~~~~~~~~~~~~~~
+
+zapi consists of classes, each class consisting of a .h and a .c. Classes may depend on other classes.
+
+`zapi.h` includes all classes header files, all the time. For the user, zapi forms one single package. All classes start by including `zapi.h`. All applications that use zapi start by including `zapi.h`. `zapi.h` also defines a limited number of small, useful macros and typedefs that have proven useful for writing clearer C code.
+
+All classes (with some exceptions) are based on a flat C class system and follow these rules (where 'zclass' is the class name):
+
+* Class typedef: `zclass_t`
+* Constructor: `zclass_new`
+* Destructor: `zclass_destroy`
+* Property methods: `zclass_property_set`, `zclass_property`
+* Class structures are private (defined in the .c source but not the .h)
+* Properties are accessed only via methods named as described above.
+* In the class source code the object is always called `self`.
+* The constructor may take arbitrary arguments, and returns NULL on failure, or a new object.
+* The destructor takes a pointer to an object reference and nullifies it.
+
+Return values for methods are:
+
+* For methods that return an object reference, either the reference, or NULL on failure.
+* For methods that signal success/failure, a return value of 0 means sucess, -1 failure.
+
+Private/static functions in a class are named `s_functionname` and are not exported via the header file.
+
+All classes (with some exceptions) have a test method called `zclass_test`.
48 doc/zctx.txt
@@ -0,0 +1,48 @@
+zctx(7)
+=======
+
+NAME
+----
+zctx - working with 0MQ contexts
+
+SYNOPSIS
+--------
+----
+zctx_t *
+ zctx = zctx_new (void);
+void
+ zctx_destroy (zctx_t **self_p);
+void
+ zctx_set_iothreads (zctx_t *self, int threads);
+void
+ zctx_set_linger (zctx_t *self, int msecs);
+void *
+ zctx_context (zctx_t *self);
+void *
+ zctx_socket_new (zctx_t *self, int type);
+void
+ zctx_socket_destroy (zctx_t *self, void **socket);
+int
+ zctx_test (int verbose);
+----
+
+DESCRIPTION
+-----------
+The zctx class wraps 0MQ contexts. It manages open sockets in the context
+and automatically closes these before terminating the context. It provides
+a simple way to set the linger timeout on sockets, and configure contexts
+for number of I/O threads. Sets-up signal (interrrupt) handling for the
+process.
+
+
+EXAMPLE
+-------
+.From zctx_test method
+----
+----
+
+
+SEE ALSO
+--------
+linkzapi:zapi[7]
+
49 doc/zframe.txt
@@ -0,0 +1,49 @@
+zframe(7)
+=========
+
+NAME
+----
+zframe - working with single message frames
+
+SYNOPSIS
+--------
+----
+#define ZFRAME_MORE 1
+#define ZFRAME_REUSE 2
+#define ZFRAME_NOWAIT 4
+
+zframe_t *
+ zframe_new (const void *data, size_t size);
+void
+ zframe_destroy (zframe_t **self_p);
+zframe_t *
+ zframe_recv (void *socket, int flags);
+void
+ zframe_send (zframe_t **self_p, void *socket, int flags);
+size_t
+ zframe_size (zframe_t *self);
+void *
+ zframe_data (zframe_t *self);
+int
+ zframe_more (zframe_t *self);
+int
+ zframe_test (int verbose);
+----
+
+DESCRIPTION
+-----------
+The zframe class provides methods to send and receive single message
+frames across 0MQ sockets.
+
+
+EXAMPLE
+-------
+.From zframe_test method
+----
+----
+
+
+SEE ALSO
+--------
+linkzapi:zapi[7]
+
51 doc/zloop.txt
@@ -0,0 +1,51 @@
+zloop(7)
+========
+
+NAME
+----
+zloop - event-driven reactor
+
+SYNOPSIS
+--------
+----
+typedef int (zloop_fn) (void *socket, int flags, void *argument);
+
+#define ZEVENTS_IN 1
+#define ZEVENTS_OUT 2
+#define ZEVENTS_ALARM 4
+
+zloop_t *
+ zloop_new (void);
+void
+ zloop_destroy (zloop_t **self_p);
+int
+ zloop_register (zloop_t *self, void *socket, int flags,
+ zloop_fn handler, void *argument);
+int
+ zloop_alarm (zloop_t *self, size_t alarm_msecs,
+ zloop_fn handler, void *argument);
+int
+ zloop_clock (zloop_t *self, size_t clock_msecs,
+ zloop_fn handler, void *argument);
+int
+ zloop_start (zloop_t *self);
+int
+ zloop_test (int verbose);
+----
+
+DESCRIPTION
+-----------
+The zloop class provides an event-driven reactor pattern.
+
+
+EXAMPLE
+-------
+.From zloop_test method
+----
+----
+
+
+SEE ALSO
+--------
+linkzapi:zapi[7]
+
59 doc/zmsg.txt
@@ -0,0 +1,59 @@
+zmsg(7)
+=======
+
+NAME
+----
+zmsg - working with multipart messages
+
+SYNOPSIS
+--------
+----
+zmsg_t *
+ zmsg_new (const void *data, size_t size);
+void
+ zmsg_destroy (zmsg_t **self_p);
+zmsg_t *
+ zmsg_recv (void *socket);
+void
+ zmsg_send (zmsg_t **self, void *socket);
+size_t
+ zmsg_size (zmsg_t *self);
+void
+ zmsg_push (zmsg_t *self, const zframe_t *frame);
+void
+ zmsg_queue (zmsg_t *self, const zframe_t *frame);
+void
+ zmsg_pushmem (zmsg_t *self, const void *src, size_t size);
+void
+ zmsg_queuemem (zmsg_t *self, const void *src, size_t size);
+zframe_t *
+ zmsg_pop (zmsg_t *self);
+zframe_t *
+ zmsg_remove (zmsg_t *self);
+zmsg_t *
+ zmsg_load (FILE *file);
+void
+ zmsg_save (zmsg_t **self_p, FILE *file);
+void
+ zmsg_dump (zmsg_t *self);
+int
+ zmsg_test (int verbose);
+----
+
+DESCRIPTION
+-----------
+The zmsg class provides methods to send and receive multipart messages
+across 0MQ sockets.
+
+
+EXAMPLE
+-------
+.From zmsg_test method
+----
+----
+
+
+SEE ALSO
+--------
+linkzapi:zapi[7]
+
35 doc/zstr.txt
@@ -0,0 +1,35 @@
+zstr(7)
+=======
+
+NAME
+----
+zstr - sending and receiving strings
+
+SYNOPSIS
+--------
+----
+char *
+ zstr_recv (void *socket);
+int
+ zstr_send (void *socket, const char *string);
+int
+ zstr_sendf (void *socket, const char format, ...);
+----
+
+DESCRIPTION
+-----------
+The zstr class provides utility functions for sending and receiving
+C strings across 0MQ sockets.
+
+
+EXAMPLE
+-------
+.From zstr_test method
+----
+----
+
+
+SEE ALSO
+--------
+linkzapi:zapi[7]
+
44 include/zapi.h
@@ -0,0 +1,44 @@
+/* =========================================================================
+ zapi.h - zapi wrapper
+
+ -------------------------------------------------------------------------
+ Copyright (c) 1991-2011 iMatix Corporation <www.imatix.com>
+ Copyright other contributors as noted in the AUTHORS file.
+
+ This file is part of zapi, the C binding for 0MQ: http://zapi.zeromq.org.
+
+ This is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your option)
+ any later version.
+
+ This software is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABIL-
+ ITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ =========================================================================
+*/
+
+#ifndef __ZAPI_H_INCLUDED__
+#define __ZAPI_H_INCLUDED__
+
+// Always include ZeroMQ header file
+//
+#include <zmq.h>
+
+// Set up environment for the application
+//
+#include <zfl_prelude.h>
+
+// Classes listed in alphabetical order
+
+#include <zctx.h>
+#include <zframe.h>
+#include <zloop.h>
+#include <zmsg.h>
+#include <zstr.h>
+
+#endif
120 include/zapi_prelude.h
@@ -0,0 +1,120 @@
+/* =========================================================================
+ zapi_prelude.h - zapi environment
+