czmq-3.0.2/0000775000175000017500000000000012535242314011571 5ustar00phph00000000000000czmq-3.0.2/LICENSE0000664000175000017500000004052512417311766012613 0ustar00phph00000000000000Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. czmq-3.0.2/config/0000775000175000017500000000000012535242314013036 5ustar00phph00000000000000czmq-3.0.2/config/libtool.m40000644000175000017500000106043412535241436014756 0ustar00phph00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS czmq-3.0.2/config/ltoptions.m40000644000175000017500000003007312535241436015340 0ustar00phph00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) czmq-3.0.2/config/missing0000755000175000017500000002415212535241442014440 0ustar00phph00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # 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, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-3.0.2/config/compile0000755000175000017500000001533712535241442014424 0ustar00phph00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-01-04.17; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free # Software Foundation, Inc. # Written by Tom Tromey . # # 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, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l*) lib=${1#-l} found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes set x "$@" "$dir/$lib.dll.lib" break fi if test -f "$dir/$lib.lib"; then found=yes set x "$@" "$dir/$lib.lib" break fi done IFS=$save_IFS test "$found" != yes && set x "$@" "$lib.lib" shift ;; -L*) func_file_conv "${1#-L}" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-3.0.2/config/lt~obsolete.m40000644000175000017500000001375612535241436015670 0ustar00phph00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) czmq-3.0.2/config/ltsugar.m40000644000175000017500000001042412535241436014764 0ustar00phph00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) czmq-3.0.2/config/config.guess0000755000175000017500000012743212535241442015366 0ustar00phph00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: czmq-3.0.2/config/install-sh0000755000175000017500000003325612535241442015052 0ustar00phph00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-3.0.2/config/ltmain.sh0000644000175000017500000105204012535241436014662 0ustar00phph00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1ubuntu1" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 czmq-3.0.2/config/config.sub0000755000175000017500000010517612535241442015032 0ustar00phph00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: czmq-3.0.2/config/ltversion.m40000644000175000017500000000126212535241436015330 0ustar00phph00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) czmq-3.0.2/config/depcomp0000755000175000017500000004755612535241442014433 0ustar00phph00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 Free Software Foundation, Inc. # 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, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-3.0.2/README.md0000664000175000017500000115333312506455175013072 0ustar00phph00000000000000 # CZMQ - High-level C binding for ØMQ [![Build Status](https://travis-ci.org/zeromq/czmq.png?branch=master)](https://travis-ci.org/zeromq/czmq) ## Contents **Overview** **Scope and Goals** **Ownership and License** **Using CZMQ** **Building and Installing** **Linking with an Application** **Use from Other Languages** **API v3 Summary**  zactor - simple actor frameworkzauth - authentication for ZeroMQ security mechanismszbeacon - LAN discovery and presencezcert - work with CURVE security certificateszcertstore - work with CURVE security certificate storeszchunk - work with memory chunkszclock - millisecond clocks and delayszconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL.zdigest - provides hashing functions (SHA-1 at present)zdir - work with file-system directorieszdir_patch - work with directory patcheszfile - provides methods to work with files in a portable fashion.zframe - working with single message frameszgossip - decentralized configuration managementzhash - simple generic hash containerziflist - List of network interfaces available on systemzlist - simple generic list containerzloop - event-driven reactorzmonitor - socket event monitorzmsg - working with multipart messageszpoller - trivial socket poller classzproxy - run a steerable proxy in the backgroundzrex - work with regular expressionszsock - high-level socket API that hides libzmq contexts and socketszsock_option - get/set ØMQ socket optionszstr - sending and receiving stringszsys - system-level methodszuuid - UUID support class **API v2 Summary**  zauth_v2 - authentication for ZeroMQ servers (deprecated)zctx - working with ØMQ contexts (deprecated)zmonitor_v2 - socket event monitor (deprecated)zmutex - working with mutexes (deprecated)zproxy_v2 - run a steerable proxy in the background (deprecated)zsocket - working with ØMQ sockets (deprecated)zsockopt - get/set ØMQ socket options (deprecated)zthread - working with system threads (deprecated) **Error Handling** **CZMQ Actors** **Under the Hood** **Adding a New Class** **Documentation** **Development** **Porting CZMQ** **Hints to Contributors** **Code Generation** **This Document** ## Overview ### Scope and Goals CZMQ has these goals: * To wrap the ØMQ core API in semantics that lead to shorter, more readable applications. * To hide as far as possible the differences between different versions of ØMQ (2.x, 3.x, 4.x). * To provide a space for development of more sophisticated API semantics. * To wrap the ØMQ security features with high-level tools and APIs. * To become the basis for other language bindings built on top of CZMQ. CZMQ grew out of concepts developed in [ØMQ - The Guide](http://zguide.zeromq.org).
1
### Ownership and License The contributors are listed in AUTHORS. This project uses the MPL v2 license, see LICENSE. CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/spec:21) guide for code style. To report an issue, use the [CZMQ issue tracker](https://github.com/zeromq/czmq/issues) at github.com. ## Using CZMQ ### Building and Installing Here's how to build CZMQ from GitHub (building from packages is very similar, you don't clone a repo but unpack a tarball), including the libsodium (for security) and libzmq (ZeroMQ core) libraries: git clone git://github.com/jedisct1/libsodium.git cd libsodium ./autogen.sh ./configure && make check sudo make install sudo ldconfig cd .. git clone git://github.com/zeromq/libzmq.git cd libzmq ./autogen.sh ./configure && make check sudo make install sudo ldconfig cd .. git clone git://github.com/zeromq/czmq.git cd czmq ./autogen.sh ./configure && make check sudo make install sudo ldconfig cd .. In general CZMQ works best with the latest libzmq master. If you already have an older version of libzmq installed on your system, e.g. in /usr/, then you can install libzmq master to your home directory ($HOME/local): # Building libzmq in our home directory ./configure --prefix=$HOME/local And then to build CZMQ against this installation of libzmq: export CFLAGS=-I$HOME/local/include export LDFLAGS=-L$HOME/local/lib64 ./configure You will need the pkg-config, libtool, and autoreconf packages. After building, run the CZMQ selftests: make check ### Linking with an Application Include `czmq.h` in your application and link with libczmq. Here is a typical gcc link command: gcc -lczmq -lzmq myapp.c -o myapp ### Use from Other Languages This is a list of known higher-level wrappers around CZMQ: * https://github.com/1100110/CZMQ - D bindings * https://github.com/methodmissing/rbczmq - Ruby * https://github.com/zeromq/pyczmq - Python * https://github.com/lhope/cl-czmq - Common Lisp * https://github.com/fmp88/ocaml-czmq - Ocaml * https://github.com/gar1t/erlang-czmq - Erlang * https://github.com/mtortonesi/ruby-czmq-ffi - Ruby FFI * https://github.com/zeromq/goczmq - Go ### API v3 Summary This is the API provided by CZMQ v3.x, in alphabetical order. #### zactor - simple actor framework The zactor class provides a simple actor framework. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard. A CZMQ actor is implemented as a thread plus a PAIR-PAIR pipe. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished.) A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, zpoller, and zloop. An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command. Please add @discuss section in ../src/zactor.c. This is the class interface: // Actors get a pipe and arguments from caller typedef void (zactor_fn) (zsock_t *pipe, void *args); // Create a new actor passing arbitrary arguments reference. CZMQ_EXPORT zactor_t * zactor_new (zactor_fn *task, void *args); // Destroy an actor. CZMQ_EXPORT void zactor_destroy (zactor_t **p_self); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. CZMQ_EXPORT int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. CZMQ_EXPORT zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. CZMQ_EXPORT bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. CZMQ_EXPORT void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. CZMQ_EXPORT zsock_t * zactor_sock (zactor_t *self); // Self test of this class CZMQ_EXPORT void zactor_test (bool verbose); This is the class self test code: zactor_t *actor = zactor_new (echo_actor, "Hello, World"); assert (actor); zstr_sendx (actor, "ECHO", "This is a string", NULL); char *string = zstr_recv (actor); assert (streq (string, "This is a string")); free (string); zactor_destroy (&actor); #### zauth - authentication for ZeroMQ security mechanisms A zauth actor takes over authentication for all incoming connections in its context. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections. This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: #define CURVE_ALLOW_ANY "*" // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated). // // Create new zauth actor instance. This installs authentication on all // zsock sockets. Until you add policies, all incoming NULL connections are // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections // are denied: // // zactor_t *auth = zactor_new (zauth, NULL); // // Destroy zauth instance. This removes authentication and allows all // connections to pass, without authentication: // // zactor_destroy (&auth); // // Note that all zauth commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity. Verbose logging can help // debug non-trivial authentication policies: // // zstr_send (auth, "VERBOSE"); // zsock_wait (auth); // // Allow (whitelist) a list of IP addresses. For NULL, all clients from // these addresses will be accepted. For PLAIN and CURVE, they will be // allowed to continue with authentication. You can call this method // multiple times to whitelist more IP addresses. If you whitelist one // or nmore addresses, any non-whitelisted addresses are treated as // blacklisted: // // zstr_sendx (auth, "ALLOW", "127.0.0.1", "127.0.0.2", NULL); // zsock_wait (auth); // // Deny (blacklist) a list of IP addresses. For all security mechanisms, // this rejects the connection without any further authentication. Use // either a whitelist, or a blacklist, not not both. If you define both // a whitelist and a blacklist, only the whitelist takes effect: // // zstr_sendx (auth, "DENY", "192.168.0.1", "192.168.0.2", NULL); // zsock_wait (auth); // // Configure PLAIN authentication using a plain-text password file. You can // modify the password file at any time; zauth will reload it automatically // if modified externally: // // zstr_sendx (auth, "PLAIN", filename, NULL); // zsock_wait (auth); // // Configure CURVE authentication, using a directory that holds all public // client certificates, i.e. their public keys. The certificates must be in // zcert_save format. You can add and remove certificates in that directory // at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the directory name: // // zstr_sendx (auth, "CURVE", directory, NULL); // zsock_wait (auth); // // Configure GSSAPI authentication, using an underlying mechanism (usually // Kerberos) to establish a secure context and perform mutual authentication: // // zstr_sendx (auth, "GSSAPI", NULL); // zsock_wait (auth); // // This is the zauth constructor as a zactor_fn: CZMQ_EXPORT void zauth (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zauth_test (bool verbose); This is the class self test code: // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Check there's no authentication zsock_t *server = zsock_new (ZMQ_PUSH); assert (server); zsock_t *client = zsock_new (ZMQ_PULL); assert (client); bool success = s_can_connect (&server, &client); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server success = s_can_connect (&server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client); assert (success); // Blacklist 127.0.0.1, connection should fail zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Try PLAIN authentication zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); success = s_can_connect (&server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); zstr_sendx (auth, "PLAIN", TESTDIR "/password-file", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Bogus"); success = s_can_connect (&server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); success = s_can_connect (&server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zstr_sendx (auth, "CURVE", TESTDIR, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); success = s_can_connect (&server, &client); assert (success); zsock_destroy (&client); zsock_destroy (&server); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #### zbeacon - LAN discovery and presence The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: // Create new zbeacon actor instance: // // zactor_t *beacon = zactor_new (zbeacon, NULL); // // Destroy zbeacon instance: // // zactor_destroy (&beacon); // // Enable verbose logging of commands and activity: // // zstr_send (beacon, "VERBOSE"); // // Configure beacon to run on specified UDP port, and return the name of // the host, which can be used as endpoint for incoming connections. To // force the beacon to operate on a given interface, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating // the beacon. If the system does not support UDP broadcasts (lacking a // workable interface), returns an empty hostname: // // // Pictures: 's' = C string, 'i' = int // zsock_send (beacon, "si", "CONFIGURE", port_number); // char *hostname = zstr_recv (beacon); // // Start broadcasting a beacon at a specified interval in msec. The beacon // data can be at most UDP_FRAME_MAX bytes; this constant is defined in // zsys.h to be 255: // // // Pictures: 'b' = byte * data + size_t size // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); // // Stop broadcasting the beacon: // // zstr_sendx (beacon, "SILENCE", NULL); // // Start listening to beacons from peers. The filter is used to do a prefix // match on received beacons, to remove junk. Note that any received data // that is identical to our broadcast beacon_data is discarded in any case. // If the filter size is zero, we get all peer beacons: // // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); // // Stop listening to other peers // // zstr_sendx (beacon, "UNSUBSCRIBE", NULL); // // Receive next beacon from a peer. Received beacons are always a 2-frame // message containing the ipaddress of the sender, and then the binary // beacon data as published by the sender: // // zmsg_t *msg = zmsg_recv (beacon); // // This is the zbeacon constructor as a zactor_fn: CZMQ_EXPORT void zbeacon (zsock_t *pipe, void *unused); // Self test of this class CZMQ_EXPORT void zbeacon_test (bool verbose); This is the class self test code: // Test 1 - two beacons, one speaking, one listening // Create speaker beacon to broadcast our service zactor_t *speaker = zactor_new (zbeacon, NULL); assert (speaker); if (verbose) zstr_sendx (speaker, "VERBOSE", NULL); zsock_send (speaker, "si", "CONFIGURE", 9999); char *hostname = zstr_recv (speaker); if (!*hostname) { printf ("OK (skipping test, no UDP broadcasting)\n"); zactor_destroy (&speaker); free (hostname); return; } free (hostname); // Create listener beacon on port 9999 to lookup service zactor_t *listener = zactor_new (zbeacon, NULL); assert (listener); if (verbose) zstr_sendx (listener, "VERBOSE", NULL); zsock_send (listener, "si", "CONFIGURE", 9999); hostname = zstr_recv (listener); assert (*hostname); free (hostname); // We will broadcast the magic value 0xCAFE byte announcement [2] = { 0xCA, 0xFE }; zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100); // We will listen to anything (empty subscription) zsock_send (listener, "sb", "SUBSCRIBE", "", 0); // Wait for at most 1/2 second if there's no broadcasting zsock_set_rcvtimeo (listener, 500); char *ipaddress = zstr_recv (listener); if (ipaddress) { zframe_t *content = zframe_recv (listener); assert (zframe_size (content) == 2); assert (zframe_data (content) [0] == 0xCA); assert (zframe_data (content) [1] == 0xFE); zframe_destroy (&content); zstr_free (&ipaddress); zstr_sendx (speaker, "SILENCE", NULL); } zactor_destroy (&listener); zactor_destroy (&speaker); // Test subscription filter using a 3-node setup zactor_t *node1 = zactor_new (zbeacon, NULL); assert (node1); zsock_send (node1, "si", "CONFIGURE", 5670); hostname = zstr_recv (node1); assert (*hostname); free (hostname); zactor_t *node2 = zactor_new (zbeacon, NULL); assert (node2); zsock_send (node2, "si", "CONFIGURE", 5670); hostname = zstr_recv (node2); assert (*hostname); free (hostname); zactor_t *node3 = zactor_new (zbeacon, NULL); assert (node3); zsock_send (node3, "si", "CONFIGURE", 5670); hostname = zstr_recv (node3); assert (*hostname); free (hostname); zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250); zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250); zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250); zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new (node1, node2, node3, NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == node1); char *ipaddress, *received; zstr_recvx (node1, &ipaddress, &received, NULL); assert (streq (received, "NODE/2")); zstr_free (&ipaddress); zstr_free (&received); } } zpoller_destroy (&poller); // Stop listening zstr_sendx (node1, "UNSUBSCRIBE", NULL); // Stop all node broadcasts zstr_sendx (node1, "SILENCE", NULL); zstr_sendx (node2, "SILENCE", NULL); zstr_sendx (node3, "SILENCE", NULL); // Destroy the test nodes zactor_destroy (&node1); zactor_destroy (&node2); zactor_destroy (&node3); #### zcert - work with CURVE security certificates The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism. A certificate contains a public + secret key pair, plus metadata. It can be used as a temporary object in memory, or persisted to disk. On disk, a certificate is stored as two files. One is public and contains only the public key. The second is secret and contains both keys. The two have the same filename, with the secret file adding "_secret". To exchange certificates, send the public file via some secure route. Certificates are not signed but are text files that can be verified by eye. Certificates are stored in the ZPL (ZMQ RFC 4) format. They have two sections, "metadata" and "curve". The first contains a list of 'name = value' pairs, one per line. Values may be enclosed in quotes. The curve section has a 'public-key = keyvalue' and, for secret certificates, a 'secret-key = keyvalue' line. The keyvalue is a Z85-encoded CURVE key. This is the class interface: // Create and initialize a new certificate in memory CZMQ_EXPORT zcert_t * zcert_new (void); // Constructor, accepts public/secret key pair from caller CZMQ_EXPORT zcert_t * zcert_new_from (byte *public_key, byte *secret_key); // Destroy a certificate in memory CZMQ_EXPORT void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string CZMQ_EXPORT byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string CZMQ_EXPORT byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. CZMQ_EXPORT void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. CZMQ_EXPORT char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. CZMQ_EXPORT zlist_t * zcert_meta_keys (zcert_t *self); // Load certificate from file (constructor) CZMQ_EXPORT zcert_t * zcert_load (const char *filename); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). CZMQ_EXPORT int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. CZMQ_EXPORT void zcert_apply (zcert_t *self, void *zocket); // Return copy of certificate; if certificate is null or we exhausted // heap memory, returns null. CZMQ_EXPORT zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys CZMQ_EXPORT bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout CZMQ_EXPORT void zcert_print (zcert_t *self); // DEPRECATED as incompatible with centralized logging // Print certificate contents to open stream CZMQ_EXPORT void zcert_fprint (zcert_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcert_test (bool verbose); This is the class self test code: // Create temporary directory for test files # define TESTDIR ".test_zcert" zsys_dir_create (TESTDIR); // Create a simple certificate with metadata zcert_t *cert = zcert_new (); assert (cert); zcert_set_meta (cert, "email", "ph@imatix.com"); zcert_set_meta (cert, "name", "Pieter Hintjens"); zcert_set_meta (cert, "organization", "iMatix Corporation"); zcert_set_meta (cert, "version", "%d", 1); assert (streq (zcert_meta (cert, "email"), "ph@imatix.com")); zlist_t *keys = zcert_meta_keys (cert); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Check the dup and eq methods zcert_t *shadow = zcert_dup (cert); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Check we can save and load certificate zcert_save (cert, TESTDIR "/mycert.txt"); assert (zsys_file_exists (TESTDIR "/mycert.txt")); assert (zsys_file_exists (TESTDIR "/mycert.txt_secret")); // Load certificate, will in fact load secret one shadow = zcert_load (TESTDIR "/mycert.txt"); assert (shadow); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Delete secret certificate, load public one int rc = zsys_file_delete (TESTDIR "/mycert.txt_secret"); assert (rc == 0); shadow = zcert_load (TESTDIR "/mycert.txt"); // 32-byte null key encodes as 40 '0' characters assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES)); zcert_destroy (&shadow); zcert_destroy (&cert); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #### zcertstore - work with CURVE security certificate stores To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client's public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. The zcert class does the work of managing a single certificate. The certificate store can be memory-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically. In most applications you won't use this class directly but through the zauth class, which provides a high-level API for authentication (and manages certificate stores for you). To actually create certificates on disk, use the zcert class in code, or the tools/makecert.c command line tool, or any text editor. The format of a certificate file is defined in the zcert man page. This is the class interface: // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. CZMQ_EXPORT zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. CZMQ_EXPORT void zcertstore_destroy (zcertstore_t **self_p); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. CZMQ_EXPORT zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. CZMQ_EXPORT void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Print list of certificates in store to logging facility CZMQ_EXPORT void zcertstore_print (zcertstore_t *self); // DEPRECATED as incompatible with centralized logging // Print list of certificates in store to open stream CZMQ_EXPORT void zcertstore_fprint (zcertstore_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcertstore_test (bool verbose); This is the class self test code: // Create temporary directory for test files # define TESTDIR ".test_zcertstore" zsys_dir_create (TESTDIR); // Load certificate store from disk; it will be empty zcertstore_t *certstore = zcertstore_new (TESTDIR); assert (certstore); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); assert (cert); char *client_key = strdup (zcert_public_txt (cert)); assert (client_key); zcert_set_meta (cert, "name", "John Doe"); zcert_save (cert, TESTDIR "/mycert.txt"); zcert_destroy (&cert); // Check that certificate store refreshes as expected cert = zcertstore_lookup (certstore, client_key); assert (cert); assert (streq (zcert_meta (cert, "name"), "John Doe")); free (client_key); if (verbose) zcertstore_print (certstore); zcertstore_destroy (&certstore); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #### zchunk - work with memory chunks The zchunk class works with variable sized blobs. Not as efficient as MQ's messages but they do less weirdness and so are easier to understand. The chunk class has methods to read and write chunks from disk. Please add @discuss section in ../src/zchunk.c. This is the class interface: // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. CZMQ_EXPORT zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk CZMQ_EXPORT void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero CZMQ_EXPORT void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size CZMQ_EXPORT size_t zchunk_size (zchunk_t *self); // Return chunk max size CZMQ_EXPORT size_t zchunk_max_size (zchunk_t *self); // Return chunk data CZMQ_EXPORT byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk CZMQ_EXPORT size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet CZMQ_EXPORT size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size CZMQ_EXPORT size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. CZMQ_EXPORT size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. CZMQ_EXPORT bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor CZMQ_EXPORT zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor CZMQ_EXPORT int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. CZMQ_EXPORT zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. CZMQ_EXPORT zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. CZMQ_EXPORT char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. CZMQ_EXPORT char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator CZMQ_EXPORT bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. CZMQ_EXPORT zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. CZMQ_EXPORT zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. CZMQ_EXPORT const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. CZMQ_EXPORT void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details CZMQ_EXPORT void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. CZMQ_EXPORT bool zchunk_is (void *self); // Self test of this class CZMQ_EXPORT void zchunk_test (bool verbose); This is the class self test code: zchunk_t *chunk = zchunk_new ("1234567890", 10); assert (chunk); assert (zchunk_size (chunk) == 10); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 10); assert (chunk); zchunk_append (chunk, "12345678", 8); zchunk_append (chunk, "90ABCDEF", 8); zchunk_append (chunk, "GHIJKLMN", 8); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); assert (zchunk_size (chunk) == 10); assert (zchunk_streq (chunk, "1234567890")); assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A")); char *string = zchunk_strdup (chunk); assert (streq (string, "1234567890")); free (string); string = zchunk_strhex (chunk); assert (streq (string, "31323334353637383930")); free (string); zframe_t *frame = zchunk_pack (chunk); assert (frame); zchunk_t *chunk2 = zchunk_unpack (frame); assert (chunk2); assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0); zframe_destroy (&frame); zchunk_destroy (&chunk2); zchunk_t *copy = zchunk_dup (chunk); assert (copy); assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0); assert (zchunk_size (copy) == 10); zchunk_destroy (©); zchunk_destroy (&chunk); copy = zchunk_new ("1234567890abcdefghij", 20); assert (copy); chunk = zchunk_new (NULL, 8); assert (chunk); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (zchunk_exhausted (copy)); assert (zchunk_size (chunk) == 4); assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0); zchunk_destroy (©); zchunk_destroy (&chunk); #### zclock - millisecond clocks and delays The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling. Wraps the non-portable system calls in a simple portable API. The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity. This is the class interface: // Sleep for a number of milliseconds CZMQ_EXPORT void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. CZMQ_EXPORT int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). CZMQ_EXPORT char * zclock_timestr (void); // Self test of this class CZMQ_EXPORT void zclock_test (bool verbose); This is the class self test code: int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); start = zclock_mono (); int64_t usecs = zclock_usecs (); zclock_sleep (10); assert ((zclock_mono () - start) >= 10); assert ((zclock_usecs () - usecs) >= 10000); char *timestr = zclock_timestr (); if (verbose) puts (timestr); free (timestr); #### zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. Lets applications load, work with, and save configuration files. This implements rfc.zeromq.org/spec:4/ZPL, which is a simple structured text format for configuration files. Here is an example ZPL stream and corresponding config structure: context iothreads = 1 verbose = 1 # Ask for a trace main type = zqueue # ZMQ_DEVICE type frontend option hwm = 1000 swap = 25000000 # 25MB bind = 'inproc://addr1' bind = 'ipc://addr2' backend bind = inproc://addr3 root Down = child | Across = next v context-->main | | | v | type=queue-->frontend-->backend | | | | | v | | bind=inproc://addr3 | v | option-->bind=inproc://addr1-->bind=ipc://addr2 | | | v | hwm=1000-->swap=25000000 v iothreads=1-->verbose=false This is the class interface: // Function that executes config typedef int (zconfig_fct) (zconfig_t *self, void *arg, int level); // Create new config item CZMQ_EXPORT zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children CZMQ_EXPORT void zconfig_destroy (zconfig_t **self_p); // Return name of config item CZMQ_EXPORT char * zconfig_name (zconfig_t *self); // Return value of config item CZMQ_EXPORT char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value CZMQ_EXPORT void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. CZMQ_EXPORT void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...); // Find our first child, if any CZMQ_EXPORT zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any CZMQ_EXPORT zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. CZMQ_EXPORT zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Resolve a config path into a string value; leading slash is optional // and ignored. CZMQ_EXPORT char * zconfig_resolve (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_path (zconfig_t *self, const char *path, const char *value); // Locate the last config item at a specified depth CZMQ_EXPORT zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. CZMQ_EXPORT int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. CZMQ_EXPORT void zconfig_set_comment (zconfig_t *self, const char *format, ...); // Return comments of config item, as zlist. CZMQ_EXPORT zlist_t * zconfig_comments (zconfig_t *self); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. CZMQ_EXPORT zconfig_t * zconfig_load (const char *filename); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. CZMQ_EXPORT int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. CZMQ_EXPORT zconfig_t * zconfig_loadf (const char *format, ...); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. CZMQ_EXPORT int zconfig_savef (zconfig_t *self, const char *format, ...); // Report filename used during zconfig_load, or NULL if none CZMQ_EXPORT char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). CZMQ_EXPORT int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk CZMQ_EXPORT zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk CZMQ_EXPORT zchunk_t * zconfig_chunk_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. CZMQ_EXPORT bool zconfig_has_changed (zconfig_t *self); // Print the config file to open stream CZMQ_EXPORT void zconfig_fprint (zconfig_t *self, FILE *file); // Print the config file to stdout CZMQ_EXPORT void zconfig_print (zconfig_t *self); This is the class self test code: // Create temporary directory for test files # define TESTDIR ".test_zconfig" zsys_dir_create (TESTDIR); zconfig_t *root = zconfig_new ("root", NULL); assert (root); zconfig_t *section, *item; section = zconfig_new ("headers", root); assert (section); item = zconfig_new ("email", section); assert (item); zconfig_set_value (item, "some@random.com"); item = zconfig_new ("name", section); assert (item); zconfig_set_value (item, "Justin Kayce"); zconfig_putf (root, "/curve/secret-key", "%s", "Top Secret"); zconfig_set_comment (root, " CURVE certificate"); zconfig_set_comment (root, " -----------------"); assert (zconfig_comments (root)); zconfig_save (root, TESTDIR "/test.cfg"); zconfig_destroy (&root); root = zconfig_load (TESTDIR "/test.cfg"); if (verbose) zconfig_save (root, "-"); assert (streq (zconfig_filename (root), TESTDIR "/test.cfg")); char *email = zconfig_resolve (root, "/headers/email", NULL); assert (email); assert (streq (email, "some@random.com")); char *passwd = zconfig_resolve (root, "/curve/secret-key", NULL); assert (passwd); assert (streq (passwd, "Top Secret")); zconfig_savef (root, "%s/%s", TESTDIR, "test.cfg"); assert (!zconfig_has_changed (root)); int rc = zconfig_reload (&root); assert (rc == 0); assert (!zconfig_has_changed (root)); zconfig_destroy (&root); // Test chunk load/save root = zconfig_new ("root", NULL); assert (root); section = zconfig_new ("section", root); assert (section); item = zconfig_new ("value", section); assert (item); zconfig_set_value (item, "somevalue"); zchunk_t *chunk = zconfig_chunk_save (root); assert (chunk); zconfig_destroy (&root); root = zconfig_chunk_load (chunk); assert (root); char *value = zconfig_resolve (root, "/section/value", NULL); assert (value); assert (streq (value, "somevalue")); // Test config can't be saved to a file in a path that doesn't // exist or isn't writable rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", TESTDIR, "test.cfg"); assert (rc == -1); zconfig_destroy (&root); zchunk_destroy (&chunk); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #### zdigest - provides hashing functions (SHA-1 at present) The zdigest class generates a hash from zchunks of data. The current algorithm is SHA-1, chosen for speed. We are aiming to generate a unique digest for a file, and there are no security issues in this use case. The current code depends on OpenSSL, which might be replaced by hard coded SHA-1 implementation to reduce build dependencies. This is the class interface: // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. CZMQ_EXPORT zdigest_t * zdigest_new (void); // Destroy a digest object CZMQ_EXPORT void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation CZMQ_EXPORT void zdigest_update (zdigest_t *self, byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, returns // NULL. CZMQ_EXPORT byte * zdigest_data (zdigest_t *self); // Return final digest hash size CZMQ_EXPORT size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. CZMQ_EXPORT char * zdigest_string (zdigest_t *self); // Self test of this class CZMQ_EXPORT void zdigest_test (bool verbose); This is the class self test code: byte *buffer = (byte *) zmalloc (1024); memset (buffer, 0xAA, 1024); zdigest_t *digest = zdigest_new (); assert (digest); zdigest_update (digest, buffer, 1024); byte *data = zdigest_data (digest); assert (data [0] == 0xDE); assert (data [1] == 0xB2); assert (data [2] == 0x38); assert (data [3] == 0x07); assert (streq (zdigest_string (digest), "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671")); zdigest_destroy (&digest); free (buffer); #### zdir - work with file-system directories The zdir class gives access to the file system index. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure. It exists mainly to wrap non-portable OS functions to do this. Please add @discuss section in ../src/zdir.c. This is the class interface: // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. CZMQ_EXPORT zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. CZMQ_EXPORT void zdir_destroy (zdir_t **self_p); // Return directory path CZMQ_EXPORT char * zdir_path (zdir_t *self); // Return last modification time for directory. CZMQ_EXPORT time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. CZMQ_EXPORT off_t zdir_cursize (zdir_t *self); // Return directory count CZMQ_EXPORT size_t zdir_count (zdir_t *self); // Returns a sorted array of zfile objects; returns a single block of memory, // that you destroy by calling zstr_free(). Each entry in the array is a pointer // to a zfile_t item already allocated in the zdir tree. The array ends with // a null pointer. Do not destroy the original zdir tree until you are done // with this array. CZMQ_EXPORT zfile_t ** zdir_flatten (zdir_t *self); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zdir_flatten_free (zfile_t ***files_p); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. CZMQ_EXPORT void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). CZMQ_EXPORT zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. CZMQ_EXPORT zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // The caller must destroy the hash table when done with it. CZMQ_EXPORT zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream CZMQ_EXPORT void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout CZMQ_EXPORT void zdir_print (zdir_t *self, int indent); // Self test of this class CZMQ_EXPORT void zdir_test (bool verbose); This is the class self test code: zdir_t *older = zdir_new (".", NULL); assert (older); if (verbose) { printf ("\n"); zdir_dump (older, 0); } zdir_t *newer = zdir_new ("..", NULL); assert (newer); zlist_t *patches = zdir_diff (older, newer, "/"); assert (patches); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); zdir_patch_destroy (&patch); } zlist_destroy (&patches); zdir_destroy (&older); zdir_destroy (&newer); zdir_t *nosuch = zdir_new ("does-not-exist", NULL); assert (nosuch == NULL); #### zdir_patch - work with directory patches The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time). Please add @discuss section in ../src/zdir_patch.c. This is the class interface: // Create new patch CZMQ_EXPORT zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, zdir_patch_op_t op, const char *alias); // Destroy a patch CZMQ_EXPORT void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. CZMQ_EXPORT zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path CZMQ_EXPORT char * zdir_patch_path (zdir_patch_t *self); // Return patch file item CZMQ_EXPORT zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation CZMQ_EXPORT zdir_patch_op_t zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path CZMQ_EXPORT char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) CZMQ_EXPORT void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file CZMQ_EXPORT char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class CZMQ_EXPORT void zdir_patch_test (bool verbose); This is the class self test code: zfile_t *file = zfile_new (".", "bilbo"); assert (file); zdir_patch_t *patch = zdir_patch_new (".", file, patch_create, "/"); assert (patch); zfile_destroy (&file); file = zdir_patch_file (patch); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (streq (zdir_patch_vpath (patch), "/bilbo")); zdir_patch_destroy (&patch); #### zfile - provides methods to work with files in a portable fashion. The zfile class provides methods to work with disk files. A file object provides the modified date, current size, and type of the file. You can create a file object for a filename that does not yet exist. To read or write data from the file, use the input and output methods, and then read and write chunks. The output method lets you both read and write chunks, at any offset. Finally, this class provides portable symbolic links. If a filename ends in ".ln", the first line of text in the file is read, and used as the underlying file for read/write operations. This lets you manipulate (e.g.) copy symbolic links without copying the perhaps very large files they point to. This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now). This is the class interface: // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. CZMQ_EXPORT zfile_t * zfile_new (const char *path, const char *name); // Destroy a file item CZMQ_EXPORT void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. CZMQ_EXPORT zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided CZMQ_EXPORT char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. CZMQ_EXPORT void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. CZMQ_EXPORT bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. CZMQ_EXPORT bool zfile_has_changed (zfile_t *self); // Remove the file from disk CZMQ_EXPORT void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible CZMQ_EXPORT int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. CZMQ_EXPORT int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. CZMQ_EXPORT zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. CZMQ_EXPORT bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 CZMQ_EXPORT int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. CZMQ_EXPORT const char * zfile_readln (zfile_t *self); // Close file, if open CZMQ_EXPORT void zfile_close (zfile_t *self); // Return file handle, if opened CZMQ_EXPORT FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. CZMQ_EXPORT const char * zfile_digest (zfile_t *self); // Self test of this class CZMQ_EXPORT void zfile_test (bool verbose); // These methods are deprecated, and now moved to zsys class. CZMQ_EXPORT bool zfile_exists (const char *filename); CZMQ_EXPORT ssize_t zfile_size (const char *filename); CZMQ_EXPORT mode_t zfile_mode (const char *filename); CZMQ_EXPORT int zfile_delete (const char *filename); CZMQ_EXPORT bool zfile_stable (const char *filename); CZMQ_EXPORT int zfile_mkdir (const char *pathname); CZMQ_EXPORT int zfile_rmdir (const char *pathname); CZMQ_EXPORT void zfile_mode_private (void); CZMQ_EXPORT void zfile_mode_default (void); This is the class self test code: zfile_t *file = zfile_new (NULL, "bilbo"); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (zfile_is_readable (file) == false); zfile_destroy (&file); // Create a test file in some random subdirectory file = zfile_new ("./this/is/a/test", "bilbo"); assert (file); int rc = zfile_output (file); assert (rc == 0); zchunk_t *chunk = zchunk_new (NULL, 100); assert (chunk); zchunk_fill (chunk, 0, 100); // Write 100 bytes at position 1,000,000 in the file rc = zfile_write (file, chunk, 1000000); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_is_readable (file)); assert (zfile_cursize (file) == 1000100); assert (!zfile_is_stable (file)); assert (zfile_digest (file)); // Now truncate file from outside int handle = open ("./this/is/a/test/bilbo", O_WRONLY | O_TRUNC | O_BINARY, 0); assert (handle >= 0); rc = write (handle, "Hello, World\n", 13); assert (rc == 13); close (handle); assert (zfile_has_changed (file)); zclock_sleep (1001); assert (zfile_has_changed (file)); assert (!zfile_is_stable (file)); zfile_restat (file); assert (zfile_is_stable (file)); assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54")); // Check we can read from file rc = zfile_input (file); assert (rc == 0); chunk = zfile_read (file, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_close (file); // Check we can read lines from file rc = zfile_input (file); assert (rc == 0); const char *line = zfile_readln (file); assert (streq (line, "Hello, World")); line = zfile_readln (file); assert (line == NULL); zfile_close (file); // Try some fun with symbolic links zfile_t *link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_output (link); assert (rc == 0); fprintf (zfile_handle (link), "./this/is/a/test/bilbo\n"); zfile_destroy (&link); link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_input (link); assert (rc == 0); chunk = zfile_read (link, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_destroy (&link); // Remove file and directory zdir_t *dir = zdir_new ("./this", NULL); assert (dir); assert (zdir_cursize (dir) == 26); zdir_remove (dir, true); assert (zdir_cursize (dir) == 0); zdir_destroy (&dir); // Check we can no longer read from file assert (zfile_is_readable (file)); zfile_restat (file); assert (!zfile_is_readable (file)); rc = zfile_input (file); assert (rc == -1); zfile_destroy (&file); #### zframe - working with single message frames The zframe class provides methods to send and receive single message frames across ØMQ sockets. A 'frame' corresponds to one zmq_msg_t. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times. Frames are binary, and this class has no special support for text data. Please add @discuss section in ../src/zframe.c. This is the class interface: #define ZFRAME_MORE 1 #define ZFRAME_REUSE 2 #define ZFRAME_DONTWAIT 4 // Constructor; if size is >0, allocates frame with that size, and if data // is not null, copies data into frame. CZMQ_EXPORT zframe_t * zframe_new (const void *data, size_t size); // Create an empty (zero-sized) frame CZMQ_EXPORT zframe_t * zframe_new_empty (void); // Destroy a frame CZMQ_EXPORT void zframe_destroy (zframe_t **self_p); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. CZMQ_EXPORT zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data CZMQ_EXPORT size_t zframe_size (zframe_t *self); // Return address of frame data CZMQ_EXPORT byte * zframe_data (zframe_t *self); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. CZMQ_EXPORT zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for ØMQ UUIDs. // Caller must free string when finished with it. CZMQ_EXPORT char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. CZMQ_EXPORT char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator CZMQ_EXPORT bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method CZMQ_EXPORT int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. CZMQ_EXPORT void zframe_set_more (zframe_t *self, int more); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. CZMQ_EXPORT bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame CZMQ_EXPORT void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. CZMQ_EXPORT void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. CZMQ_EXPORT bool zframe_is (void *self); // Self test of this class CZMQ_EXPORT void zframe_test (bool verbose); This is the class self test code: // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zframe.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zframe.test"); assert (input); // Send five different frames, test ZFRAME_MORE int frame_nbr; for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, ZFRAME_MORE); assert (rc == 0); } // Send same frame five times, test ZFRAME_REUSE frame = zframe_new ("Hello", 5); assert (frame); for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE); assert (rc == 0); } assert (frame); zframe_t *copy = zframe_dup (frame); assert (zframe_eq (frame, copy)); zframe_destroy (&frame); assert (!zframe_eq (frame, copy)); assert (zframe_size (copy) == 5); zframe_destroy (©); assert (!zframe_eq (frame, copy)); // Test zframe_new_empty frame = zframe_new_empty (); assert (frame); assert (zframe_size (frame) == 0); zframe_destroy (&frame); // Send END frame frame = zframe_new ("NOT", 3); assert (frame); zframe_reset (frame, "END", 3); char *string = zframe_strhex (frame); assert (streq (string, "454E44")); free (string); string = zframe_strdup (frame); assert (streq (string, "END")); free (string); rc = zframe_send (&frame, output, 0); assert (rc == 0); // Read and count until we receive END frame_nbr = 0; for (frame_nbr = 0;; frame_nbr++) { zframe_t *frame = zframe_recv (input); if (zframe_streq (frame, "END")) { zframe_destroy (&frame); break; } assert (zframe_more (frame)); zframe_set_more (frame, 0); assert (zframe_more (frame) == 0); zframe_destroy (&frame); } assert (frame_nbr == 10); zsock_destroy (&input); zsock_destroy (&output); #### zgossip - decentralized configuration management Implements a gossip protocol for decentralized configuration management. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples. Each node re-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state. The current design does not expire tuples. Provides these commands (sent as multipart strings to the actor): * BIND endpoint -- binds the gossip service to specified endpoint * PORT -- returns the last TCP port, if any, used for binding * LOAD configfile -- load configuration from specified file * SET configpath value -- set configuration path = value * SAVE configfile -- save configuration to specified file * CONNECT endpoint -- connect the gossip service to the specified peer * PUBLISH key value -- publish a key/value pair to the gossip cluster * STATUS -- return number of key/value pairs held by gossip service Returns these messages: * PORT number -- reply to PORT command * STATUS number -- reply to STATUS command * DELIVER key value -- new tuple delivered from network The gossip protocol distributes information around a loosely-connected network of gossip services. The information consists of name/value pairs published by applications at any point in the network. The goal of the gossip protocol is to create eventual consistency between all the using applications. The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery. When used for discovery, the gossip protocol works as an alternative to e.g. UDP beaconing. The gossip network consists of a set of loosely-coupled nodes that exchange tuples. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time. Each node runs the same stack, which is a server-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): http://zguide.zeromq.org/page:all#True-Peer-Connectivity-Harmony-Pattern Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command. The state machine for these connections is in zgossip.xml, and the generated code is in zgossip_engine.inc. Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote. The messages between client and server are defined in zgossip_msg.xml. We built this stack using the zeromq/zproto toolkit. To join the gossip network, a node connects to one or more peers. Each peer acts as a forwarder. This loosely-coupled network can scale to thousands of nodes. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network. The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to. When a node gets a duplicate tuple, it throws it away. When a node gets a new tuple, it stores it, and fowards it as just described. At any point the application can access the node's set of tuples. At present there is no way to expire tuples from the network. The assumptions in this design are: * The data set is slow-changing. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic. This is the class interface: // To work with zgossip, use the CZMQ zactor API: // // Create new zgossip instance, passing logging prefix: // // zactor_t *zgossip = zactor_new (zgossip, "myname"); // // Destroy zgossip instance // // zactor_destroy (&zgossip); // // Enable verbose logging of commands and activity: // // zstr_send (zgossip, "VERBOSE"); // // Bind zgossip to specified endpoint. TCP endpoints may specify // the port number as "*" to aquire an ephemeral port: // // zstr_sendx (zgossip, "BIND", endpoint, NULL); // // Return assigned port number, specifically when BIND was done using an // an ephemeral port: // // zstr_sendx (zgossip, "PORT", NULL); // char *command, *port_str; // zstr_recvx (zgossip, &command, &port_str, NULL); // assert (streq (command, "PORT")); // // Specify configuration file to load, overwriting any previous loaded // configuration file or options: // // zstr_sendx (zgossip, "CONFIGURE", filename, NULL); // // Set configuration path value: // // zstr_sendx (zgossip, "SET", path, value, NULL); // // Send zmsg_t instance to zgossip: // // zactor_send (zgossip, &msg); // // Receive zmsg_t instance from zgossip: // // zmsg_t *msg = zactor_recv (zgossip); // // This is the zgossip constructor as a zactor_fn: // CZMQ_EXPORT void zgossip (zsock_t *pipe, void *args); // Self test of this class CZMQ_EXPORT void zgossip_test (bool verbose); This is the class self test code: // Test basic client-to-server operation of the protocol zactor_t *server = zactor_new (zgossip, "server"); assert (server); if (verbose) zstr_send (server, "VERBOSE"); zstr_sendx (server, "BIND", "inproc://zgossip", NULL); zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zsock_set_rcvtimeo (client, 2000); int rc = zsock_connect (client, "inproc://zgossip"); assert (rc == 0); // Send HELLO, which gets no message zgossip_msg_t *message = zgossip_msg_new (); zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (message, client); // Send PING, expect PONG back zgossip_msg_set_id (message, ZGOSSIP_MSG_PING); zgossip_msg_send (message, client); zgossip_msg_recv (message, client); assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG); zgossip_msg_destroy (&message); zactor_destroy (&server); zsock_destroy (&client); // Test peer-to-peer operations zactor_t *base = zactor_new (zgossip, "base"); assert (base); if (verbose) zstr_send (base, "VERBOSE"); // Set a 100msec timeout on clients so we can test expiry zstr_sendx (base, "SET", "server/timeout", "100", NULL); zstr_sendx (base, "BIND", "inproc://base", NULL); zactor_t *alpha = zactor_new (zgossip, "alpha"); assert (alpha); zstr_sendx (alpha, "CONNECT", "inproc://base", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-1", "service1", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-2", "service2", NULL); zactor_t *beta = zactor_new (zgossip, "beta"); assert (beta); zstr_sendx (beta, "CONNECT", "inproc://base", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-1", "service1", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-2", "service2", NULL); // got nothing zclock_sleep (200); zactor_destroy (&base); zactor_destroy (&alpha); zactor_destroy (&beta); #### zhash - simple generic hash container zhash is an expandable hash table container. This is a simple container. For heavy-duty applications we recommend using zhashx. Note that it's relatively slow (~50K insertions/deletes per second), so don't do inserts/updates on the critical path for message I/O. It can do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU. This is the class interface: // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // DEPRECATED as clumsy -- use zhash_first/_next instead typedef int (zhash_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhash_t * zhash_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhash_destroy (zhash_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. CZMQ_EXPORT void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null CZMQ_EXPORT void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t * zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. CZMQ_EXPORT zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table CZMQ_EXPORT zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhash_comment (zhash_t *self, format_t *format); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. CZMQ_EXPORT zframe_t * zhash_pack (zhash_t *self); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. CZMQ_EXPORT zhash_t * zhash_unpack (zframe_t *frame); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction CZMQ_EXPORT void zhash_autofree (zhash_t *self); // DEPRECATED as clumsy -- use zhash_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). // Callback function for zhash_foreach method CZMQ_EXPORT int zhash_foreach (zhash_t *self, zhash_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhash_test (int verbose); This is the class self test code: zhash_t *hash = zhash_new (); assert (hash); assert (zhash_size (hash) == 0); assert (zhash_first (hash) == NULL); assert (zhash_cursor (hash) == NULL); // Insert some items int rc; rc = zhash_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhash_first (hash); assert (streq (zhash_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhash_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhash_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhash_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhash_size (hash) == 4); // Look for existing items item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhash_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhash_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhash_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhash_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhash_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlist_t *keys = zhash_keys (hash); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Test dup method zhash_t *copy = zhash_dup (hash); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test pack/unpack methods zframe_t *frame = zhash_pack (hash); copy = zhash_unpack (frame); zframe_destroy (&frame); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test save and load zhash_comment (hash, "This is a test file"); zhash_comment (hash, "Created by %s", "czmq_selftest"); zhash_save (hash, ".cache"); copy = zhash_new (); assert (copy); zhash_load (copy, ".cache"); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); zsys_file_delete (".cache"); // Delete a item zhash_delete (hash, "LIVEBEEF"); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhash_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr].exists) { item = (char *) zhash_lookup (hash, testset [testnbr].name); assert (item); zhash_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhash_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhash_destroy (&hash); zhash_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhash_new (); assert (hash); zhash_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhash_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Ring a ding ding"); rc = zhash_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding")); zhash_destroy (&hash); #### ziflist - List of network interfaces available on system The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices). The caller can then access the network interface information using an iterator that works like zlistx. Only stores those interfaces with broadcast capability, and ignores the loopback interface. Please add @discuss section in ../src/ziflist.c. This is the class interface: // Get a list of network interfaces currently defined on the system CZMQ_EXPORT ziflist_t * ziflist_new (void); // Destroy a ziflist instance CZMQ_EXPORT void ziflist_destroy (ziflist_t **self_p); // Reload network interfaces from system CZMQ_EXPORT void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system CZMQ_EXPORT size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none CZMQ_EXPORT const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one CZMQ_EXPORT const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string CZMQ_EXPORT const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string CZMQ_EXPORT const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string CZMQ_EXPORT const char * ziflist_netmask (ziflist_t *self); // Selftest for this class CZMQ_EXPORT void ziflist_test (bool verbose); This is the class self test code: ziflist_t *iflist = ziflist_new (); assert (iflist); size_t items = ziflist_size (iflist); if (verbose) { // printf ("ziflist: interfaces=%zu\n", ziflist_size (iflist)); const char *name = ziflist_first (iflist); while (name) { printf (" - name=%s address=%s netmask=%s broadcast=%s\n", name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist)); name = ziflist_next (iflist); } } ziflist_reload (iflist); assert (items == ziflist_size (iflist)); ziflist_destroy (&iflist); #### zlist - simple generic list container Provides a generic container implementing a fast singly-linked list. You can use this to construct multi-dimensional lists, and other structures together with other generic containers like zhash. This is a simple class. For demanding applications we recommend using zlistx. To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration. This is the class interface: // Comparison function for zlist_sort method typedef bool (zlist_compare_fn) (void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) (void *data); // Create a new list container CZMQ_EXPORT zlist_t * zlist_new (void); // Destroy a list container CZMQ_EXPORT void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any CZMQ_EXPORT void * zlist_pop (zlist_t *self); // Remove the specified item from the list if present CZMQ_EXPORT void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. CZMQ_EXPORT zlist_t * zlist_dup (zlist_t *self); // Purge all items from list CZMQ_EXPORT void zlist_purge (zlist_t *self); // Return number of items in the list CZMQ_EXPORT size_t zlist_size (zlist_t *self); // Sort the list by ascending key value using a straight ASCII comparison. // The sort is not stable, so may reorder items with the same keys. CZMQ_EXPORT void zlist_sort (zlist_t *self, zlist_compare_fn *compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. CZMQ_EXPORT void zlist_autofree (zlist_t *self); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn *fn, bool at_tail); // Self test of this class CZMQ_EXPORT void zlist_test (int verbose); This is the class self test code: zlist_t *list = zlist_new (); assert (list); assert (zlist_size (list) == 0); // Three items we'll use as test data // List items are void *, not particularly strings char *cheese = "boursin"; char *bread = "baguette"; char *wine = "bordeaux"; zlist_append (list, cheese); assert (zlist_size (list) == 1); zlist_append (list, bread); assert (zlist_size (list) == 2); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_head (list) == cheese); assert (zlist_next (list) == cheese); assert (zlist_first (list) == cheese); assert (zlist_tail (list) == wine); assert (zlist_next (list) == bread); assert (zlist_first (list) == cheese); assert (zlist_next (list) == bread); assert (zlist_next (list) == wine); assert (zlist_next (list) == NULL); // After we reach end of list, next wraps around assert (zlist_next (list) == cheese); assert (zlist_size (list) == 3); zlist_remove (list, wine); assert (zlist_size (list) == 2); assert (zlist_first (list) == cheese); zlist_remove (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == bread); zlist_remove (list, bread); assert (zlist_size (list) == 0); zlist_append (list, cheese); zlist_append (list, bread); assert (zlist_last (list) == bread); zlist_remove (list, bread); assert (zlist_last (list) == cheese); zlist_remove (list, cheese); assert (zlist_last (list) == NULL); zlist_push (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == cheese); zlist_push (list, bread); assert (zlist_size (list) == 2); assert (zlist_first (list) == bread); assert (zlist_item (list) == bread); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_first (list) == bread); zlist_t *sub_list = zlist_dup (list); assert (sub_list); assert (zlist_size (sub_list) == 3); zlist_sort (list, s_compare); char *item; item = (char *) zlist_pop (list); assert (item == bread); item = (char *) zlist_pop (list); assert (item == cheese); item = (char *) zlist_pop (list); assert (item == wine); assert (zlist_size (list) == 0); assert (zlist_size (sub_list) == 3); zlist_push (list, sub_list); zlist_t *sub_list_2 = zlist_dup (sub_list); zlist_append (list, sub_list_2); assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list); assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2); zlist_destroy (&list); // Test autofree functionality list = zlist_new (); assert (list); zlist_autofree (list); zlist_push (list, "bread"); zlist_append (list, "cheese"); assert (zlist_size (list) == 2); assert (streq ((const char *) zlist_first (list), "bread")); item = (char *) zlist_pop (list); assert (streq (item, "bread")); free (item); item = (char *) zlist_pop (list); assert (streq (item, "cheese")); free (item); zlist_destroy (&list); assert (list == NULL); #### zloop - event-driven reactor The zloop class provides an event-driven reactor pattern. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once-off or repeated timers. Its resolution is 1 msec. It uses a tickless timer to reduce CPU interrupts in inactive processes. Please add @discuss section in ../src/zloop.c. This is the class interface: // Callback function for reactor socket activity typedef int (zloop_reader_fn) (zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) (zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) (zloop_t *loop, int timer_id, void *arg); // Create a new zloop reactor CZMQ_EXPORT zloop_t * zloop_new (void); // Destroy a reactor CZMQ_EXPORT void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. CZMQ_EXPORT int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. CZMQ_EXPORT void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. CZMQ_EXPORT int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. CZMQ_EXPORT void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. CZMQ_EXPORT int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). CZMQ_EXPORT int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. CZMQ_EXPORT void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. CZMQ_EXPORT void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. CZMQ_EXPORT void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. CZMQ_EXPORT void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. CZMQ_EXPORT void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off CZMQ_EXPORT void zloop_set_verbose (zloop_t *self, bool verbose); // Start the reactor. Takes control of the thread and returns when the ØMQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if cancelled by a handler. CZMQ_EXPORT int zloop_start (zloop_t *self); // Ignore zsys_interrupted flag in this loop. By default, a zloop_start will // exit as soon as it detects zsys_interrupted is set to something other than // zero. Calling zloop_ignore_interrupts will supress this behavior. CZMQ_EXPORT void zloop_ignore_interrupts(zloop_t *self); // Self test of this class CZMQ_EXPORT void zloop_test (bool verbose); This is the class self test code: // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); zsock_bind (output, "inproc://zloop.test"); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); zsock_connect (input, "inproc://zloop.test"); zloop_t *loop = zloop_new (); assert (loop); zloop_set_verbose (loop, verbose); // Create a timer that will be cancelled int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL); zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id); // After 20 msecs, send a ping message to output3 zloop_timer (loop, 20, 1, s_timer_event, output); // Set up some tickets that will never expire zloop_set_ticket_delay (loop, 10000); void *ticket1 = zloop_ticket (loop, s_timer_event, NULL); void *ticket2 = zloop_ticket (loop, s_timer_event, NULL); void *ticket3 = zloop_ticket (loop, s_timer_event, NULL); // When we get the ping message, end the reactor rc = zloop_reader (loop, input, s_socket_event, NULL); assert (rc == 0); zloop_reader_set_tolerant (loop, input); zloop_start (loop); zloop_ticket_delete (loop, ticket1); zloop_ticket_delete (loop, ticket2); zloop_ticket_delete (loop, ticket3); // Check whether loop properly ignores zsys_interrupted flag // when asked to zloop_destroy (&loop); loop = zloop_new (); bool timer_event_called = false; zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called); zsys_interrupted = 1; zloop_start (loop); // zloop returns immediately without giving any handler a chance to run assert (!timer_event_called); zloop_ignore_interrupts (loop); zloop_start (loop); // zloop runs the handler which will terminate the loop assert (timer_event_called); zsys_interrupted = 0; // cleanup zloop_destroy (&loop); assert (loop == NULL); zsock_destroy (&input); zsock_destroy (&output); #### zmonitor - socket event monitor The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Works on all versions of libzmq from 3.2 onwards. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: // Create new zmonitor actor instance to monitor a zsock_t socket: // // zactor_t *monitor = zactor_new (zmonitor, mysocket); // // Destroy zmonitor instance. // // zactor_destroy (&monitor); // // Enable verbose logging of commands and activity. // // zstr_send (monitor, "VERBOSE"); // // Listen to monitor event type (zero or types, ending in NULL): // zstr_sendx (monitor, "LISTEN", type, ..., NULL); // // Events: // CONNECTED // CONNECT_DELAYED // CONNECT_RETRIED // LISTENING // BIND_FAILED // ACCEPTED // ACCEPT_FAILED // CLOSED // CLOSE_FAILED // DISCONNECTED // MONITOR_STOPPED // ALL // // Start monitor; after this, any further LISTEN commands are ignored. // // zstr_send (monitor, "START"); // zsock_wait (monitor); // // Receive next monitor event: // // zmsg_t *msg = zmsg_recv (monitor); // // This is the zmonitor constructor as a zactor_fn; the argument can be // a zactor_t, zsock_t, or libzmq void * socket: CZMQ_EXPORT void zmonitor (zsock_t *pipe, void *sock); // Selftest CZMQ_EXPORT void zmonitor_test (bool verbose); This is the class self test code: zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zactor_t *clientmon = zactor_new (zmonitor, client); assert (clientmon); if (verbose) zstr_sendx (clientmon, "VERBOSE", NULL); zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL); zstr_sendx (clientmon, "START", NULL); zsock_wait (clientmon); zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon); // Allow a brief time for the message to get there... zmq_poll (NULL, 0, 200); // Check client is now listening int port_nbr = zsock_bind (client, "tcp://127.0.0.1:*"); assert (port_nbr != -1); s_assert_event (clientmon, "LISTENING"); // Check server connected to client zsock_connect (server, "tcp://127.0.0.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED"); // Check client accepted connection s_assert_event (clientmon, "ACCEPTED"); zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif #### zmsg - working with multipart messages The zmsg class provides methods to send and receive multipart messages across ØMQ sockets. This class provides a list-like container interface, with methods to work with the overall container. zmsg_t messages are composed of zero or more zframe_t frames. Please add @discuss section in ../src/zmsg.c. This is the class interface: // Create a new empty message object CZMQ_EXPORT zmsg_t * zmsg_new (void); // Destroy a message object and all frames it contains CZMQ_EXPORT void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. CZMQ_EXPORT zmsg_t * zmsg_recv (void *source); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). CZMQ_EXPORT size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. CZMQ_EXPORT size_t zmsg_content_size (zmsg_t *self); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. CZMQ_EXPORT int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. CZMQ_EXPORT int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. Caller // now owns frame and must destroy it when finished with it. CZMQ_EXPORT zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushmem (zmsg_t *self, const void *src, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addmem (zmsg_t *self, const void *src, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. CZMQ_EXPORT char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. CZMQ_EXPORT int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not succesfull. Caller now owns message and must destroy it // when finished with it. CZMQ_EXPORT zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. CZMQ_EXPORT void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. CZMQ_EXPORT zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. CZMQ_EXPORT zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. CZMQ_EXPORT zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. CZMQ_EXPORT int zmsg_save (zmsg_t *self, FILE *file); // Load/append an open file into message, create new message if // null message provided. Returns NULL if the message could not // be loaded. CZMQ_EXPORT zmsg_t * zmsg_load (zmsg_t *self, FILE *file); // Serialize multipart message to a single buffer. Use this method to send // structured messages across transports that do not support multipart data. // Allocates and returns a new buffer containing the serialized message. // To decode a serialized message buffer, use zmsg_decode (). CZMQ_EXPORT size_t zmsg_encode (zmsg_t *self, byte **buffer); // Decodes a serialized message buffer created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the buffer was badly formatted or // there was insufficient memory to work. CZMQ_EXPORT zmsg_t * zmsg_decode (byte *buffer, size_t buffer_size); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. CZMQ_EXPORT zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). CZMQ_EXPORT void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. CZMQ_EXPORT bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. CZMQ_EXPORT zmsg_t * zmsg_new_signal (byte status); // Return signal value, 0 or greater, if message is a signal, -1 if not. CZMQ_EXPORT int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. CZMQ_EXPORT bool zmsg_is (void *self); // Self test of this class CZMQ_EXPORT void zmsg_test (bool verbose); This is the class self test code: // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zmsg.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zmsg.test"); assert (input); // Test send and receive of single-frame message zmsg_t *msg = zmsg_new (); assert (msg); zframe_t *frame = zframe_new ("Hello", 5); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); rc = zmsg_send (&msg, output); assert (msg == NULL); assert (rc == 0); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); zmsg_destroy (&msg); // Test send and receive of multi-frame message msg = zmsg_new (); assert (msg); rc = zmsg_addmem (msg, "Frame0", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame1", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame2", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame3", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame4", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame5", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame6", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame7", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame8", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame9", 6); assert (rc == 0); zmsg_t *copy = zmsg_dup (msg); assert (copy); rc = zmsg_send (©, output); assert (rc == 0); rc = zmsg_send (&msg, output); assert (rc == 0); copy = zmsg_recv (input); assert (copy); assert (zmsg_size (copy) == 10); assert (zmsg_content_size (copy) == 60); zmsg_destroy (©); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // create empty file for null test FILE *file = fopen ("zmsg.test", "w"); assert (file); fclose (file); file = fopen ("zmsg.test", "r"); zmsg_t *null_msg = zmsg_load (NULL, file); assert (null_msg == NULL); fclose (file); remove ("zmsg.test"); // Save to a file, read back file = fopen ("zmsg.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg.test", "r"); rc = zmsg_save (msg, file); assert (rc == -1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg.test", "r"); msg = zmsg_load (NULL, file); assert (msg); fclose (file); remove ("zmsg.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Remove all frames except first and last int frame_nbr; for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) { zmsg_first (msg); frame = zmsg_next (msg); zmsg_remove (msg, frame); zframe_destroy (&frame); } // Test message frame manipulation assert (zmsg_size (msg) == 2); frame = zmsg_last (msg); assert (zframe_streq (frame, "Frame9")); assert (zmsg_content_size (msg) == 12); frame = zframe_new ("Address", 7); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 3); rc = zmsg_addstr (msg, "Body"); assert (rc == 0); assert (zmsg_size (msg) == 4); frame = zmsg_pop (msg); zframe_destroy (&frame); assert (zmsg_size (msg) == 3); char *body = zmsg_popstr (msg); assert (streq (body, "Frame0")); free (body); zmsg_destroy (&msg); // Test encoding/decoding msg = zmsg_new (); assert (msg); byte *blank = (byte *) zmalloc (100000); assert (blank); rc = zmsg_addmem (msg, blank, 0); assert (rc == 0); rc = zmsg_addmem (msg, blank, 1); assert (rc == 0); rc = zmsg_addmem (msg, blank, 253); assert (rc == 0); rc = zmsg_addmem (msg, blank, 254); assert (rc == 0); rc = zmsg_addmem (msg, blank, 255); assert (rc == 0); rc = zmsg_addmem (msg, blank, 256); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65535); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65536); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65537); assert (rc == 0); free (blank); assert (zmsg_size (msg) == 9); byte *buffer; size_t buffer_size = zmsg_encode (msg, &buffer); zmsg_destroy (&msg); msg = zmsg_decode (buffer, buffer_size); assert (msg); free (buffer); zmsg_destroy (&msg); // Test submessages msg = zmsg_new (); assert (msg); zmsg_t *submsg = zmsg_new (); zmsg_pushstr (msg, "matr"); zmsg_pushstr (submsg, "joska"); rc = zmsg_addmsg (msg, &submsg); assert (rc == 0); assert (submsg == NULL); submsg = zmsg_popmsg (msg); assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded submsg = zmsg_popmsg (msg); assert (submsg); body = zmsg_popstr (submsg); assert (streq (body, "joska")); free (body); zmsg_destroy (&submsg); frame = zmsg_pop (msg); assert (frame == NULL); zmsg_destroy (&msg); // Test comparison of two messages msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); zmsg_addstr (msg, "Three"); zmsg_t *msg_other = zmsg_new (); zmsg_addstr (msg_other, "One"); zmsg_addstr (msg_other, "Two"); zmsg_addstr (msg_other, "One-Hundred"); zmsg_t *msg_dup = zmsg_dup (msg); zmsg_t *empty_msg = zmsg_new (); zmsg_t *empty_msg_2 = zmsg_new (); assert (zmsg_eq (msg, msg_dup)); assert (!zmsg_eq (msg, msg_other)); assert (zmsg_eq (empty_msg, empty_msg_2)); assert (!zmsg_eq (msg, NULL)); assert (!zmsg_eq (NULL, empty_msg)); assert (!zmsg_eq (NULL, NULL)); zmsg_destroy (&msg); zmsg_destroy (&msg_other); zmsg_destroy (&msg_dup); zmsg_destroy (&empty_msg); zmsg_destroy (&empty_msg_2); // Test signal messages msg = zmsg_new_signal (0); assert (zmsg_signal (msg) == 0); zmsg_destroy (&msg); msg = zmsg_new_signal (-1); assert (zmsg_signal (msg) == 255); zmsg_destroy (&msg); // Now try methods on an empty message msg = zmsg_new (); assert (msg); assert (zmsg_size (msg) == 0); assert (zmsg_unwrap (msg) == NULL); assert (zmsg_first (msg) == NULL); assert (zmsg_last (msg) == NULL); assert (zmsg_next (msg) == NULL); assert (zmsg_pop (msg) == NULL); // Sending an empty message is valid and destroys the message assert (zmsg_send (&msg, output) == 0); assert (!msg); zsock_destroy (&input); zsock_destroy (&output); #### zpoller - trivial socket poller class The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll API, for the very common case of reading from a number of sockets. It does not provide polling for output, nor polling on file handles. If you need either of these, use the zmq_poll API directly. Please add @discuss section in ../src/zpoller.c. This is the class interface: // Create new poller; the reader can be a libzmq socket (void *), a zsock_t // instance, or a zactor_t instance. CZMQ_EXPORT zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller CZMQ_EXPORT void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. CZMQ_EXPORT int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The // reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t // instance. CZMQ_EXPORT int zpoller_remove (zpoller_t *self, void *reader); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. CZMQ_EXPORT void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. CZMQ_EXPORT bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. CZMQ_EXPORT bool zpoller_terminated (zpoller_t *self); // Ignore zsys_interrupted flag in this poller. By default, a zpoller_wait will // return immediately if detects zsys_interrupted is set to something other than // zero. Calling zpoller_ignore_interrupts will supress this behavior. CZMQ_EXPORT void zpoller_ignore_interrupts(zpoller_t *self); // Self test of this class CZMQ_EXPORT void zpoller_test (bool verbose); This is the class self test code: // Create a few sockets zsock_t *vent = zsock_new (ZMQ_PUSH); assert (vent); int port_nbr = zsock_bind (vent, "tcp://127.0.0.1:*"); assert (port_nbr != -1); zsock_t *sink = zsock_new (ZMQ_PULL); assert (sink); int rc = zsock_connect (sink, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zsock_t *bowl = zsock_new (ZMQ_PULL); assert (bowl); zsock_t *dish = zsock_new (ZMQ_PULL); assert (dish); // Set-up poller zpoller_t *poller = zpoller_new (bowl, dish, NULL); assert (poller); // Add a reader to the existing poller rc = zpoller_add (poller, sink); assert (rc == 0); zstr_send (vent, "Hello, World"); // We expect a message only on the sink zsock_t *which = (zsock_t *) zpoller_wait (poller, -1); assert (which == sink); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); char *message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); // Stop polling reader rc = zpoller_remove (poller, sink); assert (rc == 0); // Check we can poll an FD rc = zsock_connect (bowl, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); SOCKET fd = zsock_fd (bowl); rc = zpoller_add (poller, (void *) &fd); assert (rc != -1); zstr_send (vent, "Hello again, world"); assert (zpoller_wait (poller, 500) == &fd); // Check whether poller properly ignores zsys_interrupted flag // when asked to zsys_interrupted = 1; zpoller_wait (poller, 0); assert (zpoller_terminated (poller)); zpoller_ignore_interrupts (poller); zpoller_wait (poller, 0); assert (!zpoller_terminated (poller)); zsys_interrupted = 0; // Destroy poller and sockets zpoller_destroy (&poller); zsock_destroy (&vent); zsock_destroy (&sink); zsock_destroy (&bowl); zsock_destroy (&dish); #### zproxy - run a steerable proxy in the background A zproxy actor switches messages between a frontend and a backend socket. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ's facilities, to be somewhat simpler to set-up. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: // Create new zproxy actor instance. The proxy switches messages between // a frontend socket and a backend socket; use the FRONTEND and BACKEND // commands to configure these: // // zactor_t *proxy = zactor_new (zproxy, NULL); // // Destroy zproxy instance. This destroys the two sockets and stops any // message flow between them: // // zactor_destroy (&proxy); // // Note that all zproxy commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity: // // zstr_send (proxy, "VERBOSE"); // zsock_wait (proxy); // // Specify frontend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); // zsock_wait (proxy); // // Specify backend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); // zsock_wait (proxy); // // Capture all proxied messages; these are delivered to the application // via an inproc PULL socket that you have already bound to the specified // endpoint: // // zstr_sendx (proxy, "CAPTURE", endpoint, NULL); // zsock_wait (proxy); // // Pause the proxy. A paused proxy will cease processing messages, causing // them to be queued up and potentially hit the high-water mark on the // frontend or backend socket, causing messages to be dropped, or writing // applications to block: // // zstr_sendx (proxy, "PAUSE", NULL); // zsock_wait (proxy); // // Resume the proxy. Note that the proxy starts automatically as soon as it // has a properly attached frontend and backend socket: // // zstr_sendx (proxy, "RESUME", NULL); // zsock_wait (proxy); // // This is the zproxy constructor as a zactor_fn; the argument is a // character string specifying frontend and backend socket types as two // uppercase strings separated by a hyphen: CZMQ_EXPORT void zproxy (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zproxy_test (bool verbose); This is the class self test code: // Create and configure our proxy zactor_t *proxy = zactor_new (zproxy, NULL); assert (proxy); if (verbose) { zstr_sendx (proxy, "VERBOSE", NULL); zsock_wait (proxy); } zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL); zsock_wait (proxy); // Connect application sockets to proxy zsock_t *faucet = zsock_new_push (">inproc://frontend"); assert (faucet); zsock_t *sink = zsock_new_pull (">inproc://backend"); assert (sink); // Send some messages and check they arrived char *hello, *world; zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test pause/resume functionality zstr_sendx (proxy, "PAUSE", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zsock_set_rcvtimeo (sink, 100); zstr_recvx (sink, &hello, &world, NULL); assert (!hello && !world); zstr_sendx (proxy, "RESUME", NULL); zsock_wait (proxy); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test capture functionality zsock_t *capture = zsock_new_pull ("inproc://capture"); assert (capture); // Switch on capturing, check that it works zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zstr_recvx (capture, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zsock_destroy (&faucet); zsock_destroy (&sink); zsock_destroy (&capture); zactor_destroy (&proxy); #### zrex - work with regular expressions Wraps a very simple regular expression library (SLRE) as a CZMQ class. Supports this syntax: ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ Please add @discuss section in ../src/zrex.c. This is the class interface: // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. CZMQ_EXPORT zrex_t * zrex_new (const char *expression); // Destructor CZMQ_EXPORT void zrex_destroy (zrex_t **self_p); // Return true if the expression was valid and compiled without errors. CZMQ_EXPORT bool zrex_valid (zrex_t *self); // Return the error message generated during compilation of the expression. CZMQ_EXPORT const char * zrex_strerror (zrex_t *self); // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. CZMQ_EXPORT bool zrex_matches (zrex_t *self, const char *text); // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. CZMQ_EXPORT bool zrex_eq (zrex_t *self, const char *text, const char *expression); // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). CZMQ_EXPORT int zrex_hits (zrex_t *self); // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. CZMQ_EXPORT const char * zrex_hit (zrex_t *self, uint index); // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. CZMQ_EXPORT int zrex_fetch (zrex_t *self, const char **string_p, ...); // Self test of this class CZMQ_EXPORT void zrex_test (bool verbose); This is the class self test code: Please add @selftest section in ../src/zrex.c. #### zsock - high-level socket API that hides libzmq contexts and sockets The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *. This is the class interface: // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. CZMQ_EXPORT zsock_t * zsock_new (int type); // Destroy the socket. You must use this for any socket created via the // zsock_new method. CZMQ_EXPORT void zsock_destroy (zsock_t **self_p); // Create a PUB socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_stream (const char *endpoint); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. CZMQ_EXPORT int zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Returns last bound endpoint, if any. CZMQ_EXPORT const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to attach the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). CZMQ_EXPORT int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. CZMQ_EXPORT const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. CZMQ_EXPORT int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. CZMQ_EXPORT int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // p = void ** (stores pointer) // h = zhashx_t ** (creates zhashx) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. CZMQ_EXPORT int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. CZMQ_EXPORT int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. CZMQ_EXPORT int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. Do not modify or destroy the returned // values. Returns 0 if successful, or -1 if it failed to read a message. CZMQ_EXPORT int zsock_brecv (void *self, const char *picture, ...); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. CZMQ_EXPORT void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. CZMQ_EXPORT void zsock_flush (void *self); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. CZMQ_EXPORT bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. CZMQ_EXPORT void * zsock_resolve (void *self); // Self test of this class CZMQ_EXPORT void zsock_test (bool verbose); This is the class self test code: zsock_t *writer = zsock_new_push ("@tcp://127.0.0.1:5560"); assert (writer); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 5560); assert (streq (zsock_endpoint (writer), "tcp://127.0.0.1:5560")); #endif zsock_t *reader = zsock_new_pull (">tcp://127.0.0.1:5560"); assert (reader); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); // Basic Hello, World zstr_send (writer, "Hello, World"); zmsg_t *msg = zmsg_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); free (string); zmsg_destroy (&msg); // Test resolve FD SOCKET fd = zsock_fd (reader); assert (zsock_resolve ((void *) &fd) == NULL); // Test binding to ephemeral ports, sequential and random int port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60050]"); assert (port >= 60000 && port <= 60050); port = zsock_bind (writer, "tcp://127.0.0.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60050]"); assert (port >= 60000 && port <= 60050); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:5556,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == -1); zsock_destroy (&server); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test.writer")); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsock_connect (reader, "txp://127.0.0.1:5560"); assert (rc == -1); // Test signal/wait methods rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); // Test zsock_send/recv pictures uint8_t number1 = 123; uint16_t number2 = 123 * 123; uint32_t number4 = 123 * 123 * 123; uint64_t number8 = 123 * 123 * 123 * 123; zchunk_t *chunk = zchunk_new ("HELLO", 5); assert (chunk); zframe_t *frame = zframe_new ("WORLD", 5); assert (frame); zhashx_t *hash = zhashx_new (); assert (hash); zhashx_autofree (hash); zhashx_insert (hash, "1", "value A"); zhashx_insert (hash, "2", "value B"); char *original = "pointer"; // Test zsock_recv into each supported type zsock_send (writer, "i1248zsbcfhp", -12345, number1, number2, number4, number8, "This is a string", "ABCDE", 5, chunk, frame, hash, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); int integer; byte *data; size_t size; char *pointer; number8 = number4 = number2 = number1 = 0; rc = zsock_recv (reader, "i1248zsbcfhp", &integer, &number1, &number2, &number4, &number8, &string, &data, &size, &chunk, &frame, &hash, &pointer); assert (rc == 0); assert (integer == -12345); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "This is a string")); assert (memcmp (data, "ABCDE", 5) == 0); assert (size == 5); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); assert (memcmp (zframe_data (frame), "WORLD", 5) == 0); assert (zframe_size (frame) == 5); char *value = (char *) zhashx_lookup (hash, "1"); assert (streq (value, "value A")); value = (char *) zhashx_lookup (hash, "2"); assert (streq (value, "value B")); assert (original == pointer); free (string); free (data); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); // Test zsock_recv of short message; this lets us return a failure // with a status code and then nothing else; the receiver will get // the status code and NULL/zero for all other values zsock_send (writer, "i", -1); zsock_recv (reader, "izsbcfp", &integer, &string, &data, &size, &chunk, &frame, &pointer); assert (integer == -1); assert (string == NULL); assert (data == NULL); assert (size == 0); assert (chunk == NULL); assert (frame == NULL); assert (pointer == NULL); msg = zmsg_new (); zmsg_addstr (msg, "frame 1"); zmsg_addstr (msg, "frame 2"); zsock_send (writer, "szm", "header", msg); zmsg_destroy (&msg); zsock_recv (reader, "szm", &string, &msg); assert (streq ("header", string)); assert (zmsg_size (msg) == 2); assert (zframe_streq (zmsg_first (msg), "frame 1")); assert (zframe_streq (zmsg_next (msg), "frame 2")); zstr_free (&string); zmsg_destroy (&msg); // Test zsock_recv with null arguments chunk = zchunk_new ("HELLO", 5); assert (chunk); frame = zframe_new ("WORLD", 5); assert (frame); zsock_send (writer, "izsbcfp", -12345, "This is a string", "ABCDE", 5, chunk, frame, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL); assert (integer == -12345); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); zchunk_destroy (&chunk); // Test zsock_bsend/brecv pictures with binary encoding frame = zframe_new ("Hello", 5); chunk = zchunk_new ("World", 5); msg = zmsg_new (); zmsg_addstr (msg, "Hello"); zmsg_addstr (msg, "World"); zsock_bsend (writer, "1248sSpcfm", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk, frame, msg); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); number8 = number4 = number2 = number1 = 0; char *longstr; zsock_brecv (reader, "1248sSpcfm", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk, &frame, &msg); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); zstr_free (&longstr); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); // Check that we can send a zproto format message zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234); zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_recv (gossip, reader); assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH); zgossip_msg_destroy (&gossip); zsock_destroy (&reader); zsock_destroy (&writer); #### zsock_option - get/set ØMQ socket options The zsock_option class provides access to the ØMQ getsockopt/setsockopt API. All methods in this class take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_r reference, or a libzmq void *. This class is generated, using the GSL code generator. See the sockopts XML file, which provides the metadata, and the sock_option.gsl template, which does the work. This is the class interface: #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsock_tos (void *self); CZMQ_EXPORT char * zsock_zap_domain (void *self); CZMQ_EXPORT int zsock_mechanism (void *self); CZMQ_EXPORT int zsock_plain_server (void *self); CZMQ_EXPORT char * zsock_plain_username (void *self); CZMQ_EXPORT char * zsock_plain_password (void *self); CZMQ_EXPORT int zsock_curve_server (void *self); CZMQ_EXPORT char * zsock_curve_publickey (void *self); CZMQ_EXPORT char * zsock_curve_secretkey (void *self); CZMQ_EXPORT char * zsock_curve_serverkey (void *self); CZMQ_EXPORT int zsock_gssapi_server (void *self); CZMQ_EXPORT int zsock_gssapi_plaintext (void *self); CZMQ_EXPORT char * zsock_gssapi_principal (void *self); CZMQ_EXPORT char * zsock_gssapi_service_principal (void *self); CZMQ_EXPORT int zsock_ipv6 (void *self); CZMQ_EXPORT int zsock_immediate (void *self); CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_tos (void *self, int tos); CZMQ_EXPORT void zsock_set_router_handover (void *self, int router_handover); CZMQ_EXPORT void zsock_set_router_mandatory (void *self, int router_mandatory); CZMQ_EXPORT void zsock_set_probe_router (void *self, int probe_router); CZMQ_EXPORT void zsock_set_req_relaxed (void *self, int req_relaxed); CZMQ_EXPORT void zsock_set_req_correlate (void *self, int req_correlate); CZMQ_EXPORT void zsock_set_conflate (void *self, int conflate); CZMQ_EXPORT void zsock_set_zap_domain (void *self, const char * zap_domain); CZMQ_EXPORT void zsock_set_plain_server (void *self, int plain_server); CZMQ_EXPORT void zsock_set_plain_username (void *self, const char * plain_username); CZMQ_EXPORT void zsock_set_plain_password (void *self, const char * plain_password); CZMQ_EXPORT void zsock_set_curve_server (void *self, int curve_server); CZMQ_EXPORT void zsock_set_curve_publickey (void *self, const char * curve_publickey); CZMQ_EXPORT void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); CZMQ_EXPORT void zsock_set_curve_secretkey (void *self, const char * curve_secretkey); CZMQ_EXPORT void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); CZMQ_EXPORT void zsock_set_curve_serverkey (void *self, const char * curve_serverkey); CZMQ_EXPORT void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); CZMQ_EXPORT void zsock_set_gssapi_server (void *self, int gssapi_server); CZMQ_EXPORT void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); CZMQ_EXPORT void zsock_set_gssapi_principal (void *self, const char * gssapi_principal); CZMQ_EXPORT void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal); CZMQ_EXPORT void zsock_set_ipv6 (void *self, int ipv6); CZMQ_EXPORT void zsock_set_immediate (void *self, int immediate); CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsock_hwm (void *self); CZMQ_EXPORT int zsock_swap (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_recovery_ivl_msec (void *self); CZMQ_EXPORT int zsock_mcast_loop (void *self); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_rcvtimeo (void *self); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_sndtimeo (void *self); # endif CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); // Set socket options CZMQ_EXPORT void zsock_set_hwm (void *self, int hwm); CZMQ_EXPORT void zsock_set_swap (void *self, int swap); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); CZMQ_EXPORT void zsock_set_mcast_loop (void *self, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); # endif CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsock_option_test (bool verbose); This is the class self test code: zsock_t *self; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_tos (self, 1); assert (zsock_tos (self) == 1); zsock_tos (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_HANDOVER) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_handover (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_MANDATORY) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_mandatory (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_PROBE_ROUTER) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_probe_router (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_RELAXED) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_relaxed (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_CORRELATE) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_correlate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONFLATE) self = zsock_new (ZMQ_PUSH); assert (self); zsock_set_conflate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ZAP_DOMAIN) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_zap_domain (self, "test"); char *zap_domain = zsock_zap_domain (self); assert (zap_domain); free (zap_domain); zsock_destroy (&self); # endif # if defined (ZMQ_MECHANISM) self = zsock_new (ZMQ_SUB); assert (self); zsock_mechanism (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_SERVER) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_plain_server (self, 1); assert (zsock_plain_server (self) == 1); zsock_plain_server (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_USERNAME) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_username (self, "test"); char *plain_username = zsock_plain_username (self); assert (plain_username); free (plain_username); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_PASSWORD) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_password (self, "test"); char *plain_password = zsock_plain_password (self); assert (plain_password); free (plain_password); zsock_destroy (&self); # endif # if defined (ZMQ_IPV6) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv6 (self, 1); assert (zsock_ipv6 (self) == 1); zsock_ipv6 (self); zsock_destroy (&self); # endif # if defined (ZMQ_IMMEDIATE) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_immediate (self, 1); assert (zsock_immediate (self) == 1); zsock_immediate (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_hwm (self, 1); assert (zsock_hwm (self) == 1); zsock_hwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_SWAP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_swap (self, 1); assert (zsock_swap (self) == 1); zsock_swap (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl_msec (self, 1); assert (zsock_recovery_ivl_msec (self) == 1); zsock_recovery_ivl_msec (self); zsock_destroy (&self); # endif # if defined (ZMQ_MCAST_LOOP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_mcast_loop (self, 1); assert (zsock_mcast_loop (self) == 1); zsock_mcast_loop (self); zsock_destroy (&self); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif #endif #### zstr - sending and receiving strings The zstr class provides utility functions for sending and receiving C strings across ØMQ sockets. It sends strings without a terminating null, and appends a null byte on received strings. This class is for simple message sending. Memory Wire +-------------+---+ +---+-------------+ Send | S t r i n g | 0 | ----> | 6 | S t r i n g | +-------------+---+ +---+-------------+ Wire Heap +---+-------------+ +-------------+---+ Recv | 6 | S t r i n g | ----> | S t r i n g | 0 | +---+-------------+ +-------------+---+ This is the class interface: // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. CZMQ_EXPORT char * zstr_recv (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". CZMQ_EXPORT int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. CZMQ_EXPORT int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. CZMQ_EXPORT int zstr_sendfm (void *dest, const char *format, ...); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. CZMQ_EXPORT int zstr_sendx (void *dest, const char *string, ...); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. CZMQ_EXPORT int zstr_recvx (void *source, char **string_p, ...); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zstr_free (char **string_p); // Self test of this class CZMQ_EXPORT void zstr_test (bool verbose); This is the class self test code: // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zstr.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zstr.test"); assert (input); // Send ten strings, five strings with MORE flag and then END int string_nbr; for (string_nbr = 0; string_nbr < 10; string_nbr++) zstr_sendf (output, "this is string %d", string_nbr); zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL); // Read and count until we receive END string_nbr = 0; for (string_nbr = 0;; string_nbr++) { char *string = zstr_recv (input); assert (string); if (streq (string, "END")) { zstr_free (&string); break; } zstr_free (&string); } assert (string_nbr == 15); zsock_destroy (&input); zsock_destroy (&output); #### zsys - system-level methods The zsys class provides a portable wrapper for system calls. We collect them here to reduce the number of weird #ifdefs in other classes. As far as possible, the bulk of CZMQ classes are fully portable. Please add @discuss section in ../src/zsys.c. This is the class interface: #define UDP_FRAME_MAX 255 // Max size of UDP frame // Callback for interrupt signal handler typedef void (zsys_handler_fn) (int signal_value); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. CZMQ_EXPORT void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. CZMQ_EXPORT void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. CZMQ_EXPORT zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. CZMQ_EXPORT void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed CZMQ_EXPORT void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_catch_interrupts (void); // Return 1 if file exists, else zero CZMQ_EXPORT bool zsys_file_exists (const char *filename); // Return size of file, or -1 if not found CZMQ_EXPORT ssize_t zsys_file_size (const char *filename); // Return file modification time. Returns 0 if the file does not exist. CZMQ_EXPORT time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. CZMQ_EXPORT int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent CZMQ_EXPORT int zsys_file_delete (const char *filename); // Check if file is 'stable' CZMQ_EXPORT bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as a // printf format. CZMQ_EXPORT int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. CZMQ_EXPORT int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. CZMQ_EXPORT int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. CZMQ_EXPORT void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. CZMQ_EXPORT void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. CZMQ_EXPORT void zsys_version (int *major, int *minor, int *patch); // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. CZMQ_EXPORT char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. CZMQ_EXPORT int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. CZMQ_EXPORT int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. CZMQ_EXPORT bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. CZMQ_EXPORT size_t zsys_socket_limit (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. CZMQ_EXPORT void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. CZMQ_EXPORT size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. CZMQ_EXPORT void zsys_set_ipv6 (int ipv6); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zsys_interface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). CZMQ_EXPORT void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority CZMQ_EXPORT void zsys_error (const char *format, ...); // Log warning condition - high priority CZMQ_EXPORT void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zsys_notice (const char *format, ...); // Log informational message - low priority CZMQ_EXPORT void zsys_info (const char *format, ...); // Log debug-level message - lowest priority CZMQ_EXPORT void zsys_debug (const char *format, ...); // Self test of this class CZMQ_EXPORT void zsys_test (bool verbose); // Global signal indicator, TRUE when user presses Ctrl-C or the process // gets a SIGTERM signal. CZMQ_EXPORT extern volatile int zsys_interrupted; // Deprecated name for this variable CZMQ_EXPORT extern volatile int zctx_interrupted; This is the class self test code: zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); free (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_io_threads (1); zsys_set_max_sockets (0); zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); // Test pipe creation zsock_t *pipe_back; zsock_t *pipe_front = zsys_create_pipe (&pipe_back); zstr_send (pipe_front, "Hello"); char *string = zstr_recv (pipe_back); assert (streq (string, "Hello")); free (string); zsock_destroy (&pipe_back); zsock_destroy (&pipe_front); // Test file manipulation rc = zsys_file_delete ("nosuchfile"); assert (rc == -1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == -1); time_t when = zsys_file_modified ("."); assert (when > 0); int mode = zsys_file_mode ("."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); zsys_file_mode_private (); rc = zsys_dir_create ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); when = zsys_file_modified ("./.testsys/subdir"); assert (when > 0); assert (!zsys_file_stable ("./.testsys/subdir")); rc = zsys_dir_delete ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", ".", ".testsys"); assert (rc == 0); zsys_file_mode_default (); assert (zsys_dir_change (".") == 0); int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); free (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zmq_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); #### zuuid - UUID support class The zuuid class generates UUIDs and provides methods for working with them. If you build CZMQ with libuuid, on Unix/Linux, it will use that library. On Windows it will use UuidCreate(). Otherwise it will use a random number generator to produce convincing imitations of uuids. Please add @discuss section in ../src/zuuid.c. This is the class interface: // Constructor CZMQ_EXPORT zuuid_t * zuuid_new (void); // Destructor CZMQ_EXPORT void zuuid_destroy (zuuid_t **self_p); // Return UUID binary data CZMQ_EXPORT byte * zuuid_data (zuuid_t *self); // Return UUID binary size CZMQ_EXPORT size_t zuuid_size (zuuid_t *self); // Returns UUID as string CZMQ_EXPORT char * zuuid_str (zuuid_t *self); // Return UUID as formatted string in the canonical format 8-4-4-4-12, // lower case. The caller should free the freshly allocated string. // See: http://en.wikipedia.org/wiki/Universally_unique_identifier CZMQ_EXPORT char * zuuid_formatted_str (zuuid_t *self); // Set UUID to new supplied ZUUID_LEN-octet value CZMQ_EXPORT void zuuid_set (zuuid_t *self, byte *source); // Set UUID to new supplied ZUUID_STR_LEN-char string value; // return 0 if OK, else returns -1. CZMQ_EXPORT int zuuid_set_str (zuuid_t *self, const char *source); // Store UUID blob in target array CZMQ_EXPORT void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value CZMQ_EXPORT bool zuuid_eq (zuuid_t *self, byte *compare); // Check if UUID is different from supplied value CZMQ_EXPORT bool zuuid_neq (zuuid_t *self, byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. CZMQ_EXPORT zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class CZMQ_EXPORT void zuuid_test (bool verbose); This is the class self test code: // Simple create/destroy test assert (ZUUID_LEN == 16); assert (ZUUID_STR_LEN == 32); zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == ZUUID_LEN); assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN); zuuid_t *copy = zuuid_dup (uuid); assert (streq (zuuid_str (uuid), zuuid_str (copy))); // Check set/set_str/export methods const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38"; zuuid_set_str (uuid, myuuid); assert (streq (zuuid_str (uuid), myuuid)); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the formatted string output char *formatted_str = zuuid_formatted_str (uuid); assert (streq (formatted_str, "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38")); zstr_free (&formatted_str); zuuid_destroy (&uuid); zuuid_destroy (©); ### API v2 Summary This is the deprecated API provided by CZMQ v2.x, in alphabetical order. #### zauth_v2 - authentication for ZeroMQ servers (deprecated) A zauth object takes over authentication for all incoming connections in its context. This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets. This is the class interface: #ifndef CURVE_ALLOW_ANY # define CURVE_ALLOW_ANY "*" #endif // Constructor // Install authentication for the specified context. Returns a new zauth // object that you can use to configure authentication. Note that until you // add policies, all incoming NULL connections are allowed (classic ZeroMQ // behaviour), and all PLAIN and CURVE connections are denied. If there was // an error during initialization, returns NULL. CZMQ_EXPORT zauth_t * zauth_new (zctx_t *ctx); // Destructor CZMQ_EXPORT void zauth_destroy (zauth_t **self_p); // Allow (whitelist) a single IP address. For NULL, all clients from this // address will be accepted. For PLAIN and CURVE, they will be allowed to // continue with authentication. You can call this method multiple times // to whitelist multiple IP addresses. If you whitelist a single address, // any non-whitelisted addresses are treated as blacklisted. CZMQ_EXPORT void zauth_allow (zauth_t *self, const char *address); // Deny (blacklist) a single IP address. For all security mechanisms, this // rejects the connection without any further authentication. Use either a // whitelist, or a blacklist, not not both. If you define both a whitelist // and a blacklist, only the whitelist takes effect. CZMQ_EXPORT void zauth_deny (zauth_t *self, const char *address); // Configure PLAIN authentication for a given domain. PLAIN authentication // uses a plain-text password file. To cover all domains, use "*". You can // modify the password file at any time; it is reloaded automatically. CZMQ_EXPORT void zauth_configure_plain (zauth_t *self, const char *domain, const char *filename); // Configure CURVE authentication for a given domain. CURVE authentication // uses a directory that holds all public client certificates, i.e. their // public keys. The certificates must be in zcert_save () format. To cover // all domains, use "*". You can add and remove certificates in that // directory at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the location. CZMQ_EXPORT void zauth_configure_curve (zauth_t *self, const char *domain, const char *location); // Configure GSSAPI authentication for a given domain. GSSAPI authentication // uses an underlying mechanism (usually Kerberos) to establish a secure // context and perform mutual authentication. To cover all domains, use "*". CZMQ_EXPORT void zauth_configure_gssapi (zauth_t *self, char *domain); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zauth_set_verbose (zauth_t *self, bool verbose); // Selftest CZMQ_EXPORT void zauth_v2_test (bool verbose); This is the class self test code: // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Install the authenticator zctx_t *ctx = zctx_new (); assert (ctx); zauth_t *auth = zauth_new (ctx); assert (auth); zauth_set_verbose (auth, verbose); // A default NULL connection should always success, and not // go through our authentication infrastructure at all. void *server = zsocket_new (ctx, ZMQ_PUSH); assert (server); void *client = zsocket_new (ctx, ZMQ_PULL); assert (client); bool success = s_can_connect (ctx, &server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsocket_set_zap_domain (server, "global"); success = s_can_connect (ctx, &server, &client); assert (success); // Blacklist 127.0.0.1, connection should fail zsocket_set_zap_domain (server, "global"); zauth_deny (auth, "127.0.0.1"); success = s_can_connect (ctx, &server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsocket_set_zap_domain (server, "global"); zauth_allow (auth, "127.0.0.1"); success = s_can_connect (ctx, &server, &client); assert (success); // Try PLAIN authentication zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); success = s_can_connect (ctx, &server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); zauth_configure_plain (auth, "*", TESTDIR "/password-file"); success = s_can_connect (ctx, &server, &client); assert (success); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Bogus"); success = s_can_connect (ctx, &server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); success = s_can_connect (ctx, &server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zauth_configure_curve (auth, "*", CURVE_ALLOW_ANY); success = s_can_connect (ctx, &server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zauth_configure_curve (auth, "*", TESTDIR); success = s_can_connect (ctx, &server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zauth_destroy (&auth); success = s_can_connect (ctx, &server, &client); assert (success); zctx_destroy (&ctx); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #### zctx - working with ØMQ contexts (deprecated) The zctx class wraps ØMQ 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 (interrupt) handling for the process. The zctx class has these main features: * Tracks all open sockets and automatically closes them before calling zmq_term(). This avoids an infinite wait on open sockets. * Automatically configures sockets with a ZMQ_LINGER timeout you can define, and which defaults to zero. The default behavior of zctx is therefore like ØMQ/2.0, immediate termination with loss of any pending messages. You can set any linger timeout you like by calling the zctx_set_linger() method. * Moves the iothreads configuration to a separate method, so that default usage is 1 I/O thread. Lets you configure this value. * Sets up signal (SIGINT and SIGTERM) handling so that blocking calls such as zmq_recv() and zmq_poll() will return when the user presses Ctrl-C. NOTE: this class is deprecated in favor of zsock, which does not expose contexts in the API at all. All zsock instances use the same global context. This is the class interface: // Create new context, returns context object, replaces zmq_init CZMQ_EXPORT zctx_t * zctx_new (void); // Destroy context and all sockets in it, replaces zmq_term CZMQ_EXPORT void zctx_destroy (zctx_t **self_p); // Create new shadow context, returns context object CZMQ_EXPORT zctx_t * zctx_shadow (zctx_t *self); // Raise default I/O threads from 1, for crazy heavy applications // The rule of thumb is one I/O thread per gigabyte of traffic in // or out. Call this method before creating any sockets on the context, // or calling zctx_shadow, or the setting will have no effect. CZMQ_EXPORT void zctx_set_iothreads (zctx_t *self, int iothreads); // Set msecs to flush sockets when closing them, see the ZMQ_LINGER // man page section for more details. By default, set to zero, so // any in-transit messages are discarded when you destroy a socket or // a context. CZMQ_EXPORT void zctx_set_linger (zctx_t *self, int linger); // Set initial high-water mark for inter-thread pipe sockets. Note that // this setting is separate from the default for normal sockets. You // should change the default for pipe sockets *with care*. Too low values // will cause blocked threads, and an infinite setting can cause memory // exhaustion. The default, no matter the underlying ZeroMQ version, is // 1,000. CZMQ_EXPORT void zctx_set_pipehwm (zctx_t *self, int pipehwm); // Set initial send HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. CZMQ_EXPORT void zctx_set_sndhwm (zctx_t *self, int sndhwm); // Set initial receive HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. CZMQ_EXPORT void zctx_set_rcvhwm (zctx_t *self, int rcvhwm); // Return low-level ØMQ context object, will be NULL before first socket // is created. Use with care. CZMQ_EXPORT void * zctx_underlying (zctx_t *self); // Self test of this class CZMQ_EXPORT void zctx_test (bool verbose); This is the class self test code: // Create and destroy a context without using it zctx_t *ctx = zctx_new (); assert (ctx); zctx_destroy (&ctx); assert (ctx == NULL); // Create a context with many busy sockets, destroy it ctx = zctx_new (); assert (ctx); zctx_set_iothreads (ctx, 1); zctx_set_linger (ctx, 5); // 5 msecs void *s1 = zctx__socket_new (ctx, ZMQ_PAIR); assert (s1); void *s2 = zctx__socket_new (ctx, ZMQ_XREQ); assert (s2); void *s3 = zctx__socket_new (ctx, ZMQ_REQ); assert (s3); void *s4 = zctx__socket_new (ctx, ZMQ_REP); assert (s4); void *s5 = zctx__socket_new (ctx, ZMQ_PUB); assert (s5); void *s6 = zctx__socket_new (ctx, ZMQ_SUB); assert (s6); int rc = zsocket_connect (s1, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s2, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s3, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s4, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s5, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s6, "tcp://127.0.0.1:5555"); assert (rc == 0); assert (zctx_underlying (ctx)); zctx_destroy (&ctx); #### zmonitor_v2 - socket event monitor (deprecated) The zmonitor class provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Currently this class requires libzmq v4.0 or later and is empty on older versions of libzmq. This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zmonitor interface, based on zactor, together with the zsock class for sockets. This is the class interface: // This code needs backporting to work with ZMQ v3.2 #if (ZMQ_VERSION_MAJOR == 4) // Create a new socket monitor CZMQ_EXPORT zmonitor_t * zmonitor_new (zctx_t *ctx, void *socket, int events); // Destroy a socket monitor CZMQ_EXPORT void zmonitor_destroy (zmonitor_t **self_p); // Receive a status message from the monitor; if no message arrives within // 500 msec, or the call was interrupted, returns NULL. CZMQ_EXPORT zmsg_t * zmonitor_recv (zmonitor_t *self); // Get the ZeroMQ socket, for polling CZMQ_EXPORT void * zmonitor_socket (zmonitor_t *self); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zmonitor_set_verbose (zmonitor_t *self, bool verbose); #endif // ZeroMQ 4.0 or later // Self test of this class CZMQ_EXPORT void zmonitor_v2_test (bool verbose); This is the class self test code: zctx_t *ctx = zctx_new (); assert (ctx); bool result; void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); zmonitor_t *sinkmon = zmonitor_new (ctx, sink, ZMQ_EVENT_LISTENING | ZMQ_EVENT_ACCEPTED); assert (sinkmon); zmonitor_set_verbose (sinkmon, verbose); // Check sink is now listening int port_nbr = zsocket_bind (sink, "tcp://127.0.0.1:*"); assert (port_nbr != -1); result = s_check_event (sinkmon, ZMQ_EVENT_LISTENING); assert (result); void *source = zsocket_new (ctx, ZMQ_PUSH); assert (source); zmonitor_t *sourcemon = zmonitor_new (ctx, source, ZMQ_EVENT_CONNECTED | ZMQ_EVENT_DISCONNECTED); assert (sourcemon); zmonitor_set_verbose (sourcemon, verbose); zsocket_connect (source, "tcp://127.0.0.1:%d", port_nbr); // Check source connected to sink result = s_check_event (sourcemon, ZMQ_EVENT_CONNECTED); assert (result); // Check sink accepted connection result = s_check_event (sinkmon, ZMQ_EVENT_ACCEPTED); assert (result); zmonitor_destroy (&sinkmon); zmonitor_destroy (&sourcemon); zctx_destroy (&ctx); #### zmutex - working with mutexes (deprecated) The zmutex class provides a portable wrapper for mutexes. Please do not use this class to do multi-threading. It is for the rare case where you absolutely need thread-safe global state. This should happen in system code only. DO NOT USE THIS TO SHARE SOCKETS BETWEEN THREADS, OR DARK THINGS WILL HAPPEN TO YOUR CODE. Please add @discuss section in ../src/zmutex.c. This is the class interface: // Create a new mutex container CZMQ_EXPORT zmutex_t * zmutex_new (void); // Destroy a mutex container CZMQ_EXPORT void zmutex_destroy (zmutex_t **self_p); // Lock mutex CZMQ_EXPORT void zmutex_lock (zmutex_t *self); // Unlock mutex CZMQ_EXPORT void zmutex_unlock (zmutex_t *self); // Try to lock mutex CZMQ_EXPORT int zmutex_try_lock (zmutex_t *self); // Self test of this class CZMQ_EXPORT void zmutex_test (bool verbose); This is the class self test code: zmutex_t *mutex = zmutex_new (); assert (mutex); zmutex_lock (mutex); zmutex_unlock (mutex); zmutex_destroy (&mutex); #### zproxy_v2 - run a steerable proxy in the background (deprecated) The zproxy class provides an equivalent to the ZMQ steerable proxy, on all versions of ZeroMQ. This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zproxy interface, based on zactor, together with the zsock class for sockets. This is the class interface: // Constructor // Create a new zproxy object. You must create the frontend and backend // sockets, configure them, and connect or bind them, before you pass them // to the constructor. Do NOT use the sockets again, after passing them to // this method. CZMQ_EXPORT zproxy_t * zproxy_new (zctx_t *ctx, void *frontend, void *backend); // Destructor // Destroy a zproxy object; note this first stops the proxy. CZMQ_EXPORT void zproxy_destroy (zproxy_t **self_p); // Copy all proxied messages to specified endpoint; if this is NULL, any // in-progress capturing will be stopped. You must already have bound the // endpoint to a PULL socket. CZMQ_EXPORT void zproxy_capture (zproxy_t *self, const char *endpoint); // Pauses a zproxy object; a paused proxy will cease processing messages, // causing them to be queued up and potentially hit the high-water mark on // the frontend socket, causing messages to be dropped, or writing // applications to block. CZMQ_EXPORT void zproxy_pause (zproxy_t *self); // Resume a zproxy object CZMQ_EXPORT void zproxy_resume (zproxy_t *self); // Self test of this class CZMQ_EXPORT void zproxy_v2_test (bool verbose); This is the class self test code: zctx_t *ctx = zctx_new (); assert (ctx); void *frontend = zsocket_new (ctx, ZMQ_PULL); assert (frontend); int rc = zsocket_bind (frontend, "inproc://frontend"); assert (rc == 0); void *backend = zsocket_new (ctx, ZMQ_PUSH); assert (backend); rc = zsocket_bind (backend, "inproc://backend"); assert (rc == 0); zproxy_t *proxy = zproxy_new (ctx, frontend, backend); assert (proxy); // Connect application sockets to proxy void *faucet = zsocket_new (ctx, ZMQ_PUSH); assert (faucet); rc = zsocket_connect (faucet, "inproc://frontend"); assert (rc == 0); void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); rc = zsocket_connect (sink, "inproc://backend"); assert (rc == 0); // Send some messages and check they arrived zstr_send (faucet, "Hello"); char *string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); // Check pause/resume functionality zproxy_pause (proxy); zstr_send (faucet, "World"); zproxy_resume (proxy); string = zstr_recv (sink); assert (streq (string, "World")); zstr_free (&string); // Create capture socket, must be a PULL socket void *capture = zsocket_new (ctx, ZMQ_PULL); assert (capture); rc = zsocket_bind (capture, "inproc://capture"); assert (rc == 0); // Switch on capturing, check that it works zproxy_capture (proxy, "inproc://capture"); zstr_send (faucet, "Hello"); string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); string = zstr_recv (capture); assert (streq (string, "Hello")); zstr_free (&string); zproxy_destroy (&proxy); zctx_destroy (&ctx); #### zsocket - working with ØMQ sockets (deprecated) The zsocket class provides helper functions for ØMQ sockets. It doesn't wrap the ØMQ socket type, to avoid breaking all libzmq socket-related calls. Please add @discuss section in ../src/zsocket.c. This is the class interface: // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding. #define ZSOCKET_DYNFROM 0xc000 #define ZSOCKET_DYNTO 0xffff // Callback function for zero-copy methods typedef void (zsocket_free_fn) (void *data, void *arg); // Create a new socket within our CZMQ context, replaces zmq_socket. // Use this to get automatic management of the socket at shutdown. // Note: SUB sockets do not automatically subscribe to everything; you // must set filters explicitly. CZMQ_EXPORT void * zsocket_new (zctx_t *self, int type); // Destroy a socket within our CZMQ context, replaces zmq_close. CZMQ_EXPORT void zsocket_destroy (zctx_t *ctx, void *self); // Bind a socket to a formatted endpoint. If the port is specified as // '*', binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO // and returns the actual port number used. Otherwise asserts that the // bind succeeded with the specified port number. Always returns the // port number if successful. CZMQ_EXPORT int zsocket_bind (void *self, const char *format, ...); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsocket_unbind (void *self, const char *format, ...); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsocket_connect (void *self, const char *format, ...); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsocket_disconnect (void *self, const char *format, ...); // Poll for input events on the socket. Returns TRUE if there is input // ready on the socket, else FALSE. CZMQ_EXPORT bool zsocket_poll (void *self, int msecs); // Returns socket type as printable constant string CZMQ_EXPORT const char * zsocket_type_str (void *self); // Send data over a socket as a single message frame. // Accepts these flags: ZFRAME_MORE and ZFRAME_DONTWAIT. // Returns -1 on error, 0 on success CZMQ_EXPORT int zsocket_sendmem (void *self, const void *data, size_t size, int flags); // Send a signal over a socket. A signal is a zero-byte message. // Signals are used primarily between threads, over pipe sockets. // Returns -1 if there was an error sending the signal. CZMQ_EXPORT int zsocket_signal (void *self); // Wait on a signal. Use this to coordinate between threads, over // pipe pairs. Returns -1 on error, 0 on success. CZMQ_EXPORT int zsocket_wait (void *self); // Self test of this class CZMQ_EXPORT void zsocket_test (bool verbose); This is the class self test code: zctx_t *ctx = zctx_new (); assert (ctx); // Create a detached thread, let it run char *interf = "127.0.0.1"; char *domain = "localhost"; int service = 5560; void *writer = zsocket_new (ctx, ZMQ_PUSH); assert (writer); void *reader = zsocket_new (ctx, ZMQ_PULL); assert (reader); assert (streq (zsocket_type_str (writer), "PUSH")); assert (streq (zsocket_type_str (reader), "PULL")); int rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsocket_unbind (writer, "tcp://%s:%d", interf, service); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #endif rc = zsocket_connect (reader, "tcp://%s:%d", domain, service); assert (rc == 0); zstr_send (writer, "HELLO"); char *message = zstr_recv (reader); assert (message); assert (streq (message, "HELLO")); free (message); // Test binding to ports int port = zsocket_bind (writer, "tcp://%s:*", interf); assert (port >= ZSOCKET_DYNFROM && port <= ZSOCKET_DYNTO); assert (zsocket_poll (writer, 100) == false); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsocket_connect (reader, "txp://%s:%d", domain, service); assert (rc == -1); // Test sending frames to socket rc = zsocket_sendmem (writer, "ABC", 3, ZFRAME_MORE); assert (rc == 0); rc = zsocket_sendmem (writer, "DEFG", 4, 0); assert (rc == 0); zframe_t *frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "ABC")); assert (zframe_more (frame)); zframe_destroy (&frame); frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "DEFG")); assert (!zframe_more (frame)); zframe_destroy (&frame); rc = zsocket_signal (writer); assert (rc == 0); rc = zsocket_wait (reader); assert (rc == 0); zsocket_destroy (ctx, reader); zsocket_destroy (ctx, writer); zctx_destroy (&ctx); #### zsockopt - get/set ØMQ socket options (deprecated) The zsockopt class provides access to the ØMQ getsockopt/setsockopt API. This class is generated, using the GSL code generator. See the sockopts XML file, which provides the metadata, and the zsockopt.gsl template, which does the work. This is the class interface: #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsocket_tos (void *zocket); CZMQ_EXPORT char * zsocket_zap_domain (void *zocket); CZMQ_EXPORT int zsocket_mechanism (void *zocket); CZMQ_EXPORT int zsocket_plain_server (void *zocket); CZMQ_EXPORT char * zsocket_plain_username (void *zocket); CZMQ_EXPORT char * zsocket_plain_password (void *zocket); CZMQ_EXPORT int zsocket_curve_server (void *zocket); CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket); CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket); CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket); CZMQ_EXPORT int zsocket_gssapi_server (void *zocket); CZMQ_EXPORT int zsocket_gssapi_plaintext (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_principal (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_service_principal (void *zocket); CZMQ_EXPORT int zsocket_ipv6 (void *zocket); CZMQ_EXPORT int zsocket_immediate (void *zocket); CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_tos (void *zocket, int tos); CZMQ_EXPORT void zsocket_set_router_handover (void *zocket, int router_handover); CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory); CZMQ_EXPORT void zsocket_set_probe_router (void *zocket, int probe_router); CZMQ_EXPORT void zsocket_set_req_relaxed (void *zocket, int req_relaxed); CZMQ_EXPORT void zsocket_set_req_correlate (void *zocket, int req_correlate); CZMQ_EXPORT void zsocket_set_conflate (void *zocket, int conflate); CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain); CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server); CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username); CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password); CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server); CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey); CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey); CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey); CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey); CZMQ_EXPORT void zsocket_set_gssapi_server (void *zocket, int gssapi_server); CZMQ_EXPORT void zsocket_set_gssapi_plaintext (void *zocket, int gssapi_plaintext); CZMQ_EXPORT void zsocket_set_gssapi_principal (void *zocket, const char * gssapi_principal); CZMQ_EXPORT void zsocket_set_gssapi_service_principal (void *zocket, const char * gssapi_service_principal); CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6); CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate); CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsocket_hwm (void *zocket); CZMQ_EXPORT int zsocket_swap (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *zocket); CZMQ_EXPORT int zsocket_mcast_loop (void *zocket); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); # endif CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); CZMQ_EXPORT void zsocket_set_swap (void *zocket, int swap); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec); CZMQ_EXPORT void zsocket_set_mcast_loop (void *zocket, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); # endif CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsockopt_test (bool verbose); This is the class self test code: zctx_t *ctx = zctx_new (); assert (ctx); void *zocket; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_tos (zocket, 1); assert (zsocket_tos (zocket) == 1); zsocket_tos (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_HANDOVER) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_handover (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_MANDATORY) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_mandatory (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PROBE_ROUTER) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_probe_router (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_RELAXED) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_relaxed (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_CORRELATE) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_correlate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_CONFLATE) zocket = zsocket_new (ctx, ZMQ_PUSH); assert (zocket); zsocket_set_conflate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ZAP_DOMAIN) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_zap_domain (zocket, "test"); char *zap_domain = zsocket_zap_domain (zocket); assert (zap_domain); free (zap_domain); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MECHANISM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_mechanism (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_SERVER) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_plain_server (zocket, 1); assert (zsocket_plain_server (zocket) == 1); zsocket_plain_server (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_USERNAME) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_username (zocket, "test"); char *plain_username = zsocket_plain_username (zocket); assert (plain_username); free (plain_username); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_PASSWORD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_password (zocket, "test"); char *plain_password = zsocket_plain_password (zocket); assert (plain_password); free (plain_password); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV6) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv6 (zocket, 1); assert (zsocket_ipv6 (zocket) == 1); zsocket_ipv6 (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IMMEDIATE) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_immediate (zocket, 1); assert (zsocket_immediate (zocket) == 1); zsocket_immediate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_hwm (zocket, 1); assert (zsocket_hwm (zocket) == 1); zsocket_hwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SWAP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_swap (zocket, 1); assert (zsocket_swap (zocket) == 1); zsocket_swap (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl_msec (zocket, 1); assert (zsocket_recovery_ivl_msec (zocket) == 1); zsocket_recovery_ivl_msec (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MCAST_LOOP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_mcast_loop (zocket, 1); assert (zsocket_mcast_loop (zocket) == 1); zsocket_mcast_loop (zocket); zsocket_destroy (ctx, zocket); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif #endif zctx_destroy (&ctx); #### zthread - working with system threads (deprecated) The zthread class wraps OS thread creation. It creates detached threads that look like normal OS threads, or attached threads that share the caller's ØMQ context, and get an inproc pipe to talk back to the parent thread. Detached threads create their own ØMQ contexts as needed. NOTE: this class is deprecated in favor of zactor. We have several use cases for multiple threads. One is to simulate many processes, so we can test ØMQ designs and flows more easily. Another is to create APIs that can send and receive ØMQ messages in the background. zthread solves these two use cases separately, using the zthread_new and zthead_fork methods respectively. These methods wrap the native system calls needed to start threads, so your code can remain fully portable. Detached threads follow the POSIX pthreads API; they accept a void * argument and return a void * result (always NULL in our case). Attached thread receive a void * argument, a zctx_t context, and a pipe socket. The pipe socket is a PAIR socket that is connected back to the caller. When you call zthread_fork, it returns you a PAIR socket that is the other end of this pipe. Thus attached threads can talk back to their parent threads over the pipe. We use this very heavily when making so-called "asynchronous" APIs, which you can see in the Guide examples like 'clone'. To recap some rules about threading: do not share sockets between threads or your code will crash. You can migrate a socket from one thread to a child thread, if you stop using it in the parent thread immediately after creating the child thread. If you want to connect sockets over inproc:// they must share the same ØMQ context, i.e. be attached threads. You should always use zthread_fork to create an attached thread; it is not sufficient to pass a zctx_t structure to a detached thread (this will crash). If you want to communicate over ipc:// or tcp:// you may be sharing the same context, or use separate contexts. Thus, every detached thread usually starts by creating its own zctx_t instance. This is the class interface: // Detached threads follow POSIX pthreads API typedef void *(zthread_detached_fn) (void *args); // Attached threads get context and pipe from parent typedef void (zthread_attached_fn) (void *args, zctx_t *ctx, void *pipe); // Create a detached thread. A detached thread operates autonomously // and is used to simulate a separate process. It gets no ctx, and no // pipe. CZMQ_EXPORT int zthread_new (zthread_detached_fn *thread_fn, void *args); // Create an attached thread. An attached thread gets a ctx and a PAIR // pipe back to its parent. It must monitor its pipe, and exit if the // pipe becomes unreadable. Do not destroy the ctx, the thread does this // automatically when it ends. CZMQ_EXPORT void * zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args); // Self test of this class CZMQ_EXPORT void zthread_test (bool verbose); This is the class self test code: static void * s_test_detached (void *args) { // Create a socket to check it'll be automatically deleted zctx_t *ctx = zctx_new (); assert (ctx); void *push = zsocket_new (ctx, ZMQ_PUSH); assert (push); zctx_destroy (&ctx); return NULL; } static void s_test_attached (void *args, zctx_t *ctx, void *pipe) { // Create a socket to check it'll be automatically deleted zsocket_new (ctx, ZMQ_PUSH); assert (ctx); // Wait for our parent to ping us, and pong back char *ping = zstr_recv (pipe); assert (ping); zstr_free (&ping); zstr_send (pipe, "pong"); } zctx_t *ctx = zctx_new (); assert (ctx); int rc = 0; // Create a detached thread, let it run rc = zthread_new (s_test_detached, NULL); assert (rc == 0); zclock_sleep (100); // Create an attached thread, check it's safely alive void *pipe = zthread_fork (ctx, s_test_attached, NULL); assert (pipe); zstr_send (pipe, "ping"); char *pong = zstr_recv (pipe); assert (pong); assert (streq (pong, "pong")); zstr_free (&pong); // Everything should be cleanly closed now zctx_destroy (&ctx); ## Error Handling The CZMQ policy is to reduce the error flow to 0/-1 where possible. libzmq still does a lot of errno setting. CZMQ does not do that, as it creates a fuzzy API. Things either work as expected, or they fail, and the application's best strategy is usually to assert on non-zero return codes. Some older libraries still return plethora of error codes, to indicate different types of failure. This ironically makes both library and application more likely to be buggy. The reason is simply that it needs more code on both sides of the API, and the more code, the more bugs. The use of black/white error handling fits the CLASS style for APIs where each call is explicit and without side effects of any kind, and where damage is either impossible, or fatal. The one exception is running out of resources (memory, sockets). In that case, there are two strategies that work, for different types of app. One is to assert, to force better sizing of the machine and/or limits such as max connections. Two is to degrade carefully, e.g. refuse new connections, however that is considerably harder to do correctly and probably unrealistic for most developers. Some CZMQ methods used to actually assert, e.g. in zsocket_bind, if the action failed, instead of returning -1. That was just closer to the majority case where the action MUST work, or nothing can continue. However there's a small slice of cases where failure means something positive, and for these cases, such calls return -1 on failure. 99% of calling code simply asserts the return value is not -1. There are a few cases where the return value is overloaded to return -1, 0, or other values. These are somewhat confusing special cases and we aim to eliminate them over time. The overall goal with this strategy is robustness, and absolute minimal and predictable expression in the code. You can see that it works: the CZMQ code is generally very simple and clear, with a few exceptions of places where people have used their old C style (we fix these over time). ## CZMQ Actors The v2 API had a zthread class that let you create "attached threads" connected to their parent by an inproc:// PIPE socket. In v3 this has been simplified and better wrapped as the zactor class. CZMQ actors are in effect threads with a socket interface. A zactor_t instance works like a socket, and the CZMQ classes that deal with sockets (like zmsg and zpoller) all accept zactor_t references as well as zsock_t and libzmq void * socket handles. To write an actor, use this template. Note that your actor is a single function "void myname (zsock_t *pipe, void *args)" function: /* ========================================================================= someclass - some description Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for ØMQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Please take e.g. include/zmonitor.h as basis for your public API. And delete this text, and write your own, when you create an actor :-) @discuss @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller // ... you'll be adding other stuff here bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); self->pipe = pipe; // ... initialize your own state including any other // sockets, which you can add to the poller: self->poller = zpoller_new (self->pipe, NULL); return self; } static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zpoller_destroy (&self->poller); // ... destroy your own state here free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (self->verbose) zsys_info ("zxxx: API command=%s", command); if (streq (command, "VERBOSE")) self->verbose = true; else // An example of a command that the caller would wait for // via a signal, so that the two threads synchronize if (streq (command, "WAIT")) zsock_signal (self->pipe, 0); else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zxxx: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // zxxx() implements the zxxx actor interface void zxxx (zsock_t *pipe, void *args) { self_t *self = s_self_new (pipe); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zxxx_test (bool verbose) { printf (" * zxxx: "); if (verbose) printf ("\n"); // @selftest zactor_t *xxx = zactor_new (zxxx, NULL); assert (xxx); if (verbose) zstr_sendx (xxx, "VERBOSE", NULL); zactor_destroy (&xxx); // @end printf ("OK\n"); } The selftest code shows how to create, talk to, and destroy an actor. ## Under the Hood ### Adding a New Class If you define a new CZMQ class `myclass` you need to: * Write the `zmyclass.c` and `zmyclass.h` source files, in `src` and `include` respectively. * Add`#include ` to `include/czmq.h`. * Add the myclass header and test call to `src/czmq_selftest.c`. * Add a reference documentation to 'doc/zmyclass.txt'. * Add myclass to 'model/projects.xml` and read model/README.txt. * Add a section to README.txt. ### Documentation Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (http://github.com/imatix/gitdown). The header file for a class must wrap its interface as follows (example is from include/zclock.h): // @interface // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds int64_t zclock_time (void); // Self test of this class int zclock_test (Bool verbose); // @end The source file for a class must provide documentation as follows: /* @header ...short explanation of class... @discuss ...longer discussion of how it works... @end */ The source file for a class then provides the self test example as follows: // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); // @end The template for man pages is in doc/mkman. ### Development CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code: * Modify a class or method. * Update the test method for that class. * Run the 'selftest' script, which uses the Valgrind memcheck tool. * Repeat until perfect. ### Porting CZMQ When you try CZMQ 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 non-trivial. 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 `czmq_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 czmq_prelude.h. * Defining macros that rename exotic library functions to more conventional names: do this in czmq_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. ### Hints to Contributors CZMQ is a nice, neat library, and you may not immediately appreciate why. Read the CLASS style guide please, and write your code to make it indistinguishable from the rest of the code in the library. That is the only real criteria for good style: it's invisible. Don't include system headers in source files. The right place for these is czmq_prelude.h. If you need to check against configured libraries and/or headers, include platform.h in the source before including czmq.h. Do read your code after you write it and ask, "Can I make this simpler?" We do use a nice minimalist and yet readable style. Learn it, adopt it, use it. Before opening a pull request read our [contribution guidelines](https://github.com/zeromq/czmq/blob/master/CONTRIBUTING.md). Thanks! ### Code Generation We generate the zsockopt class using [GSL](https://github.com/imatix/gsl), using a code generator script in scripts/sockopts.gsl. We also generate the project files. ### This Document This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown). czmq-3.0.2/INSTALL0000644000175000017500000003660012240203010012604 0ustar00phph00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. czmq-3.0.2/CONTRIBUTING.md0000664000175000017500000000277712505070716014041 0ustar00phph00000000000000# Contributing to CZMQ The contributors are listed in AUTHORS (add yourself). This project uses the MPL v2 license, see LICENSE. Please read these documents BEFORE you send a patch: * CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. Please read this if you are unfamiliar with it. * CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/spec:21) guide for code style. Please read this, and also read the existing code base. CZMQ grows by the slow and careful accretion of simple, minimal solutions to real problems faced by many people. Some people seem to not understand this. So in case of doubt: * Each patch defines one clear and agreed problem, and one clear, minimal, plausible solution. If you come with a large, complex problem and a large, complex solution, you will provoke a negative reaction from CZMQ maintainers and users. * We will usually merge patches aggressively, without a blocking review. If you send us bad patches, without taking the care to read and understand our rules, that reflects on you. Do NOT expect us to do your homework for you. * As rapidly we will merge poor quality patches, we will remove them again. If you insist on arguing about this and trying to justify your changes, we will simply ignore you and your patches. If you still insist, we will ban you. * CZMQ is not a sandbox where "anything goes until the next stable release". If you want to experiment, please work in your own projects. czmq-3.0.2/aclocal.m40000664000175000017500000013071612535241734013446 0ustar00phph00000000000000# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_COND_IF -*- Autoconf -*- # Copyright (C) 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_COND_IF # _AM_COND_ELSE # _AM_COND_ENDIF # -------------- # These macros are only used for tracing. m4_define([_AM_COND_IF]) m4_define([_AM_COND_ELSE]) m4_define([_AM_COND_ENDIF]) # AM_COND_IF(COND, [IF-TRUE], [IF-FALSE]) # --------------------------------------- # If the shell condition COND is true, execute IF-TRUE, otherwise execute # IF-FALSE. Allow automake to learn about conditional instantiating macros # (the AC_CONFIG_FOOS). AC_DEFUN([AM_COND_IF], [m4_ifndef([_AM_COND_VALUE_$1], [m4_fatal([$0: no such condition "$1"])])dnl _AM_COND_IF([$1])dnl if test -z "$$1_TRUE"; then : m4_n([$2])[]dnl m4_ifval([$3], [_AM_COND_ELSE([$1])dnl else $3 ])dnl _AM_COND_ENDIF([$1])dnl fi[]dnl ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2009, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # (`yes' being less verbose, `no' or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [ --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0')]) case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few `make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using `$V' instead of `$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([config/libtool.m4]) m4_include([config/ltoptions.m4]) m4_include([config/ltsugar.m4]) m4_include([config/ltversion.m4]) m4_include([config/lt~obsolete.m4]) czmq-3.0.2/src/0000775000175000017500000000000012535242314012360 5ustar00phph00000000000000czmq-3.0.2/src/zproxy.c0000664000175000017500000002340612515173670014112 0ustar00phph00000000000000/* ========================================================================= zproxy - run a steerable proxy in the background Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header A zproxy actor switches messages between a frontend and a backend socket. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ's facilities, to be somewhat simpler to set-up. @discuss This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller zsock_t *frontend; // Frontend socket zsock_t *backend; // Backend socket zsock_t *capture; // Capture socket bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zsock_destroy (&self->frontend); zsock_destroy (&self->backend); zsock_destroy (&self->capture); zpoller_destroy (&self->poller); free (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); if (self) { self->pipe = pipe; self->poller = zpoller_new (self->pipe, NULL); if (!self->poller) s_self_destroy (&self); } return self; } static zsock_t * s_create_socket (char *type_name, char *endpoints) { // This array matches ZMQ_XXX type definitions assert (ZMQ_PAIR == 0); char *type_names [] = { "PAIR", "PUB", "SUB", "REQ", "REP", "DEALER", "ROUTER", "PULL", "PUSH", "XPUB", "XSUB", type_name }; // We always match type at least at end of table int index; for (index = 0; strneq (type_name, type_names [index]); index++) ; if (index > ZMQ_XSUB) { zsys_error ("zproxy: invalid socket type '%s'", type_name); return NULL; } zsock_t *sock = zsock_new (index); if (sock) { if (zsock_attach (sock, endpoints, true)) { zsys_error ("zproxy: invalid endpoints '%s'", endpoints); zsock_destroy (&sock); } } return sock; } static void s_self_configure (self_t *self, zsock_t **sock_p, zmsg_t *request, char *name) { char *type_name = zmsg_popstr (request); assert (type_name); char *endpoints = zmsg_popstr (request); assert (endpoints); if (self->verbose) zsys_info ("zproxy: - %s type=%s attach=%s", name, type_name, endpoints); assert (*sock_p == NULL); *sock_p = s_create_socket (type_name, endpoints); assert (*sock_p); zpoller_add (self->poller, *sock_p); zstr_free (&type_name); zstr_free (&endpoints); } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); assert (command); if (self->verbose) zsys_info ("zproxy: API command=%s", command); if (streq (command, "FRONTEND")) { s_self_configure (self, &self->frontend, request, "frontend"); zsock_signal (self->pipe, 0); } else if (streq (command, "BACKEND")) { s_self_configure (self, &self->backend, request, "backend"); zsock_signal (self->pipe, 0); } else if (streq (command, "CAPTURE")) { self->capture = zsock_new (ZMQ_PUSH); assert (self->capture); char *endpoint = zmsg_popstr (request); assert (endpoint); int rc = zsock_connect (self->capture, "%s", endpoint); assert (rc == 0); zstr_free (&endpoint); zsock_signal (self->pipe, 0); } else if (streq (command, "PAUSE")) { zpoller_destroy (&self->poller); self->poller = zpoller_new (self->pipe, NULL); assert (self->poller); zsock_signal (self->pipe, 0); } else if (streq (command, "RESUME")) { zpoller_destroy (&self->poller); self->poller = zpoller_new (self->pipe, self->frontend, self->backend, NULL); assert (self->poller); zsock_signal (self->pipe, 0); } else if (streq (command, "VERBOSE")) { self->verbose = true; zsock_signal (self->pipe, 0); } else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zproxy: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // Switch messages from an input socket to an output socket until there are // no messages left waiting. We use this loop rather than zmq_poll, to reduce // the cost of polling, which is non-trivial on some boxes (OS/X, mainly). static void s_self_switch (self_t *self, zsock_t *input, zsock_t *output) { // We use the low-level libzmq API for best performance void *zmq_input = zsock_resolve (input); void *zmq_output = zsock_resolve (output); void *zmq_capture = self->capture? zsock_resolve (self->capture): NULL; zmq_msg_t msg; zmq_msg_init (&msg); while (true) { if (zmq_recvmsg (zmq_input, &msg, ZMQ_DONTWAIT) == -1) break; // Presumably EAGAIN int send_flags = zsock_rcvmore (zmq_input)? ZMQ_SNDMORE: 0; if (zmq_capture) { zmq_msg_t dup; zmq_msg_init (&dup); zmq_msg_copy (&dup, &msg); if (zmq_sendmsg (zmq_capture, &dup, send_flags) == -1) zmq_msg_close (&dup); } if (zmq_sendmsg (zmq_output, &msg, send_flags) == -1) { zmq_msg_close (&msg); break; } } } // -------------------------------------------------------------------------- // zproxy() implements the zproxy actor interface void zproxy (zsock_t *pipe, void *unused) { self_t *self = s_self_new (pipe); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (zpoller_terminated (self->poller)) break; // Interrupted else if (which == self->pipe) s_self_handle_pipe (self); else if (which == self->frontend) s_self_switch (self, self->frontend, self->backend); else if (which == self->backend) s_self_switch (self, self->backend, self->frontend); } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zproxy_test (bool verbose) { printf (" * zproxy: "); if (verbose) printf ("\n"); // @selftest // Create and configure our proxy zactor_t *proxy = zactor_new (zproxy, NULL); assert (proxy); if (verbose) { zstr_sendx (proxy, "VERBOSE", NULL); zsock_wait (proxy); } zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL); zsock_wait (proxy); // Connect application sockets to proxy zsock_t *faucet = zsock_new_push (">inproc://frontend"); assert (faucet); zsock_t *sink = zsock_new_pull (">inproc://backend"); assert (sink); // Send some messages and check they arrived char *hello, *world; zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test pause/resume functionality zstr_sendx (proxy, "PAUSE", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zsock_set_rcvtimeo (sink, 100); zstr_recvx (sink, &hello, &world, NULL); assert (!hello && !world); zstr_sendx (proxy, "RESUME", NULL); zsock_wait (proxy); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test capture functionality zsock_t *capture = zsock_new_pull ("inproc://capture"); assert (capture); // Switch on capturing, check that it works zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zstr_recvx (capture, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zsock_destroy (&faucet); zsock_destroy (&sink); zsock_destroy (&capture); zactor_destroy (&proxy); // @end printf ("OK\n"); } czmq-3.0.2/src/zfile.c0000664000175000017500000004772012522736135013654 0ustar00phph00000000000000/* ========================================================================= zfile - provides methods to work with files in a portable fashion. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zfile class provides methods to work with disk files. A file object provides the modified date, current size, and type of the file. You can create a file object for a filename that does not yet exist. To read or write data from the file, use the input and output methods, and then read and write chunks. The output method lets you both read and write chunks, at any offset. Finally, this class provides portable symbolic links. If a filename ends in ".ln", the first line of text in the file is read, and used as the underlying file for read/write operations. This lets you manipulate (e.g.) copy symbolic links without copying the perhaps very large files they point to. @discuss This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now). @end */ #include "../include/czmq.h" // Structure of our class struct _zfile_t { // Properties for all file objects char *fullname; // File name with path char *link; // Optional linked file bool exists; // true if file exists bool stable; // true if file is stable bool eof; // true if at end of file FILE *handle; // Read/write handle zdigest_t *digest; // File digest, if known char *curline; // Last read line, if any size_t linemax; // Size of allocated buffer // Properties from files that exist on file system time_t modified; // Modification time off_t cursize; // Size of the file mode_t mode; // POSIX permission bits }; // -------------------------------------------------------------------------- // Constructor // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. zfile_t * zfile_new (const char *path, const char *name) { zfile_t *self = (zfile_t *) zmalloc (sizeof (zfile_t)); if (self) { // Format full path to file if (path) { self->fullname = (char *) zmalloc (strlen (path) + strlen (name) + 2); if (self->fullname) sprintf (self->fullname, "%s/%s", path, name); else { zfile_destroy (&self); return NULL; } } else self->fullname = strdup (name); if (self->fullname) { // Resolve symbolic link if possible if (strlen (self->fullname) > 3 && streq (self->fullname + strlen (self->fullname) - 3, ".ln")) { FILE *handle = fopen (self->fullname, "r"); if (handle) { char buffer [256]; if (fgets (buffer, 256, handle)) { // We have the contents of the symbolic link if (buffer [strlen (buffer) - 1] == '\n') buffer [strlen (buffer) - 1] = 0; self->link = strdup (buffer); // Chop ".ln" off name for external use if (self->link) self->fullname [strlen (self->fullname) - 3] = 0; else { fclose (handle); zfile_destroy (&self); return NULL; } } fclose (handle); } } zfile_restat (self); } else zfile_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Destroy a file item void zfile_destroy (zfile_t **self_p) { assert (self_p); if (*self_p) { zfile_t *self = *self_p; zdigest_destroy (&self->digest); if (self->handle) fclose (self->handle); free (self->fullname); free (self->curline); free (self->link); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. zfile_t * zfile_dup (zfile_t *self) { if (self) { zfile_t *copy = (zfile_t *) zmalloc (sizeof (zfile_t)); if (copy) copy->fullname = strdup (self->fullname); if (copy->fullname) { copy->modified = self->modified; copy->cursize = self->cursize; copy->link = self->link? strdup (self->link): NULL; copy->mode = self->mode; } else zfile_destroy (©); return copy; } else return NULL; } // -------------------------------------------------------------------------- // Return file name, remove path if provided const char * zfile_filename (zfile_t *self, const char *path) { assert (self); char *name = self->fullname; if (path && strlen (self->fullname) >= strlen (path) && memcmp (self->fullname, path, strlen (path)) == 0) { name += strlen (path); if (*name == '/') name++; } return name; } // -------------------------------------------------------------------------- // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void zfile_restat (zfile_t *self) { assert (self); struct stat stat_buf; char *real_name = self->link? self->link: self->fullname; if (stat (real_name, &stat_buf) == 0) { self->cursize = stat_buf.st_size; self->modified = stat_buf.st_mtime; self->mode = zsys_file_mode (real_name); self->stable = zsys_file_stable (real_name); } else { self->cursize = 0; self->modified = 0; self->mode = 0; self->stable = false; } zdigest_destroy (&self->digest); } // -------------------------------------------------------------------------- // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t zfile_modified (zfile_t *self) { assert (self); return self->modified; } // -------------------------------------------------------------------------- // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t zfile_cursize (zfile_t *self) { assert (self); return self->cursize; } // -------------------------------------------------------------------------- // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_directory (zfile_t *self) { assert (self); return S_ISDIR (self->mode); } // -------------------------------------------------------------------------- // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_regular (zfile_t *self) { assert (self); return S_ISREG (self->mode); } // -------------------------------------------------------------------------- // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_readable (zfile_t *self) { assert (self); return (self->mode & S_IRUSR) != 0; } // -------------------------------------------------------------------------- // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_writeable (zfile_t *self) { assert (self); return (self->mode & S_IWUSR) != 0; } // -------------------------------------------------------------------------- // Check if file has stopped changing and can be safely processed. // If you want this to reflect the current situation, call zfile_restat // before checking this property. bool zfile_is_stable (zfile_t *self) { assert (self); return self->stable; } // -------------------------------------------------------------------------- // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. Note that the // file will not necessarily yet be stable. bool zfile_has_changed (zfile_t *self) { assert (self); struct stat stat_buf; char *real_name = self->link? self->link: self->fullname; if (stat (real_name, &stat_buf) == 0) { // It's not a foolproof heuristic but catches most cases if (stat_buf.st_mtime != self->modified || stat_buf.st_size != self->cursize) return true; } return false; } // -------------------------------------------------------------------------- // Remove the file void zfile_remove (zfile_t *self) { assert (self); // Restore ".ln" in file name if this was a symbolic link if (self->link) self->fullname [strlen (self->fullname)] = '.'; zfile_close (self); zsys_file_delete (self->fullname); } // -------------------------------------------------------------------------- // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int zfile_input (zfile_t *self) { assert (self); if (self->handle) zfile_close (self); char *real_name = self->link? self->link: self->fullname; self->handle = fopen (real_name, "rb"); if (self->handle) { struct stat stat_buf; if (stat (real_name, &stat_buf) == 0) self->cursize = stat_buf.st_size; else self->cursize = 0; } return self->handle? 0: -1; } // -------------------------------------------------------------------------- // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int zfile_output (zfile_t *self) { int rc; assert (self); // Create file path if it doesn't exist char *file_path = strdup (self->fullname); if (!file_path) return -1; char *last_slash = strrchr (file_path, '/'); if (last_slash) *last_slash = 0; // Wipe symbolic link if that's what the file was if (self->link) { free (self->link); self->link = NULL; } rc = zsys_dir_create (file_path); free (file_path); if (rc != 0) return -1; // Create file if it doesn't exist if (self->handle) zfile_close (self); self->handle = fopen (self->fullname, "r+b"); if (!self->handle) self->handle = fopen (self->fullname, "w+b"); return self->handle? 0: -1; } // -------------------------------------------------------------------------- // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset) { assert (self); assert (self->handle); // Calculate real number of bytes to read if (offset > self->cursize) bytes = 0; else if (bytes > (size_t) (self->cursize - offset)) bytes = (size_t) (self->cursize - offset); if (fseek (self->handle, (long) offset, SEEK_SET) == -1) return NULL; self->eof = false; zchunk_t *chunk = zchunk_read (self->handle, bytes); if (chunk) self->eof = zchunk_size (chunk) < bytes; return chunk; } // -------------------------------------------------------------------------- // Returns the eof property. bool zfile_eof (zfile_t *self) { assert (self); return self->eof; } // -------------------------------------------------------------------------- // Write chunk to file at specified position // Return 0 if OK, else -1 int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset) { assert (self); assert (self->handle); int rc = fseek (self->handle, (long) offset, SEEK_SET); if (rc >= 0) rc = zchunk_write (chunk, self->handle); return rc; } // -------------------------------------------------------------------------- // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const char * zfile_readln (zfile_t *self) { assert (self); assert (self->handle); // Opportunistically allocate line buffer if needed; we'll grow this // if needed, so the initial linemax is not a big deal if (!self->curline) { self->linemax = 512; self->curline = (char *) malloc (self->linemax); } uint char_nbr = 0; while (true) { int cur_char = fgetc (self->handle); if (cur_char == '\r') continue; // Skip CR in MS-DOS format files else if (cur_char == EOF && char_nbr == 0) return NULL; // Signal end of file else if (cur_char == '\n' || cur_char == EOF) cur_char = 0; if (char_nbr == self->linemax - 1) { self->linemax *= 2; self->curline = (char *) realloc (self->curline, self->linemax); } self->curline [char_nbr++] = cur_char; if (cur_char == 0) break; } return self->curline; } // -------------------------------------------------------------------------- // Close file, if open void zfile_close (zfile_t *self) { assert (self); if (self->handle) { fclose (self->handle); zfile_restat (self); self->handle = 0; self->eof = false; } } // -------------------------------------------------------------------------- // Return file handle, if opened FILE * zfile_handle (zfile_t *self) { assert (self); return self->handle; } // -------------------------------------------------------------------------- // Calculate SHA1 digest for file, using zdigest class. const char * zfile_digest (zfile_t *self) { assert (self); if (!self->digest) { if (zfile_input (self) == -1) return NULL; // Problem reading file // Now calculate hash for file data, chunk by chunk size_t blocksz = 65535; off_t offset = 0; self->digest = zdigest_new (); if (!self->digest) return NULL; zchunk_t *chunk = zfile_read (self, blocksz, offset); while (zchunk_size (chunk)) { zdigest_update (self->digest, zchunk_data (chunk), zchunk_size (chunk)); zchunk_destroy (&chunk); // off_t is defined as long (32 bit on Windows, 64 bit otherwise) // This guards against overflow in both contexts. if (blocksz > LONG_MAX - offset) return NULL; offset += (off_t) blocksz; chunk = zfile_read (self, blocksz, offset); } zchunk_destroy (&chunk); fclose (self->handle); self->handle = 0; } return zdigest_string (self->digest); } // Deprecated API, moved to zsys class. The zfile class works with // an object instance, which is more consistent with the CLASS style // and lets us do more interesting things. These functions were // essentially about portability, so now sit in zsys. bool zfile_exists (const char *filename) { return zsys_file_exists (filename); } ssize_t zfile_size (const char *filename) { return zsys_file_size (filename); } mode_t zfile_mode (const char *filename) { return zsys_file_mode (filename); } int zfile_delete (const char *filename) { return zsys_file_delete (filename); } bool zfile_stable (const char *filename) { return zsys_file_stable (filename); } int zfile_mkdir (const char *pathname) { return zsys_dir_create (pathname); } int zfile_rmdir (const char *pathname) { return zsys_dir_delete (pathname); } void zfile_mode_private (void) { zsys_file_mode_private (); } void zfile_mode_default (void) { zsys_file_mode_default (); } // -------------------------------------------------------------------------- // Self test of this class void zfile_test (bool verbose) { printf (" * zfile: "); // @selftest zfile_t *file = zfile_new (NULL, "bilbo"); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (zfile_is_readable (file) == false); zfile_destroy (&file); // Create a test file in some random subdirectory file = zfile_new ("./this/is/a/test", "bilbo"); assert (file); int rc = zfile_output (file); assert (rc == 0); zchunk_t *chunk = zchunk_new (NULL, 100); assert (chunk); zchunk_fill (chunk, 0, 100); // Write 100 bytes at position 1,000,000 in the file rc = zfile_write (file, chunk, 1000000); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_is_readable (file)); assert (zfile_cursize (file) == 1000100); assert (!zfile_is_stable (file)); assert (zfile_digest (file)); // Now truncate file from outside int handle = open ("./this/is/a/test/bilbo", O_WRONLY | O_TRUNC | O_BINARY, 0); assert (handle >= 0); rc = write (handle, "Hello, World\n", 13); assert (rc == 13); close (handle); assert (zfile_has_changed (file)); zclock_sleep (1001); assert (zfile_has_changed (file)); assert (!zfile_is_stable (file)); zfile_restat (file); assert (zfile_is_stable (file)); assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54")); // Check we can read from file rc = zfile_input (file); assert (rc == 0); chunk = zfile_read (file, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_close (file); // Check we can read lines from file rc = zfile_input (file); assert (rc == 0); const char *line = zfile_readln (file); assert (streq (line, "Hello, World")); line = zfile_readln (file); assert (line == NULL); zfile_close (file); // Try some fun with symbolic links zfile_t *link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_output (link); assert (rc == 0); fprintf (zfile_handle (link), "./this/is/a/test/bilbo\n"); zfile_destroy (&link); link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_input (link); assert (rc == 0); chunk = zfile_read (link, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_destroy (&link); // Remove file and directory zdir_t *dir = zdir_new ("./this", NULL); assert (dir); assert (zdir_cursize (dir) == 26); zdir_remove (dir, true); assert (zdir_cursize (dir) == 0); zdir_destroy (&dir); // Check we can no longer read from file assert (zfile_is_readable (file)); zfile_restat (file); assert (!zfile_is_readable (file)); rc = zfile_input (file); assert (rc == -1); zfile_destroy (&file); // @end printf ("OK\n"); } czmq-3.0.2/src/zdir.c0000664000175000017500000007523512522736135013515 0ustar00phph00000000000000/* ========================================================================= zdir - work with file-system directories ------------------------------------------------------------------------- Copyright (c) 1991-2014 iMatix Corporation Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.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 MERCHANTA- BILITY 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/. =========================================================================*/ /* @header The zdir class gives access to the file system index. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure. It exists mainly to wrap non-portable OS functions to do this. @discuss @end */ #include "../include/czmq.h" // Structure of our class struct _zdir_t { char *path; // Directory name + separator zlist_t *files; // List of files in directory zlist_t *subdirs; // List of subdirectories time_t modified; // Most recent file including subdirs off_t cursize; // Total file size including subdirs size_t count; // Total file count including subdirs bool trimmed; // Load only top level directory }; #if (defined (WIN32)) static void s_win32_populate_entry (zdir_t *self, WIN32_FIND_DATAA *entry) { if (entry->cFileName [0] == '.') ; // Skip hidden files else // If we have a subdirectory, go load that if (entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (!self->trimmed) { zdir_t *subdir = zdir_new (entry->cFileName, self->path); zlist_append (self->subdirs, subdir); } } else { // Add file entry to directory list zfile_t *file = zfile_new (self->path, entry->cFileName); assert (file); zlist_append (self->files, file); } } #else static void s_posix_populate_entry (zdir_t *self, struct dirent *entry) { // Skip . and .. if (streq (entry->d_name, ".") || streq (entry->d_name, "..")) return; char fullpath [1024 + 1]; snprintf (fullpath, 1024, "%s/%s", self->path, entry->d_name); struct stat stat_buf; if (stat (fullpath, &stat_buf)) return; if (entry->d_name [0] == '.') ; // Skip hidden files else // If we have a subdirectory, go load that if (S_ISDIR (stat_buf.st_mode)) { if (!self->trimmed) { zdir_t *subdir = zdir_new (entry->d_name, self->path); assert (subdir); zlist_append (self->subdirs, subdir); } } else { // Add file entry to directory list zfile_t *file = zfile_new (self->path, entry->d_name); assert (file); zlist_append (self->files, file); } } #endif // -------------------------------------------------------------------------- // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. zdir_t * zdir_new (const char *path, const char *parent) { zdir_t *self = (zdir_t *) zmalloc (sizeof (zdir_t)); if (!self) return NULL; if (parent) { if (streq (parent, "-")) { self->trimmed = true; self->path = strdup (path); if (!self->path) { zdir_destroy (&self); return NULL; } } else { self->path = (char *) zmalloc (strlen (path) + strlen (parent) + 2); if (self->path) sprintf (self->path, "%s/%s", parent, path); else { zdir_destroy (&self); return NULL; } } } else { self->path = strdup (path); if (!self->path) { zdir_destroy (&self); return NULL; } } if (self->path) self->files = zlist_new (); if (self->files) self->subdirs = zlist_new (); if (!self->subdirs) { zdir_destroy (&self); return NULL; } #if (defined (WIN32)) // On Windows, replace backslashes by normal slashes char *path_clean_ptr = self->path; while (*path_clean_ptr) { if (*path_clean_ptr == '\\') *path_clean_ptr = '/'; path_clean_ptr++; } // Remove any trailing slash if (self->path [strlen (self->path) - 1] == '/') self->path [strlen (self->path) - 1] = 0; // Win32 wants a wildcard at the end of the path char *wildcard = (char *) zmalloc (strlen (self->path) + 3); if (!wildcard) { zdir_destroy (&self); return NULL; } sprintf (wildcard, "%s/*", self->path); WIN32_FIND_DATAA entry; HANDLE handle = FindFirstFileA (wildcard, &entry); free (wildcard); if (handle != INVALID_HANDLE_VALUE) { // We have read an entry, so return those values s_win32_populate_entry (self, &entry); while (FindNextFileA (handle, &entry)) s_win32_populate_entry (self, &entry); FindClose (handle); } #else // Remove any trailing slash if (self->path [strlen (self->path) - 1] == '/') self->path [strlen (self->path) - 1] = 0; DIR *handle = opendir (self->path); if (handle) { // Calculate system-specific size of dirent block int dirent_size = offsetof (struct dirent, d_name) + pathconf (self->path, _PC_NAME_MAX) + 1; struct dirent *entry = (struct dirent *) zmalloc (dirent_size); if (!entry) { zdir_destroy (&self); return NULL; } struct dirent *result; int rc = readdir_r (handle, entry, &result); while (rc == 0 && result != NULL) { s_posix_populate_entry (self, entry); rc = readdir_r (handle, entry, &result); } free (entry); closedir (handle); } #endif else { zdir_destroy (&self); return NULL; } // Update directory signatures zdir_t *subdir = (zdir_t *) zlist_first (self->subdirs); while (subdir) { if (self->modified < subdir->modified) self->modified = subdir->modified; self->cursize += subdir->cursize; self->count += subdir->count; subdir = (zdir_t *) zlist_next (self->subdirs); } zfile_t *file = (zfile_t *) zlist_first (self->files); while (file) { if (self->modified < zfile_modified (file)) self->modified = zfile_modified (file); self->cursize += zfile_cursize (file); self->count += 1; file = (zfile_t *) zlist_next (self->files); } return self; } // -------------------------------------------------------------------------- // Destroy a directory item void zdir_destroy (zdir_t **self_p) { assert (self_p); if (*self_p) { zdir_t *self = *self_p; if (self->subdirs) while (zlist_size (self->subdirs)) { zdir_t *subdir = (zdir_t *) zlist_pop (self->subdirs); zdir_destroy (&subdir); } if (self->files) while (zlist_size (self->files)) { zfile_t *file = (zfile_t *) zlist_pop (self->files); zfile_destroy (&file); } zlist_destroy (&self->subdirs); zlist_destroy (&self->files); free (self->path); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return directory path const char * zdir_path (zdir_t *self) { return self->path; } // -------------------------------------------------------------------------- // Return last modification time for directory. time_t zdir_modified (zdir_t *self) { assert (self); return self->modified; } // -------------------------------------------------------------------------- // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t zdir_cursize (zdir_t *self) { assert (self); return self->cursize; } // -------------------------------------------------------------------------- // Return directory count size_t zdir_count (zdir_t *self) { assert (self); return self->count; } // -------------------------------------------------------------------------- // Returns a sorted array of zfile objects; returns a single block of memory, // that you destroy by calling zdir_flatten_free(). Each entry in the array // is a pointer to a zfile_t item already allocated in the zdir tree. The // array ends with a null pointer. Do not destroy the original zdir tree // until you are done with this array. static int s_dir_flatten (zdir_t *self, zfile_t **files, int index); static int s_dir_compare (void *item1, void *item2); static int s_file_compare (void *item1, void *item2); zfile_t ** zdir_flatten (zdir_t *self) { size_t flat_size; if (self) flat_size = self->count + 1; else flat_size = 1; // Just null terminator zfile_t **files = (zfile_t **) zmalloc (sizeof (zfile_t *) * flat_size); uint index = 0; if (self) index = s_dir_flatten (self, files, index); return files; } // Flatten one directory, calls itself recursively static int s_dir_flatten (zdir_t *self, zfile_t **files, int index) { // First flatten the normal files zlist_sort (self->files, s_file_compare); zfile_t *file = (zfile_t *) zlist_first (self->files); while (file) { files [index++] = file; file = (zfile_t *) zlist_next (self->files); } // Now flatten subdirectories, recursively zlist_sort (self->subdirs, s_dir_compare); zdir_t *subdir = (zdir_t *) zlist_first (self->subdirs); while (subdir) { index = s_dir_flatten (subdir, files, index); subdir = (zdir_t *) zlist_next (self->subdirs); } return index; } // Compare two subdirs, true if they need swapping static int s_dir_compare (void *item1, void *item2) { assert (item1); assert (item2); return strcmp (zdir_path ((zdir_t *) item1), zdir_path ((zdir_t *) item2)); } // Compare two files, true if they need swapping. We sort by ascending name. static int s_file_compare (void *item1, void *item2) { assert (item1); assert (item2); return strcmp (zfile_filename ((zfile_t *) item1, NULL), zfile_filename ((zfile_t *) item2, NULL)); } // -------------------------------------------------------------------------- // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zdir_flatten_free (zfile_t ***files_p) { assert (files_p); free (*files_p); *files_p = NULL; } // -------------------------------------------------------------------------- // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. zlist_t * zdir_list (zdir_t *self) { zfile_t **files = zdir_flatten (self); zlist_t *list = zlist_new (); size_t index; if (files) { for (index = 0 ; files[index] ; index++) { zlist_append (list, files[index]); } } zdir_flatten_free (&files); return list; } // -------------------------------------------------------------------------- // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void zdir_remove (zdir_t *self, bool force) { // If forced, remove all subdirectories and files if (force) { zfile_t *file = (zfile_t *) zlist_pop (self->files); while (file) { zfile_remove (file); zfile_destroy (&file); file = (zfile_t *) zlist_pop (self->files); } zdir_t *subdir = (zdir_t *) zlist_pop (self->subdirs); while (subdir) { zdir_remove (subdir, force); zdir_destroy (&subdir); subdir = (zdir_t *) zlist_pop (self->subdirs); } self->cursize = 0; self->count = 0; } // Remove if empty if (zlist_size (self->files) == 0 && zlist_size (self->subdirs) == 0) zsys_dir_delete (self->path); } // -------------------------------------------------------------------------- // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias) { zlist_t *patches = zlist_new (); if (!patches) return NULL; zfile_t **old_files = zdir_flatten (older); zfile_t **new_files = zdir_flatten (newer); int old_index = 0; int new_index = 0; // Note that both lists are sorted, so detecting differences // is rather trivial while (old_files [old_index] || new_files [new_index]) { zfile_t *old_file = old_files [old_index]; zfile_t *new_file = new_files [new_index]; int cmp; if (!old_file) cmp = 1; // Old file was deleted at end of list else if (!new_file) cmp = -1; // New file was added at end of list else cmp = strcmp (zfile_filename (old_file, NULL), zfile_filename (new_file, NULL)); if (cmp > 0) { // New file was created if (zfile_is_stable (new_file)) { int rc = zlist_append (patches, zdir_patch_new (newer->path, new_file, patch_create, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } old_index--; } else if (cmp < 0) { // Old file was deleted if (zfile_is_stable (old_file)) { int rc = zlist_append (patches, zdir_patch_new (older->path, old_file, patch_delete, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } new_index--; } else if (cmp == 0 && zfile_is_stable (new_file)) { if (zfile_is_stable (old_file)) { // Old file was modified or replaced // Since we don't check file contents, treat as created // Could better do SHA check on file here if (zfile_modified (new_file) != zfile_modified (old_file) || zfile_cursize (new_file) != zfile_cursize (old_file)) { int rc = zlist_append (patches, zdir_patch_new (newer->path, new_file, patch_create, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } } else { // File was created over some period of time int rc = zlist_append (patches, zdir_patch_new (newer->path, new_file, patch_create, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } } old_index++; new_index++; } free (old_files); free (new_files); return patches; } // -------------------------------------------------------------------------- // Return full contents of directory as a patch list. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_resync (zdir_t *self, const char *alias) { zlist_t *patches = zlist_new (); if (!patches) return NULL; zfile_t **files = zdir_flatten (self); uint index; for (index = 0;; index++) { zfile_t *file = files [index]; if (!file) break; if (zlist_append (patches, zdir_patch_new ( self->path, file, patch_create, alias))) { zlist_destroy (&patches); break; } } free (files); return patches; } // -------------------------------------------------------------------------- // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // The caller must destroy the hash table when done with it. zhash_t * zdir_cache (zdir_t *self) { assert (self); // Load any previous cache from disk zhash_t *cache = zhash_new (); if (!cache) return NULL; zhash_autofree (cache); char *cache_file = (char *) zmalloc (strlen (self->path) + strlen ("/.cache") + 1); if (!cache_file) { zhash_destroy (&cache); return NULL; } sprintf (cache_file, "%s/.cache", self->path); zhash_load (cache, cache_file); // Recalculate digest for any new files zfile_t **files = zdir_flatten (self); uint index; for (index = 0;; index++) { zfile_t *file = files [index]; if (!file) break; const char *filename = zfile_filename (file, self->path); if (zhash_lookup (cache, zfile_filename (file, self->path)) == NULL) { int rc = zhash_insert (cache, filename, (void *) zfile_digest (file)); if (rc != 0) { zhash_destroy (&cache); break; } } } free (files); // Save cache to disk for future reference if (cache) zhash_save (cache, cache_file); free (cache_file); return cache; } // -------------------------------------------------------------------------- // Print contents of directory to open stream void zdir_fprint (zdir_t *self, FILE *stream, int indent) { assert (self); zfile_t **files = zdir_flatten (self); uint index; for (index = 0;; index++) { zfile_t *file = files [index]; if (!file) break; fprintf (stream, "%s\n", zfile_filename (file, NULL)); } zdir_flatten_free (&files); } // -------------------------------------------------------------------------- // Print contents of directory to stdout void zdir_print (zdir_t *self, int indent) { zdir_fprint (self, stdout, indent); } // -------------------------------------------------------------------------- // Watch a directory for changes typedef struct _zdir_watch_t { zsock_t *pipe; // actor command channel zloop_t *loop; // event reactor int read_timer_id; // the zloop timer id to signal directory updating bool verbose; // extra logging to be printed zhash_t *subs; // path -> zdir_watch_sub_t instance hashtable for each active subscription } zdir_watch_t; typedef struct _zdir_watch_sub_t { zdir_t *dir; } zdir_watch_sub_t; static int s_on_read_timer (zloop_t *loop, int timer_id, void *arg) { zdir_watch_t *watch = (zdir_watch_t *) arg; for (void *data = zhash_first (watch->subs); data != NULL; data = zhash_next (watch->subs)) { zdir_watch_sub_t *sub = (zdir_watch_sub_t *) data; zdir_t *new_dir = zdir_new (zdir_path (sub->dir), NULL); if (!new_dir) { if (watch->verbose) zsys_error ("zdir_watch: Unable to create new zdir for path %s", zdir_path (sub->dir)); continue; } // Determine if anything has changed. zlist_t *diff = zdir_diff (sub->dir, new_dir, ""); // Do memory management before error handling... zdir_destroy (&sub->dir); sub->dir = new_dir; if (!diff) { if (watch->verbose) zsys_error ("zdir_watch: Unable to create diff for path %s", zdir_path (sub->dir)); continue; } if (zlist_size (diff) > 0) { if (watch->verbose) { zdir_patch_t *patch = (zdir_patch_t *) zlist_first (diff); zsys_info ("zdir_watch: Found %d changes in %s:", zlist_size (diff), zdir_path (sub->dir)); while (patch) { zsys_info ("zdir_watch: %s %s", zfile_filename (zdir_patch_file (patch), NULL), zdir_patch_op (patch) == ZDIR_PATCH_CREATE ? "created" : "deleted"); patch = (zdir_patch_t *) zlist_next (diff); } } if (zsock_send (watch->pipe, "sp", zdir_path (sub->dir), diff) != 0) { if (watch->verbose) zsys_error ("zdir_watch: Unable to send patch list for path %s", zdir_path (sub->dir)); zlist_destroy (&diff); } // Successfully sent `diff` list - now owned by receiver } else { zlist_destroy (&diff); } } return 0; } static void s_zdir_watch_destroy (zdir_watch_t **watch_p) { assert (watch_p); if (*watch_p) { zdir_watch_t *watch = *watch_p; zloop_destroy (&watch->loop); free (watch); *watch_p = NULL; } } static void s_sub_free (void *data) { zdir_watch_sub_t *sub = (zdir_watch_sub_t *) data; zdir_destroy (&sub->dir); free (sub); } static void s_zdir_watch_subscribe (zdir_watch_t *watch, const char *path) { if (watch->verbose) zsys_info ("zdir_watch: Subscribing to directory path: %s", path); zdir_watch_sub_t *sub = (zdir_watch_sub_t *) zmalloc (sizeof (zdir_watch_sub_t)); sub->dir = zdir_new (path, NULL); if (!sub->dir) { if (watch->verbose) zsys_error ("zdir_watch: Unable to create zdir for path: %s", path); zsock_signal (watch->pipe, 1); return; } int rc = zhash_insert (watch->subs, path, sub); if (rc) { if (watch->verbose) zsys_error ("zdir_watch: Unable to insert path '%s' into subscription list", path); zsock_signal (watch->pipe, 1); return; } void *item = zhash_freefn (watch->subs, path, s_sub_free); if (item != sub) { if (watch->verbose) zsys_error ("zdir_watch: Unable to set free fn for path %s", path); zsock_signal (watch->pipe, 1); return; } if (watch->verbose) zsys_info ("zdir_watch: Successfully subscribed to %s", path); zsock_signal (watch->pipe, 0); } static void s_zdir_watch_unsubscribe (zdir_watch_t *watch, const char *path) { if (watch->verbose) zsys_info ("zdir_watch: Unsubscribing from directory path: %s", path); zhash_delete (watch->subs, path); if (watch->verbose) zsys_info ("zdir_watch: Successfully unsubscribed from %s", path); zsock_signal (watch->pipe, 0); } static int s_zdir_watch_timeout (zdir_watch_t *watch, int timeout) { if (watch->verbose) zsys_info ("zdir_watch: Setting directory poll timeout to %d", timeout); if (watch->read_timer_id != -1) { zloop_timer_end (watch->loop, watch->read_timer_id); watch->read_timer_id = -1; } watch->read_timer_id = zloop_timer (watch->loop, timeout, 0, s_on_read_timer, watch); if (watch->verbose) zsys_info ("zdir_watch: Successfully set directory poll timeout to %d", timeout); return 0; } static zdir_watch_t * s_zdir_watch_new (zsock_t *pipe) { zdir_watch_t *watch = (zdir_watch_t *) zmalloc (sizeof (zdir_watch_t)); if (!watch) return NULL; watch->pipe = pipe; watch->read_timer_id = -1; watch->verbose = false; return watch; } static int s_on_command (zloop_t *loop, zsock_t *reader, void *arg) { zdir_watch_t *watch = (zdir_watch_t *) arg; zmsg_t *msg = zmsg_recv (watch->pipe); assert (msg); char *command = zmsg_popstr (msg); assert (command); if (watch->verbose) zsys_info ("zdir_watch: Command received: %s", command); if (streq (command, "$TERM")) { return -1; } else if (streq (command, "VERBOSE")) { watch->verbose = true; zsock_signal (watch->pipe, 0); } else if (streq (command, "SUBSCRIBE")) { char *path = zmsg_popstr (msg); if (path) { s_zdir_watch_subscribe (watch, path); free (path); } else { if (watch->verbose) zsys_error ("zdir_watch: Unable to extract path from SUBSCRIBE message"); zsock_signal (watch->pipe, 1); } } else if (streq (command, "UNSUBSCRIBE")) { char *path = zmsg_popstr (msg); if (path) { assert (path); s_zdir_watch_unsubscribe (watch, path); free (path); } else { if (watch->verbose) zsys_error ("zdir_watch: Unable to extract path from UNSUBSCRIBE message"); zsock_signal (watch->pipe, 1); } } else if (streq (command, "TIMEOUT")) { char *timeout_string = zmsg_popstr (msg); if (timeout_string) { int timeout = atoi (timeout_string); zsock_signal (watch->pipe, s_zdir_watch_timeout (watch, timeout)); free (timeout_string); } else { if (watch->verbose) zsys_error ("zdir_watch: Unable to extract time from TIMEOUT message"); zsock_signal (watch->pipe, 1); } } else { if (watch->verbose) zsys_warning ("zdir_watch: Unknown command '%s'", command); zsock_signal (watch->pipe, 1); } free (command); return 0; } // -------------------------------------------------------------------------- // Create a new zdir_watch actor instance void zdir_watch (zsock_t *pipe, void *unused) { zdir_watch_t *watch = s_zdir_watch_new (pipe); assert (watch); watch->loop = zloop_new (); assert (watch->loop); watch->subs = zhash_new (); assert (watch->subs); zloop_reader (watch->loop, pipe, s_on_command, watch); zloop_reader_set_tolerant (watch->loop, pipe); // command pipe needs to be tolerant, otherwise we'd have a hard time shutting down s_zdir_watch_timeout (watch, 250); // default poll time of 250ms // Signal initialization zsock_signal (pipe, 0); // Dispatch above handlers zloop_start (watch->loop); if (watch->verbose) zsys_info ("zdir_watch: Complete"); // signal destruction zsock_signal (watch->pipe, 0); // Done - cleanup and exit s_zdir_watch_destroy (&watch); } // -------------------------------------------------------------------------- // Self test of this class void zdir_test (bool verbose) { printf (" * zdir: "); // @selftest zdir_t *older = zdir_new (".", NULL); assert (older); if (verbose) { printf ("\n"); zdir_dump (older, 0); } zdir_t *newer = zdir_new ("..", NULL); assert (newer); zlist_t *patches = zdir_diff (older, newer, "/"); assert (patches); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); zdir_patch_destroy (&patch); } zlist_destroy (&patches); zdir_destroy (&older); zdir_destroy (&newer); zdir_t *nosuch = zdir_new ("does-not-exist", NULL); assert (nosuch == NULL); // zdir_watch test: zactor_t *watch = zactor_new (zdir_watch, NULL); assert (watch); if (verbose) { zsock_send (watch, "s", "VERBOSE"); assert (zsock_wait (watch) == 0); } // need to create a file in the test directory we're watching // in order to ensure the directory exists zfile_t *initfile = zfile_new ("./zdir-test-dir", "initial_file"); assert (initfile); zfile_output (initfile); fprintf (zfile_handle (initfile), "initial file\n"); zfile_close (initfile); zfile_destroy (&initfile); zclock_sleep (1001); // wait for initial file to become 'stable' zsock_send (watch, "si", "TIMEOUT", 100); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir-test-dir"); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "UNSUBSCRIBE", "zdir-test-dir"); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir-test-dir"); assert (zsock_wait (watch) == 0); zfile_t *newfile = zfile_new ("zdir-test-dir", "test_abc"); zfile_output (newfile); fprintf (zfile_handle (newfile), "test file\n"); zfile_close (newfile); zpoller_t *watch_poll = zpoller_new (watch, NULL); // poll for a certain timeout before giving up and failing the test. assert(zpoller_wait (watch_poll, 1001) == watch); // wait for notification of the file being added char *path; int rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir-test-dir")); free (path); assert (zlist_size (patches) == 1); zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir-test-dir")); zfile_t *patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir-test-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); // remove the file zfile_remove (newfile); zfile_destroy (&newfile); // poll for a certain timeout before giving up and failing the test. assert(zpoller_wait (watch_poll, 1001) == watch); // wait for notification of the file being removed rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir-test-dir")); free (path); assert (zlist_size (patches) == 1); patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir-test-dir")); patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir-test-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); zpoller_destroy (&watch_poll); zactor_destroy (&watch); // clean up by removing the test directory. zdir_t *testdir = zdir_new ("zdir-test-dir", NULL); zdir_remove (testdir, true); zdir_destroy (&testdir); // @end printf ("OK\n"); } czmq-3.0.2/src/zlist.c0000664000175000017500000004121212523065376013701 0ustar00phph00000000000000/* ========================================================================= zlist - simple generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Provides a generic container implementing a fast singly-linked list. You can use this to construct multi-dimensional lists, and other structures together with other generic containers like zhash. This is a simple class. For demanding applications we recommend using zlistx. @discuss To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration. @end */ #include "../include/czmq.h" // List node, used internally only typedef struct _node_t { struct _node_t *next; void *item; zlist_free_fn *free_fn; } node_t; // --------------------------------------------------------------------- // Structure of our class struct _zlist_t { node_t *head; // First item in list, if any node_t *tail; // Last item in list, if any node_t *cursor; // Current cursors for iteration size_t size; // Number of items in list bool autofree; // If true, free items in destructor zlist_compare_fn *compare_fn; // Function to compare two list item for // less than, equals or greater than }; // -------------------------------------------------------------------------- // List constructor zlist_t * zlist_new (void) { zlist_t *self = (zlist_t *) zmalloc (sizeof (zlist_t)); return self; } // -------------------------------------------------------------------------- // List destructor void zlist_destroy (zlist_t **self_p) { assert (self_p); if (*self_p) { zlist_t *self = *self_p; zlist_purge (self); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlist_first (zlist_t *self) { assert (self); self->cursor = self->head; if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * zlist_next (zlist_t *self) { assert (self); if (self->cursor) self->cursor = self->cursor->next; else self->cursor = self->head; if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlist_last (zlist_t *self) { assert (self); self->cursor = self->tail; if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor as-is. void * zlist_head (zlist_t *self) { assert (self); return self->head ? self->head->item : NULL; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor as-is. void * zlist_tail (zlist_t *self) { assert (self); return self->tail ? self->tail->item : NULL; } // -------------------------------------------------------------------------- // Return current item in the list. If the list is empty, or the cursor // passed the end of the list, returns NULL. Does not change the cursor. void * zlist_item (zlist_t *self) { assert (self); if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). int zlist_append (zlist_t *self, void *item) { if (!item) return -1; node_t *node; node = (node_t *) zmalloc (sizeof (node_t)); if (!node) return -1; // If necessary, take duplicate of (string) item if (self->autofree) item = strdup ((char *) item); node->item = item; if (self->tail) self->tail->next = node; else self->head = node; self->tail = node; node->next = NULL; self->size++; self->cursor = NULL; return 0; } // -------------------------------------------------------------------------- // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). int zlist_push (zlist_t *self, void *item) { node_t *node; node = (node_t *) zmalloc (sizeof (node_t)); if (!node) return -1; // If necessary, take duplicate of (string) item if (self->autofree) item = strdup ((char *) item); node->item = item; node->next = self->head; self->head = node; if (self->tail == NULL) self->tail = node; self->size++; self->cursor = NULL; return 0; } // -------------------------------------------------------------------------- // Remove item from the beginning of the list, returns NULL if none void * zlist_pop (zlist_t *self) { node_t *node = self->head; void *item = NULL; if (node) { item = node->item; self->head = node->next; if (self->tail == node) self->tail = NULL; free (node); self->size--; } self->cursor = NULL; return item; } // -------------------------------------------------------------------------- // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool zlist_exists (zlist_t *self, void *item) { assert (self); assert (item); node_t *node = self->head; while (node) { if (self->compare_fn) { if ((*self->compare_fn)(node->item, item) == 0) return true; } else { if (node->item == item) { return true; } } node = node->next; } return false; } // -------------------------------------------------------------------------- // Remove the item from the list, if present. Safe to call on items that // are not in the list. void zlist_remove (zlist_t *self, void *item) { node_t *node, *prev = NULL; // First off, we need to find the list node for (node = self->head; node != NULL; node = node->next) { if (self->compare_fn) { if ((*self->compare_fn)(node->item, item) == 0) break; } else { if (node->item == item) break; } prev = node; } if (node) { if (prev) prev->next = node->next; else self->head = node->next; if (node->next == NULL) self->tail = prev; if (self->cursor == node) self->cursor = prev; if (node->free_fn) (node->free_fn)(node->item); free (node); self->size--; } } // -------------------------------------------------------------------------- // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. zlist_t * zlist_dup (zlist_t *self) { if (!self) return NULL; zlist_t *copy = zlist_new (); if (copy) { node_t *node; for (node = self->head; node; node = node->next) { if (zlist_append (copy, node->item) == -1) { zlist_destroy (©); break; } } } return copy; } // -------------------------------------------------------------------------- // Purge all items from list void zlist_purge (zlist_t *self) { assert (self); node_t *node = self->head; while (node) { node_t *next = node->next; if (self->autofree) free (node->item); else if (node->free_fn) (node->free_fn)(node->item); free (node); node = next; } self->head = NULL; self->tail = NULL; self->cursor = NULL; self->size = 0; } // -------------------------------------------------------------------------- // Return the number of items in the list size_t zlist_size (zlist_t *self) { return self->size; } // -------------------------------------------------------------------------- // Sort the list by ascending key value using a straight ASCII comparison. // The sort is not stable, so may reorder items with the same keys. void zlist_sort (zlist_t *self, zlist_compare_fn *compare) { // If the compare function is NULL use the lists one if present if (!compare && self->compare_fn) compare = self->compare_fn; // Uses a comb sort, which is simple and reasonably fast. // See http://en.wikipedia.org/wiki/Comb_sort size_t gap = self->size; bool swapped = false; while (gap > 1 || swapped) { if (gap > 1) gap = (size_t) ((double) gap / 1.3); node_t *base = self->head; node_t *test = self->head; size_t jump = gap; while (jump--) test = test->next; swapped = false; while (base && test) { if ((*compare)(base->item, test->item) > 0) { // It's trivial to swap items in a generic container void *item = base->item; base->item = test->item; test->item = item; swapped = true; } base = base->next; test = test->next; } } } // -------------------------------------------------------------------------- // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void zlist_comparefn (zlist_t *self, zlist_compare_fn fn) { assert (self); self->compare_fn = fn; } // -------------------------------------------------------------------------- // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn *fn, bool at_tail) { node_t *node = self->head; if (at_tail) node = self->tail; while (node) { if (node->item == item) { node->free_fn = fn; return item; } node = node->next; } return NULL; } // -------------------------------------------------------------------------- // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void zlist_autofree (zlist_t *self) { assert (self); self->autofree = true; } static void s_zlist_free (void *data) { zlist_t *self = (zlist_t *) data; zlist_destroy (&self); } static int s_compare (void *item1, void *item2) { return strcmp ((char *) item1, (char *) item2); } // -------------------------------------------------------------------------- // Runs selftest of class void zlist_test (int verbose) { printf (" * zlist: "); // @selftest zlist_t *list = zlist_new (); assert (list); assert (zlist_size (list) == 0); // Three items we'll use as test data // List items are void *, not particularly strings char *cheese = "boursin"; char *bread = "baguette"; char *wine = "bordeaux"; zlist_append (list, cheese); assert (zlist_size (list) == 1); assert ( zlist_exists (list, cheese)); assert (!zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, bread); assert (zlist_size (list) == 2); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, wine); assert (zlist_size (list) == 3); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert ( zlist_exists (list, wine)); assert (zlist_head (list) == cheese); assert (zlist_next (list) == cheese); assert (zlist_first (list) == cheese); assert (zlist_tail (list) == wine); assert (zlist_next (list) == bread); assert (zlist_first (list) == cheese); assert (zlist_next (list) == bread); assert (zlist_next (list) == wine); assert (zlist_next (list) == NULL); // After we reach end of list, next wraps around assert (zlist_next (list) == cheese); assert (zlist_size (list) == 3); zlist_remove (list, wine); assert (zlist_size (list) == 2); assert (zlist_first (list) == cheese); zlist_remove (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == bread); zlist_remove (list, bread); assert (zlist_size (list) == 0); zlist_append (list, cheese); zlist_append (list, bread); assert (zlist_last (list) == bread); zlist_remove (list, bread); assert (zlist_last (list) == cheese); zlist_remove (list, cheese); assert (zlist_last (list) == NULL); zlist_push (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == cheese); zlist_push (list, bread); assert (zlist_size (list) == 2); assert (zlist_first (list) == bread); assert (zlist_item (list) == bread); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_first (list) == bread); zlist_t *sub_list = zlist_dup (list); assert (sub_list); assert (zlist_size (sub_list) == 3); zlist_sort (list, s_compare); char *item; item = (char *) zlist_pop (list); assert (item == bread); item = (char *) zlist_pop (list); assert (item == wine); item = (char *) zlist_pop (list); assert (item == cheese); assert (zlist_size (list) == 0); assert (zlist_size (sub_list) == 3); zlist_push (list, sub_list); zlist_t *sub_list_2 = zlist_dup (sub_list); zlist_append (list, sub_list_2); assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list); assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2); zlist_destroy (&list); // Test autofree functionality list = zlist_new (); assert (list); zlist_autofree (list); // Set equals function otherwise equals will not work as autofree copies strings zlist_comparefn (list, s_compare); zlist_push (list, bread); zlist_append (list, cheese); assert (zlist_size (list) == 2); zlist_append (list, wine); assert (zlist_exists (list, wine)); zlist_remove (list, wine); assert (!zlist_exists (list, wine)); assert (streq ((const char *) zlist_first (list), bread)); item = (char *) zlist_pop (list); assert (streq (item, bread)); free (item); item = (char *) zlist_pop (list); assert (streq (item, cheese)); free (item); zlist_destroy (&list); assert (list == NULL); // @end printf ("OK\n"); } czmq-3.0.2/src/zsock.c0000664000175000017500000016214212525412323013661 0ustar00phph00000000000000/* ========================================================================= zsock - high-level socket API that hides libzmq contexts and sockets Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *. @discuss @end */ #define ZSOCK_NOCHECK // we are defining the methods here, so don't redirect symbols. #include "../include/czmq.h" // zsock_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZSOCK_TAG 0x0004cafe // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding. #define DYNAMIC_FIRST 0xc000 // 49152 #define DYNAMIC_LAST 0xffff // 65535 #define ZSOCK_BSEND_MAX_FRAMES 32 // Arbitrary limit, for now // Structure of our class struct _zsock_t { uint32_t tag; // Object tag for runtime detection void *handle; // The libzmq socket handle char *endpoint; // Last bound endpoint, if any char *cache; // Holds last zsock_brecv strings int type; // Socket type size_t cache_size; // Current size of cache }; // -------------------------------------------------------------------------- // Create a new socket. This macro passes the caller source and line // number so that CZMQ can report socket leaks intelligently. To switch // off this checking, which may be costly if you use a LOT of sockets, // define ZSOCK_NOCHECK before compiling your code. Returns the new // socket, or NULL if the new socket could not be created. zsock_t * zsock_new_checked (int type, const char *filename, size_t line_nbr) { zsock_t *self = (zsock_t *) zmalloc (sizeof (zsock_t)); if (self) { self->tag = ZSOCK_TAG; self->handle = zsys_socket (type, filename, line_nbr); self->type = type; if (!self->handle) zsock_destroy (&self); } return self; } zsock_t * zsock_new (int type) { return zsock_new_checked (type, NULL, 0); } // -------------------------------------------------------------------------- // Destroy the socket. You must use this for any socket created via the // zsock_new method. void zsock_destroy_checked (zsock_t **self_p, const char *filename, size_t line_nbr) { assert (self_p); if (*self_p) { zsock_t *self = *self_p; assert (zsock_is (self)); self->tag = 0xDeadBeef; int rc = zsys_close (self->handle, filename, line_nbr); assert (rc == 0); free (self->endpoint); free (self->cache); free (self); *self_p = NULL; } } void zsock_destroy (zsock_t **self_p) { zsock_destroy_checked (self_p, NULL, 0); } // -------------------------------------------------------------------------- // This interface includes some smart constructors, which create sockets with // additional set-up. In all of these, the endpoint is NULL, or starts with // '@' (bind) or '>' (connect). Multiple endpoints are allowed, separated by // commas. If endpoint does not start with '@' or '>', default action depends // on socket type. // Create a PUB socket. Default action is bind. zsock_t * zsock_new_pub_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PUB, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_pub (const char *endpoints) { return zsock_new_pub_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. zsock_t * zsock_new_sub_checked (const char *endpoints, const char *subscribe, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_SUB, filename, line_nbr); if (sock) { if (zsock_attach (sock, endpoints, false) == 0) { if (subscribe) zsock_set_subscribe (sock, subscribe); } else zsock_destroy (&sock); } return sock; } zsock_t * zsock_new_sub (const char *endpoints, const char *subscribe) { return zsock_new_sub_checked (endpoints, subscribe, NULL, 0); } // -------------------------------------------------------------------------- // Create a REQ socket. Default action is connect. zsock_t * zsock_new_req_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_REQ, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_req (const char *endpoints) { return zsock_new_req_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a REP socket. Default action is bind. zsock_t * zsock_new_rep_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_REP, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_rep (const char *endpoints) { return zsock_new_rep_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a DEALER socket. Default action is connect. zsock_t * zsock_new_dealer_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_DEALER, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_dealer (const char *endpoints) { return zsock_new_dealer_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a ROUTER socket. Default action is bind. zsock_t * zsock_new_router_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_ROUTER, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_router (const char *endpoints) { return zsock_new_router_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a PUSH socket. Default action is connect. zsock_t * zsock_new_push_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PUSH, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_push (const char *endpoints) { return zsock_new_push_checked(endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a PULL socket. Default action is bind. zsock_t * zsock_new_pull_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PULL, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_pull (const char *endpoints) { return zsock_new_pull_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create an XPUB socket. Default action is bind. zsock_t * zsock_new_xpub_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_XPUB zsock_t *sock = zsock_new_checked (ZMQ_XPUB, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; #else return NULL; // Not implemented #endif } zsock_t * zsock_new_xpub (const char *endpoints) { return zsock_new_xpub_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create an XSUB socket. Default action is connect. zsock_t * zsock_new_xsub_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_XSUB zsock_t *sock = zsock_new_checked (ZMQ_XSUB, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; // Not implemented #endif } zsock_t * zsock_new_xsub (const char *endpoints) { return zsock_new_xsub_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a PAIR socket. Default action is connect. zsock_t * zsock_new_pair_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PAIR, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_pair (const char *endpoints) { return zsock_new_pair_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a STREAM socket. Default action is connect. zsock_t * zsock_new_stream_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_STREAM zsock_t *sock = zsock_new_checked (ZMQ_STREAM, filename, line_nbr); if (sock) if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; // Not implemented #endif } zsock_t * zsock_new_stream (const char *endpoints) { return zsock_new_stream_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] bind to random port from 55000-55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int zsock_bind (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc; // If tcp:// endpoint, parse to get or make port number zrex_t *rex = zrex_new (NULL); if (zrex_eq (rex, endpoint, "^tcp://.*:(\\d+)$")) { assert (zrex_hits (rex) == 2); if (zmq_bind (self->handle, endpoint) == 0) rc = atoi (zrex_hit (rex, 1)); else rc = -1; } else if (zrex_eq (rex, endpoint, "^(tcp://.*):([*!])(\\[(\\d+)?-(\\d+)?\\])?$")) { assert (zrex_hits (rex) == 6); const char *hostname, *opcode, *group, *first_str, *last_str; zrex_fetch (rex, &hostname, &opcode, &group, &first_str, &last_str, NULL); int first = *first_str? atoi (first_str): DYNAMIC_FIRST; int last = *last_str? atoi (last_str): DYNAMIC_LAST; // This is how many times we'll try before giving up int attempts = last - first + 1; // If operator is '*', take first available port. // If operator is '!', take a random leap into our port space; we'll // still scan sequentially to make sure we find a free slot rapidly. int port = first; if (streq (opcode, "!")) port += randof (attempts); rc = -1; // Assume we don't succeed while (rc == -1 && attempts--) { free (endpoint); endpoint = zsys_sprintf ("%s:%d", hostname, port); if (!endpoint) break; if (zmq_bind (self->handle, endpoint) == 0) rc = port; if (++port > last) port = first; } } else rc = zmq_bind (self->handle, endpoint); // Store successful endpoint for later reference if (rc >= 0) { free (self->endpoint); self->endpoint = endpoint; } else free (endpoint); zrex_destroy (&rex); return rc; } // -------------------------------------------------------------------------- // Returns last bound endpoint, if any. const char * zsock_endpoint (zsock_t *self) { assert (self); return self->endpoint; } // -------------------------------------------------------------------------- // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_unbind (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc = zmq_unbind (self->handle, endpoint); free (endpoint); return rc; #else return -1; #endif } // -------------------------------------------------------------------------- // Connect a socket to a formatted endpoint // Returns 0 if the endpoint is valid, -1 if the connect failed. int zsock_connect (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc = zmq_connect (self->handle, endpoint); #if (ZMQ_VERSION < ZMQ_MAKE_VERSION (4, 0, 0)) int retries = 4; while (rc == -1 && zmq_errno () == ECONNREFUSED && retries) { // This bruteforces a synchronization between connecting and // binding threads on ZeroMQ v3.2 and earlier, where the bind // MUST happen before the connect on inproc transports. zclock_sleep (250); rc = zmq_connect (self->handle, endpoint); retries--; } #endif free (endpoint); return rc; } // -------------------------------------------------------------------------- // Disconnect a socket from a formatted endpoint // Returns 0 if disconnection is complete -1 if the disconnection failed. int zsock_disconnect (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc = zmq_disconnect (self->handle, endpoint); free (endpoint); return rc; #else return -1; #endif } // -------------------------------------------------------------------------- // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to attach the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int zsock_attach (zsock_t *self, const char *endpoints, bool serverish) { assert (self); if (!endpoints) return 0; // We hold each individual endpoint here char endpoint [256]; while (*endpoints) { const char *delimiter = strchr (endpoints, ','); if (!delimiter) delimiter = endpoints + strlen (endpoints); if (delimiter - endpoints > 255) return -1; memcpy (endpoint, endpoints, delimiter - endpoints); endpoint [delimiter - endpoints] = 0; int rc; if (endpoint [0] == '@') rc = zsock_bind (self, "%s", endpoint + 1); else if (endpoint [0] == '>') rc = zsock_connect (self, "%s", endpoint + 1); else if (serverish) rc = zsock_bind (self, "%s", endpoint); else rc = zsock_connect (self, "%s", endpoint); if (rc == -1) return -1; // Bad endpoint syntax if (*delimiter == 0) break; endpoints = delimiter + 1; } return 0; } // -------------------------------------------------------------------------- // Returns socket type as printable constant string. const char * zsock_type_str (zsock_t *self) { assert (self); return zsys_sockname (self->type); } // -------------------------------------------------------------------------- // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, int (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int zsock_send (void *self, const char *picture, ...) { va_list argptr; va_start (argptr, picture); int rc = zsock_vsend (self, picture, argptr); va_end (argptr); return rc; } // -------------------------------------------------------------------------- // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int zsock_vsend (void *self, const char *picture, va_list argptr) { assert (self); assert (picture); zmsg_t *msg = zmsg_new (); while (*picture) { if (*picture == 'i') zmsg_addstrf (msg, "%d", va_arg (argptr, int)); else if (*picture == '1') zmsg_addstrf (msg, "%" PRIu8, (uint8_t) va_arg (argptr, int)); else if (*picture == '2') zmsg_addstrf (msg, "%" PRIu16, (uint16_t) va_arg (argptr, int)); else if (*picture == '4') zmsg_addstrf (msg, "%" PRIu32, va_arg (argptr, uint32_t)); else if (*picture == '8') zmsg_addstrf (msg, "%" PRIu64, va_arg (argptr, uint64_t)); else if (*picture == 'u') // Deprecated, use 4 or 8 instead zmsg_addstrf (msg, "%ud", va_arg (argptr, uint)); else if (*picture == 's') zmsg_addstr (msg, va_arg (argptr, char *)); else if (*picture == 'b') { // Note function arguments may be expanded in reverse order, // so we cannot use va_arg macro twice in a single call byte *data = va_arg (argptr, byte *); zmsg_addmem (msg, data, va_arg (argptr, int)); } else if (*picture == 'c') { zchunk_t *chunk = va_arg (argptr, zchunk_t *); assert (zchunk_is (chunk)); zmsg_addmem (msg, zchunk_data (chunk), zchunk_size (chunk)); } else if (*picture == 'f') { zframe_t *frame = va_arg (argptr, zframe_t *); assert (zframe_is (frame)); zmsg_addmem (msg, zframe_data (frame), zframe_size (frame)); } else if (*picture == 'U') { zuuid_t *uuid = va_arg (argptr, zuuid_t *); zmsg_addmem (msg, zuuid_data (uuid), zuuid_size (uuid)); } else if (*picture == 'p') { void *pointer = va_arg (argptr, void *); zmsg_addmem (msg, &pointer, sizeof (void *)); } else if (*picture == 'h') { zhashx_t *hash = va_arg (argptr, zhashx_t *); zframe_t *frame = zhashx_pack (hash); zmsg_append (msg, &frame); } else if (*picture == 'm') { zframe_t *frame; zmsg_t *zmsg = va_arg (argptr, zmsg_t *); for (frame = zmsg_first (zmsg); frame; frame = zmsg_next (zmsg) ) { zframe_t *frame_dup = zframe_dup (frame); zmsg_append (msg, &frame_dup); } } else if (*picture == 'z') zmsg_addmem (msg, NULL, 0); else { zsys_error ("zsock: invalid picture element '%c'", *picture); assert (false); } picture++; } return zmsg_send (&msg, self); } // -------------------------------------------------------------------------- // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 1 = uint8_t * (stores 8-bit unsigned integer) // 2 = uint16_t * (stores 16-bit unsigned integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // h = zhashx_t ** (creates zhashx) // U = zuuid_t * (creates a zuuid with the data) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int zsock_recv (void *self, const char *picture, ...) { va_list argptr; va_start (argptr, picture); int rc = zsock_vrecv (self, picture, argptr); va_end (argptr); return rc; } // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int zsock_vrecv (void *self, const char *picture, va_list argptr) { assert (self); assert (picture); zmsg_t *msg = zmsg_recv (self); if (!msg) return -1; // Interrupted // Filter a signal that may come from a dying actor if (zmsg_signal (msg) >= 0) { zmsg_destroy (&msg); return -1; } // Now parse message according to picture argument int rc = 0; while (*picture) { if (*picture == 'i') { char *string = zmsg_popstr (msg); int *int_p = va_arg (argptr, int *); if (int_p) *int_p = string? atoi (string): 0; free (string); } else if (*picture == '1') { char *string = zmsg_popstr (msg); uint8_t *uint8_p = va_arg (argptr, uint8_t *); if (uint8_p) *uint8_p = string? (uint8_t) atoi (string): 0; free (string); } else if (*picture == '2') { char *string = zmsg_popstr (msg); uint16_t *uint16_p = va_arg (argptr, uint16_t *); if (uint16_p) *uint16_p = string? (uint16_t) atol (string): 0; free (string); } else if (*picture == '4') { char *string = zmsg_popstr (msg); uint32_t *uint32_p = va_arg (argptr, uint32_t *); if (uint32_p) *uint32_p = string? (uint32_t) atol (string): 0; free (string); } else if (*picture == '8') { char *string = zmsg_popstr (msg); uint64_t *uint64_p = va_arg (argptr, uint64_t *); if (uint64_p) *uint64_p = string? (uint64_t) atoll (string): 0; free (string); } else if (*picture == 'u') { // Deprecated, use 4 or 8 instead char *string = zmsg_popstr (msg); uint *uint_p = va_arg (argptr, uint *); if (uint_p) *uint_p = string? (uint) atol (string): 0; free (string); } else if (*picture == 's') { char *string = zmsg_popstr (msg); char **string_p = va_arg (argptr, char **); if (string_p) *string_p = string; else free (string); } else if (*picture == 'b') { zframe_t *frame = zmsg_pop (msg); byte **data_p = va_arg (argptr, byte **); size_t *size = va_arg (argptr, size_t *); if (data_p) { if (frame) { *size = zframe_size (frame); *data_p = (byte *) malloc (*size); memcpy (*data_p, zframe_data (frame), *size); } else { *data_p = NULL; *size = 0; } } zframe_destroy (&frame); } else if (*picture == 'c') { zframe_t *frame = zmsg_pop (msg); zchunk_t **chunk_p = va_arg (argptr, zchunk_t **); if (chunk_p) { if (frame) *chunk_p = zchunk_new (zframe_data (frame), zframe_size (frame)); else *chunk_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'f') { zframe_t *frame = zmsg_pop (msg); zframe_t **frame_p = va_arg (argptr, zframe_t **); if (frame_p) *frame_p = frame; else zframe_destroy (&frame); } else if (*picture == 'U') { zframe_t *frame = zmsg_pop (msg); zuuid_t **uuid_p = va_arg (argptr, zuuid_t **); if (uuid_p) { if (frame) { *uuid_p = zuuid_new (); zuuid_set (*uuid_p, zframe_data (frame)); } else *uuid_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'p') { zframe_t *frame = zmsg_pop (msg); void **pointer_p = va_arg (argptr, void **); if (pointer_p) { if (frame) { if (zframe_size (frame) == sizeof (void *)) *pointer_p = *((void **) zframe_data (frame)); else rc = -1; } else *pointer_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'h') { zframe_t *frame = zmsg_pop (msg); zhashx_t **hash_p = va_arg (argptr, zhashx_t **); if (hash_p) { if (frame) *hash_p = zhashx_unpack (frame); else *hash_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'm') { zmsg_t **zmsg_p = va_arg (argptr, zmsg_t **); if (zmsg_p) { *zmsg_p = zmsg_new (); zframe_t *frame; while ((frame = zmsg_pop (msg))) zmsg_append (*zmsg_p, &frame); } } else if (*picture == 'z') { zframe_t *frame = zmsg_pop (msg); if (frame && zframe_size (frame) != 0) rc = -1; zframe_destroy (&frame); } else { zsys_error ("zsock: invalid picture element '%c'", *picture); assert (false); } picture++; } zmsg_destroy (&msg); return rc; } // -------------------------------------------------------------------------- // Network data encoding macros that we use in bsend/brecv // Put a 1-byte number to the frame #define PUT_NUMBER1(host) { \ *(byte *) needle = (host); \ needle++; \ } // Put a 2-byte number to the frame #define PUT_NUMBER2(host) { \ needle [0] = (byte) (((host) >> 8) & 255); \ needle [1] = (byte) (((host)) & 255); \ needle += 2; \ } // Put a 4-byte number to the frame #define PUT_NUMBER4(host) { \ needle [0] = (byte) (((host) >> 24) & 255); \ needle [1] = (byte) (((host) >> 16) & 255); \ needle [2] = (byte) (((host) >> 8) & 255); \ needle [3] = (byte) (((host)) & 255); \ needle += 4; \ } // Put a 8-byte number to the frame #define PUT_NUMBER8(host) { \ needle [0] = (byte) (((host) >> 56) & 255); \ needle [1] = (byte) (((host) >> 48) & 255); \ needle [2] = (byte) (((host) >> 40) & 255); \ needle [3] = (byte) (((host) >> 32) & 255); \ needle [4] = (byte) (((host) >> 24) & 255); \ needle [5] = (byte) (((host) >> 16) & 255); \ needle [6] = (byte) (((host) >> 8) & 255); \ needle [7] = (byte) (((host)) & 255); \ needle += 8; \ } // Get a 1-byte number from the frame #define GET_NUMBER1(host) { \ if (needle + 1 > ceiling) \ goto malformed; \ (host) = *(byte *) needle; \ needle++; \ } // Get a 2-byte number from the frame #define GET_NUMBER2(host) { \ if (needle + 2 > ceiling) \ goto malformed; \ (host) = ((uint16_t) (needle [0]) << 8) \ + (uint16_t) (needle [1]); \ needle += 2; \ } // Get a 4-byte number from the frame #define GET_NUMBER4(host) { \ if (needle + 4 > ceiling) \ goto malformed; \ (host) = ((uint32_t) (needle [0]) << 24) \ + ((uint32_t) (needle [1]) << 16) \ + ((uint32_t) (needle [2]) << 8) \ + (uint32_t) (needle [3]); \ needle += 4; \ } // Get a 8-byte number from the frame #define GET_NUMBER8(host) { \ if (needle + 8 > ceiling) \ goto malformed; \ (host) = ((uint64_t) (needle [0]) << 56) \ + ((uint64_t) (needle [1]) << 48) \ + ((uint64_t) (needle [2]) << 40) \ + ((uint64_t) (needle [3]) << 32) \ + ((uint64_t) (needle [4]) << 24) \ + ((uint64_t) (needle [5]) << 16) \ + ((uint64_t) (needle [6]) << 8) \ + (uint64_t) (needle [7]); \ needle += 8; \ } // -------------------------------------------------------------------------- // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int zsock_bsend (void *self, const char *picture, ...) { assert (self); assert (picture); // Pass 1: calculate total size of data frame size_t frame_size = 0; zframe_t *frames [ZSOCK_BSEND_MAX_FRAMES]; // Non-data frames to send size_t nbr_frames = 0; // Size of this table va_list argptr; va_start (argptr, picture); const char *picptr = picture; while (*picptr) { if (*picptr == '1') { va_arg (argptr, int); frame_size += 1; } else if (*picptr == '2') { va_arg (argptr, int); frame_size += 2; } else if (*picptr == '4') { va_arg (argptr, uint32_t); frame_size += 4; } else if (*picptr == '8') { va_arg (argptr, uint64_t); frame_size += 8; } else if (*picptr == 's') { char *string = va_arg (argptr, char *); frame_size += 1 + (string? strlen (string): 0); } else if (*picptr == 'S') { char *string = va_arg (argptr, char *); frame_size += 4 + (string? strlen (string): 0); } else if (*picptr == 'c') { zchunk_t *chunk = va_arg (argptr, zchunk_t *); frame_size += 4 + (chunk? zchunk_size (chunk): 0); } else if (*picptr == 'p') { va_arg (argptr, void *); frame_size += sizeof (void *); } else if (*picptr == 'f') { zframe_t *frame = va_arg (argptr, zframe_t *); assert (nbr_frames < ZSOCK_BSEND_MAX_FRAMES - 1); frames [nbr_frames++] = frame; } else if (*picptr == 'u') { zuuid_t *uuid = va_arg (argptr, zuuid_t *); frame_size += zuuid_size (uuid); } else if (*picptr == 'm') { if (picptr [1]) { zsys_error ("zsock_bsend: 'm' (zmsg) only valid at end of picptr"); assert (false); } zmsg_t *msg = va_arg (argptr, zmsg_t *); if (msg) { zframe_t *frame = zmsg_first (msg); while (frame) { assert (nbr_frames < ZSOCK_BSEND_MAX_FRAMES - 1); frames [nbr_frames++] = frame; frame = zmsg_next (msg); } } else frames [nbr_frames++] = zframe_new_empty (); } else { zsys_error ("zsock_bsend: invalid picptr element '%c'", *picptr); assert (false); } picptr++; } va_end (argptr); // Pass 2: encode data into data frame zmq_msg_t msg; zmq_msg_init_size (&msg, frame_size); byte *needle = (byte *) zmq_msg_data (&msg); va_start (argptr, picture); picptr = picture; while (*picptr) { if (*picptr == '1') { int number1 = va_arg (argptr, int); PUT_NUMBER1 (number1); } else if (*picptr == '2') { int number2 = va_arg (argptr, int); PUT_NUMBER2 (number2); } else if (*picptr == '4') { uint32_t number4 = va_arg (argptr, uint32_t); PUT_NUMBER4 (number4); } else if (*picptr == '8') { uint64_t number8 = va_arg (argptr, uint64_t); PUT_NUMBER8 (number8); } else if (*picptr == 'p') { void *pointer = va_arg (argptr, void *); memcpy (needle, &pointer, sizeof (void *)); needle += sizeof (void *); } else if (*picptr == 's') { char *string = va_arg (argptr, char *); if (!string) string = ""; size_t string_size = strlen (string); PUT_NUMBER1 ((byte) string_size); memcpy (needle, string, string_size); needle += string_size; } else if (*picptr == 'S') { char *string = va_arg (argptr, char *); if (!string) string = ""; size_t string_size = strlen (string); PUT_NUMBER4 (string_size); memcpy (needle, string, string_size); needle += string_size; } else if (*picptr == 'c') { zchunk_t *chunk = va_arg (argptr, zchunk_t *); if (chunk) { PUT_NUMBER4 (zchunk_size (chunk)); memcpy (needle, zchunk_data (chunk), zchunk_size (chunk)); needle += zchunk_size (chunk); } } else if (*picptr == 'u') { zuuid_t *uuid = va_arg (argptr, zuuid_t *); if (uuid) { memcpy (needle, zuuid_data (uuid), zuuid_size (uuid)); needle += zuuid_size (uuid); } } picptr++; } va_end (argptr); // Now send the data frame void *handle = zsock_resolve (self); zmq_msg_send (&msg, handle, nbr_frames? ZMQ_SNDMORE: 0); // Now send any additional frames unsigned int frame_nbr; for (frame_nbr = 0; frame_nbr < nbr_frames; frame_nbr++) { bool more = frame_nbr < nbr_frames - 1; zframe_send (&frames [frame_nbr], handle, ZFRAME_REUSE + (more? ZFRAME_MORE: 0)); } return 0; } // -------------------------------------------------------------------------- // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. Do not modify or destroy the returned // values. Returns 0 if successful, or -1 if it failed to read a message. // This is the largest size we allow for an incoming longstr or chunk (1M) #define MAX_ALLOC_SIZE 1024 * 1024 int zsock_brecv (void *selfish, const char *picture, ...) { assert (selfish); // Kind of self assert (picture); zmq_msg_t msg; zmq_msg_init (&msg); if (zmq_msg_recv (&msg, zsock_resolve (selfish), 0) == -1) return -1; // Interrupted // If we don't have a string cache, create one now with arbitrary // value; this will grow if needed. Do not use an initial size less // than 256, or cache expansion will not work properly. zsock_t *self = (zsock_t *) selfish; if (zactor_is (selfish)) self = zactor_sock ((zactor_t *) selfish); if (!self->cache) { self->cache = (char *) malloc (512); self->cache_size = 512; } // Last received strings are cached per socket uint cache_used = 0; byte *needle = (byte *) zmq_msg_data (&msg); byte *ceiling = needle + zmq_msg_size (&msg); va_list argptr; va_start (argptr, picture); const char *picptr = picture; while (*picptr) { if (*picptr == '1') { uint8_t *number1_p = va_arg (argptr, uint8_t *); GET_NUMBER1 (*number1_p); } else if (*picptr == '2') { uint16_t *number2_p = va_arg (argptr, uint16_t *); GET_NUMBER2 (*number2_p); } else if (*picptr == '4') { uint32_t *number4_p = va_arg (argptr, uint32_t *); GET_NUMBER4 (*number4_p); } else if (*picptr == '8') { uint64_t *number8_p = va_arg (argptr, uint64_t *); GET_NUMBER8 (*number8_p); } else if (*picptr == 'p') { void **pointer_p = va_arg (argptr, void **); memcpy (pointer_p, needle, sizeof (void *)); needle += sizeof (void *); } else if (*picptr == 's') { char **string_p = va_arg (argptr, char **); uint string_size; GET_NUMBER1 (string_size); if (needle + string_size > ceiling) goto malformed; // Expand cache if we need to; string is guaranteed to fit into // expansion space if (cache_used + string_size > self->cache_size) { puts ("REALLOC"); self->cache_size *= 2; self->cache = (char *) realloc (self->cache, self->cache_size); assert (self->cache); } *string_p = self->cache + cache_used; memcpy (*string_p, needle, string_size); cache_used += string_size; self->cache [cache_used++] = 0; needle += string_size; } else if (*picptr == 'S') { char **string_p = va_arg (argptr, char **); size_t string_size; GET_NUMBER4 (string_size); if (string_size > MAX_ALLOC_SIZE || needle + string_size > (ceiling)) goto malformed; *string_p = (char *) malloc (string_size + 1); assert (string_p); memcpy (*string_p, needle, string_size); (*string_p) [string_size] = 0; needle += string_size; } else if (*picptr == 'c') { zchunk_t **chunk_p = va_arg (argptr, zchunk_t **); size_t chunk_size; GET_NUMBER4 (chunk_size); if (chunk_size > MAX_ALLOC_SIZE || needle + chunk_size > (ceiling)) goto malformed; *chunk_p = zchunk_new (needle, chunk_size); needle += chunk_size; } else if (*picptr == 'u') { zuuid_t **uuid_p = va_arg (argptr, zuuid_t **); *uuid_p = zuuid_new (); if (zuuid_size (*uuid_p) > MAX_ALLOC_SIZE || needle + zuuid_size (*uuid_p) > (ceiling)) goto malformed; zuuid_set (*uuid_p, needle); needle += zuuid_size (*uuid_p); } else if (*picptr == 'f') { zframe_t **frame_p = va_arg (argptr, zframe_t **); // Get next frame off socket if (!zsock_rcvmore (self)) goto malformed; *frame_p = zframe_recv (self); } else if (*picptr == 'm') { if (picptr [1]) { zsys_error ("zsock_brecv: 'm' (zmsg) only valid at end of picptr"); assert (false); } zmsg_t **msg_p = va_arg (argptr, zmsg_t **); // Get zero or more remaining frames if (!zsock_rcvmore (self)) goto malformed; *msg_p = zmsg_recv (self); } else { zsys_error ("zsock_brecv: invalid picptr element '%c'", *picptr); assert (false); } picptr++; } va_end (argptr); zmq_msg_close (&msg); return 0; // Error return malformed: zmq_msg_close (&msg); return -1; // Invalid message } // -------------------------------------------------------------------------- // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void zsock_set_unbounded (void *self) { #if (ZMQ_VERSION_MAJOR == 2) zsock_set_hwm (self, 0); #else zsock_set_sndhwm (self, 0); zsock_set_rcvhwm (self, 0); #endif } // -------------------------------------------------------------------------- // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int zsock_signal (void *self, byte status) { assert (self); zmsg_t *msg = zmsg_new_signal (status); return zmsg_send (&msg, self); } // -------------------------------------------------------------------------- // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int zsock_wait (void *self) { assert (self); // Loop and discard messages until we get a signal value or interrupt. while (true) { zmsg_t *msg = zmsg_recv (self); if (!msg) return -1; int rc = zmsg_signal (msg); zmsg_destroy (&msg); if (rc >= 0) return rc; } return -1; } // -------------------------------------------------------------------------- // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void zsock_flush (void *self) { if (zsock_rcvmore (self)) { zmsg_t *msg = zmsg_recv (self); zmsg_destroy (&msg); } } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool zsock_is (void *self) { assert (self); return ((zsock_t *) self)->tag == ZSOCK_TAG; } // -------------------------------------------------------------------------- // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; elsie if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void * zsock_resolve (void *self) { assert (self); if (zsock_is (self)) return ((zsock_t *) self)->handle; else if (zactor_is (self)) return zactor_resolve (self); int sock_type = -1; // TODO: this code should move to zsys_isfd () #if defined (__WINDOWS__) int sock_type_size = sizeof (int); int rc = getsockopt (*(SOCKET *) self, SOL_SOCKET, SO_TYPE, (char *) &sock_type, &sock_type_size); if (rc == 0) return NULL; // It's a socket descriptor #else socklen_t sock_type_size = sizeof (socklen_t); int rc = getsockopt (*(SOCKET *) self, SOL_SOCKET, SO_TYPE, (char *) &sock_type, &sock_type_size); if (rc == 0 || (rc == -1 && errno == ENOTSOCK)) return NULL; // It's a socket FD or FD #endif // Socket appears to be something else, return it as-is return self; } // We use the gossip messages for some test cases #include "zgossip_msg.h" // -------------------------------------------------------------------------- // Selftest void zsock_test (bool verbose) { printf (" * zsock: "); if (verbose) printf ("\n"); // @selftest zsock_t *writer = zsock_new_push ("@tcp://127.0.0.1:5560"); assert (writer); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 5560); assert (streq (zsock_endpoint (writer), "tcp://127.0.0.1:5560")); #endif zsock_t *reader = zsock_new_pull (">tcp://127.0.0.1:5560"); assert (reader); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); // Basic Hello, World zstr_send (writer, "Hello, World"); zmsg_t *msg = zmsg_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); free (string); zmsg_destroy (&msg); // Test resolve FD SOCKET fd = zsock_fd (reader); assert (zsock_resolve ((void *) &fd) == NULL); // Test binding to ephemeral ports, sequential and random int port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60050]"); assert (port >= 60000 && port <= 60050); port = zsock_bind (writer, "tcp://127.0.0.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60050]"); assert (port >= 60000 && port <= 60050); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:5556,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == -1); zsock_destroy (&server); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test.writer")); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsock_connect (reader, "txp://127.0.0.1:5560"); assert (rc == -1); // Test signal/wait methods rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); // Test zsock_send/recv pictures uint8_t number1 = 123; uint16_t number2 = 123 * 123; uint32_t number4 = 123 * 123 * 123; uint64_t number8 = 123 * 123 * 123 * 123; zchunk_t *chunk = zchunk_new ("HELLO", 5); assert (chunk); zframe_t *frame = zframe_new ("WORLD", 5); assert (frame); zhashx_t *hash = zhashx_new (); assert (hash); zuuid_t *uuid = zuuid_new (); assert (uuid); zhashx_autofree (hash); zhashx_insert (hash, "1", "value A"); zhashx_insert (hash, "2", "value B"); char *original = "pointer"; // Test zsock_recv into each supported type zsock_send (writer, "i1248zsbcfUhp", -12345, number1, number2, number4, number8, "This is a string", "ABCDE", 5, chunk, frame, uuid, hash, original); char *uuid_str = strdup (zuuid_str (uuid)); zchunk_destroy (&chunk); zframe_destroy (&frame); zuuid_destroy (&uuid); zhashx_destroy (&hash); int integer; byte *data; size_t size; char *pointer; number8 = number4 = number2 = number1 = 0; rc = zsock_recv (reader, "i1248zsbcfUhp", &integer, &number1, &number2, &number4, &number8, &string, &data, &size, &chunk, &frame, &uuid, &hash, &pointer); assert (rc == 0); assert (integer == -12345); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "This is a string")); assert (memcmp (data, "ABCDE", 5) == 0); assert (size == 5); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); assert (streq (uuid_str, zuuid_str (uuid))); assert (memcmp (zframe_data (frame), "WORLD", 5) == 0); assert (zframe_size (frame) == 5); char *value = (char *) zhashx_lookup (hash, "1"); assert (streq (value, "value A")); value = (char *) zhashx_lookup (hash, "2"); assert (streq (value, "value B")); assert (original == pointer); free (string); free (data); free (uuid_str); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); // Test zsock_recv of short message; this lets us return a failure // with a status code and then nothing else; the receiver will get // the status code and NULL/zero for all other values zsock_send (writer, "i", -1); zsock_recv (reader, "izsbcfp", &integer, &string, &data, &size, &chunk, &frame, &pointer); assert (integer == -1); assert (string == NULL); assert (data == NULL); assert (size == 0); assert (chunk == NULL); assert (frame == NULL); assert (pointer == NULL); msg = zmsg_new (); zmsg_addstr (msg, "frame 1"); zmsg_addstr (msg, "frame 2"); zsock_send (writer, "szm", "header", msg); zmsg_destroy (&msg); zsock_recv (reader, "szm", &string, &msg); assert (streq ("header", string)); assert (zmsg_size (msg) == 2); assert (zframe_streq (zmsg_first (msg), "frame 1")); assert (zframe_streq (zmsg_next (msg), "frame 2")); zstr_free (&string); zmsg_destroy (&msg); // Test zsock_recv with null arguments chunk = zchunk_new ("HELLO", 5); assert (chunk); frame = zframe_new ("WORLD", 5); assert (frame); zsock_send (writer, "izsbcfp", -12345, "This is a string", "ABCDE", 5, chunk, frame, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL); assert (integer == -12345); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); zchunk_destroy (&chunk); // Test zsock_bsend/brecv pictures with binary encoding frame = zframe_new ("Hello", 5); chunk = zchunk_new ("World", 5); msg = zmsg_new (); zmsg_addstr (msg, "Hello"); zmsg_addstr (msg, "World"); zsock_bsend (writer, "1248sSpcfm", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk, frame, msg); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); number8 = number4 = number2 = number1 = 0; char *longstr; zsock_brecv (reader, "1248sSpcfm", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk, &frame, &msg); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); zstr_free (&longstr); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); // Check that we can send a zproto format message zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234); zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_recv (gossip, reader); assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH); zgossip_msg_destroy (&gossip); zsock_destroy (&reader); zsock_destroy (&writer); // @end printf ("OK\n"); } czmq-3.0.2/src/zcert.c0000664000175000017500000003572212512445545013672 0ustar00phph00000000000000/* ========================================================================= zcert - work with CURVE security certificates Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism. A certificate contains a public + secret key pair, plus metadata. It can be used as a temporary object in memory, or persisted to disk. On disk, a certificate is stored as two files. One is public and contains only the public key. The second is secret and contains both keys. The two have the same filename, with the secret file adding "_secret". To exchange certificates, send the public file via some secure route. Certificates are not signed but are text files that can be verified by eye. @discuss Certificates are stored in the ZPL (ZMQ RFC 4) format. They have two sections, "metadata" and "curve". The first contains a list of 'name = value' pairs, one per line. Values may be enclosed in quotes. The curve section has a 'public-key = keyvalue' and, for secret certificates, a 'secret-key = keyvalue' line. The keyvalue is a Z85-encoded CURVE key. @end */ #include "../include/czmq.h" // Structure of our class struct _zcert_t { byte public_key [32]; // Public key in binary byte secret_key [32]; // Secret key in binary char public_txt [41]; // Public key in Z85 text char secret_txt [41]; // Secret key in Z85 text zhash_t *metadata; // Certificate metadata zconfig_t *config; // Config tree to save }; // This is a null key, when curve is not available #define FORTY_ZEROES "0000000000000000000000000000000000000000" // -------------------------------------------------------------------------- // Constructor zcert_t * zcert_new (void) { byte public_key [32] = { 0 }; byte secret_key [32] = { 0 }; #if (ZMQ_VERSION_MAJOR == 4) if (zsys_has_curve ()) { char public_txt [41]; char secret_txt [41]; int rc = zmq_curve_keypair (public_txt, secret_txt); if (rc != 0) return NULL; zmq_z85_decode (public_key, public_txt); zmq_z85_decode (secret_key, secret_txt); } #endif return zcert_new_from (public_key, secret_key); } // -------------------------------------------------------------------------- // Constructor, accepts public/secret key pair from caller zcert_t * zcert_new_from (byte *public_key, byte *secret_key) { zcert_t *self = (zcert_t *) zmalloc (sizeof (zcert_t)); if (!self) return NULL; assert (public_key); assert (secret_key); self->metadata = zhash_new (); if (self->metadata) { zhash_autofree (self->metadata); memcpy (self->public_key, public_key, 32); memcpy (self->secret_key, secret_key, 32); #if (ZMQ_VERSION_MAJOR == 4) zmq_z85_encode (self->public_txt, self->public_key, 32); zmq_z85_encode (self->secret_txt, self->secret_key, 32); #else strcpy (self->public_txt, FORTY_ZEROES); strcpy (self->secret_txt, FORTY_ZEROES); #endif } else zcert_destroy (&self); return self; } // -------------------------------------------------------------------------- // Destructor void zcert_destroy (zcert_t **self_p) { assert (self_p); if (*self_p) { zcert_t *self = *self_p; zhash_destroy (&self->metadata); zconfig_destroy (&self->config); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return public part of key pair as 32-byte binary string byte * zcert_public_key (zcert_t *self) { assert (self); return self->public_key; } // -------------------------------------------------------------------------- // Return secret part of key pair as 32-byte binary string byte * zcert_secret_key (zcert_t *self) { assert (self); return self->secret_key; } // -------------------------------------------------------------------------- // Return public part of key pair as Z85 armored string char * zcert_public_txt (zcert_t *self) { assert (self); return self->public_txt; } // -------------------------------------------------------------------------- // Return secret part of key pair as Z85 armored string char * zcert_secret_txt (zcert_t *self) { assert (self); return self->secret_txt; } // -------------------------------------------------------------------------- // Set certificate metadata from formatted string. void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...) { va_list argptr; va_start (argptr, format); char *value = zsys_vprintf (format, argptr); va_end (argptr); assert (value); zhash_insert (self->metadata, name, value); free (value); } // -------------------------------------------------------------------------- // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. char * zcert_meta (zcert_t *self, const char *name) { assert (self); return (char *) zhash_lookup (self->metadata, name); } // -------------------------------------------------------------------------- // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. zlist_t * zcert_meta_keys (zcert_t *self) { assert (self); return zhash_keys (self->metadata); } // -------------------------------------------------------------------------- // Load certificate from file (constructor) zcert_t * zcert_load (const char *filename) { assert (filename); // Try first to load secret certificate, which has both keys // Then fallback to loading public certificate char filename_secret [256]; snprintf (filename_secret, 256, "%s_secret", filename); zconfig_t *root = zconfig_load (filename_secret); if (!root) root = zconfig_load (filename); zcert_t *self = NULL; if (root) { char *public_text = zconfig_get (root, "/curve/public-key", NULL); if (public_text && strlen (public_text) == 40) { byte public_key [32] = { 0 }; byte secret_key [32] = { 0 }; #if (ZMQ_VERSION_MAJOR == 4) char *secret_text = zconfig_get (root, "/curve/secret-key", NULL); zmq_z85_decode (public_key, public_text); if (secret_text && strlen (secret_text) == 40) zmq_z85_decode (secret_key, secret_text); #endif // Load metadata into certificate self = zcert_new_from (public_key, secret_key); zconfig_t *metadata = zconfig_locate (root, "/metadata"); zconfig_t *item = metadata ? zconfig_child (metadata) : NULL; while (item) { zcert_set_meta (self, zconfig_name (item), zconfig_value (item)); item = zconfig_next (item); } } } zconfig_destroy (&root); return self; } // -------------------------------------------------------------------------- // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). static void s_save_metadata_all (zcert_t *self) { zconfig_destroy (&self->config); self->config = zconfig_new ("root", NULL); assert (self->config); zconfig_t *section = zconfig_new ("metadata", self->config); char *value = (char *) zhash_first (self->metadata); while (value) { zconfig_t *item = zconfig_new (zhash_cursor (self->metadata), section); assert (item); zconfig_set_value (item, "%s", value); value = (char *) zhash_next (self->metadata); } char *timestr = zclock_timestr (); zconfig_set_comment (self->config, " **** Generated on %s by CZMQ ****", timestr); zstr_free (×tr); } int zcert_save (zcert_t *self, const char *filename) { assert (self); assert (filename); // Save public certificate using specified filename zcert_save_public (self, filename); // Now save secret certificate using filename with "_secret" suffix char filename_secret [256]; snprintf (filename_secret, 256, "%s_secret", filename); int rc = zcert_save_secret (self, filename_secret); return rc; } // -------------------------------------------------------------------------- // Save public certificate only to file for persistent storage. int zcert_save_public (zcert_t *self, const char *filename) { assert (self); assert (filename); s_save_metadata_all (self); zconfig_set_comment (self->config, " ZeroMQ CURVE Public Certificate"); zconfig_set_comment (self->config, " Exchange securely, or use a secure mechanism to verify the contents"); zconfig_set_comment (self->config, " of this file after exchange. Store public certificates in your home"); zconfig_set_comment (self->config, " directory, in the .curve subdirectory."); zconfig_put (self->config, "/curve/public-key", self->public_txt); int rc = zconfig_save (self->config, filename); return rc; } // -------------------------------------------------------------------------- // Save public certificate only to file for persistent storage. int zcert_save_secret (zcert_t *self, const char *filename) { assert (self); assert (filename); s_save_metadata_all (self); zconfig_set_comment (self->config, " ZeroMQ CURVE **Secret** Certificate"); zconfig_set_comment (self->config, " DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions."); zconfig_put (self->config, "/curve/public-key", self->public_txt); zconfig_put (self->config, "/curve/secret-key", self->secret_txt); zsys_file_mode_private (); int rc = zconfig_save (self->config, filename); zsys_file_mode_default (); return rc; } // -------------------------------------------------------------------------- // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void zcert_apply (zcert_t *self, void *zocket) { assert (self); #if (ZMQ_VERSION_MAJOR == 4) void *handle = zsock_resolve (zocket); if (zsys_has_curve ()) { zsock_set_curve_secretkey_bin (handle, self->secret_key); zsock_set_curve_publickey_bin (handle, self->public_key); } #endif } // -------------------------------------------------------------------------- // Return copy of certificate; if certificate is null or we exhausted // heap memory, returns null. zcert_t * zcert_dup (zcert_t *self) { if (self) { zcert_t *copy = zcert_new_from (self->public_key, self->secret_key); if (copy) { zhash_destroy (©->metadata); copy->metadata = zhash_dup (self->metadata); if (!copy->metadata) zcert_destroy (©); } return copy; } else return NULL; } // -------------------------------------------------------------------------- // Return true if two certificates have the same keys bool zcert_eq (zcert_t *self, zcert_t *compare) { assert (self); assert (compare); return ( streq (self->public_txt, compare->public_txt) && streq (self->secret_txt, compare->secret_txt)); } // -------------------------------------------------------------------------- // Print certificate contents to stdout void zcert_print (zcert_t *self) { assert (self); zsys_info ("zcert: metadata"); char *value = (char *) zhash_first (self->metadata); while (value) { zsys_info ("zcert: %s = \"%s\"", zhash_cursor (self->metadata), value); value = (char *) zhash_next (self->metadata); } zsys_info ("zcert: curve"); zsys_info ("zcert: public-key = \"%s\"", self->public_txt); zsys_info ("zcert: secret-key = \"%s\"", self->secret_txt); } // -------------------------------------------------------------------------- // DEPRECATED as incompatible with centralized logging // Print certificate contents to open stream void zcert_fprint (zcert_t *self, FILE *file) { assert (self); fprintf (file, "metadata\n"); char *value = (char *) zhash_first (self->metadata); while (value) { fprintf (file, " %s = \"%s\"\n", zhash_cursor (self->metadata), value); value = (char *) zhash_next (self->metadata); } fprintf (file, "curve\n"); fprintf (file, " public-key = \"%s\"\n", self->public_txt); fprintf (file, " secret-key = \"%s\"\n", self->secret_txt); } // -------------------------------------------------------------------------- // Selftest void zcert_test (bool verbose) { printf (" * zcert: "); // @selftest // Create temporary directory for test files # define TESTDIR ".test_zcert" zsys_dir_create (TESTDIR); // Create a simple certificate with metadata zcert_t *cert = zcert_new (); assert (cert); zcert_set_meta (cert, "email", "ph@imatix.com"); zcert_set_meta (cert, "name", "Pieter Hintjens"); zcert_set_meta (cert, "organization", "iMatix Corporation"); zcert_set_meta (cert, "version", "%d", 1); assert (streq (zcert_meta (cert, "email"), "ph@imatix.com")); zlist_t *keys = zcert_meta_keys (cert); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Check the dup and eq methods zcert_t *shadow = zcert_dup (cert); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Check we can save and load certificate zcert_save (cert, TESTDIR "/mycert.txt"); assert (zsys_file_exists (TESTDIR "/mycert.txt")); assert (zsys_file_exists (TESTDIR "/mycert.txt_secret")); // Load certificate, will in fact load secret one shadow = zcert_load (TESTDIR "/mycert.txt"); assert (shadow); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Delete secret certificate, load public one int rc = zsys_file_delete (TESTDIR "/mycert.txt_secret"); assert (rc == 0); shadow = zcert_load (TESTDIR "/mycert.txt"); // 32-byte null key encodes as 40 '0' characters assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES)); zcert_destroy (&shadow); zcert_destroy (&cert); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); // @end printf ("OK\n"); } czmq-3.0.2/src/zmonitor.c0000664000175000017500000002504312505070716014413 0ustar00phph00000000000000/* ========================================================================= zmonitor - socket event monitor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. @discuss This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Works on all versions of libzmq from 3.2 onwards. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller void *monitored; // Monitored libzmq socket zsock_t *sink; // Sink for monitor events int events; // Monitored event mask bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; #if defined (ZMQ_EVENT_ALL) zmq_socket_monitor (self->monitored, NULL, 0); #endif zpoller_destroy (&self->poller); zsock_destroy (&self->sink); free (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe, void *sock) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); if (!self) return NULL; self->pipe = pipe; self->monitored = zsock_resolve (sock); self->poller = zpoller_new (self->pipe, NULL); if (!self->poller) s_self_destroy (&self); return self; } // -------------------------------------------------------------------------- // Add listener for specified event static void s_self_listen (self_t *self, const char *event) { #if defined (ZMQ_EVENT_ALL) if (streq (event, "CONNECTED")) self->events |= ZMQ_EVENT_CONNECTED; else if (streq (event, "CONNECT_DELAYED")) self->events |= ZMQ_EVENT_CONNECT_DELAYED; else if (streq (event, "CONNECT_RETRIED")) self->events |= ZMQ_EVENT_CONNECT_RETRIED; else if (streq (event, "LISTENING")) self->events |= ZMQ_EVENT_LISTENING; else if (streq (event, "BIND_FAILED")) self->events |= ZMQ_EVENT_BIND_FAILED; else if (streq (event, "ACCEPTED")) self->events |= ZMQ_EVENT_ACCEPTED; else if (streq (event, "ACCEPT_FAILED")) self->events |= ZMQ_EVENT_ACCEPT_FAILED; else if (streq (event, "CLOSED")) self->events |= ZMQ_EVENT_CLOSED; else if (streq (event, "CLOSE_FAILED")) self->events |= ZMQ_EVENT_CLOSE_FAILED; else if (streq (event, "DISCONNECTED")) self->events |= ZMQ_EVENT_DISCONNECTED; else #if (ZMQ_VERSION_MAJOR == 4) if (streq (event, "MONITOR_STOPPED")) self->events |= ZMQ_EVENT_MONITOR_STOPPED; else #endif if (streq (event, "ALL")) self->events |= ZMQ_EVENT_ALL; else zsys_warning ("zmonitor: - invalid listen event=%s", event); #endif } // -------------------------------------------------------------------------- // Start monitoring static void s_self_start (self_t *self) { assert (!self->sink); char *endpoint = zsys_sprintf ("inproc://zmonitor-%p", self->monitored); assert (endpoint); int rc; #if defined (ZMQ_EVENT_ALL) rc = zmq_socket_monitor (self->monitored, endpoint, self->events); assert (rc == 0); #endif self->sink = zsock_new (ZMQ_PAIR); assert (self->sink); rc = zsock_connect (self->sink, "%s", endpoint); assert (rc == 0); zpoller_add (self->poller, self->sink); free (endpoint); } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (!command) { s_self_destroy (&self); return -1; } if (self->verbose) zsys_info ("zmonitor: API command=%s", command); if (streq (command, "LISTEN")) { char *event = zmsg_popstr (request); while (event) { if (self->verbose) zsys_info ("zmonitor: - listening to event=%s", event); s_self_listen (self, event); zstr_free (&event); event = zmsg_popstr (request); } } else if (streq (command, "START")) { s_self_start (self); zsock_signal (self->pipe, 0); } else if (streq (command, "VERBOSE")) self->verbose = true; else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zmonitor: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // Handle event from socket monitor static void s_self_handle_sink (self_t *self) { #if defined (ZMQ_EVENT_ALL) #if (ZMQ_VERSION_MAJOR == 4) // First frame is event number and value zframe_t *frame = zframe_recv (self->sink); int event = *(uint16_t *) (zframe_data (frame)); int value = *(uint32_t *) (zframe_data (frame) + 2); // Address is in second message frame char *address = zstr_recv (self->sink); zframe_destroy (&frame); #elif (ZMQ_VERSION_MAJOR == 3 && ZMQ_VERSION_MINOR == 2) // zmq_event_t is passed as-is in the frame zframe_t *frame = zframe_recv (self->sink); zmq_event_t *eptr = (zmq_event_t *) zframe_data (frame); int event = eptr->event; int value = eptr->data.listening.fd; char *address = strdup (eptr->data.listening.addr); assert (address); zframe_destroy (&frame); #else // We can't plausibly be here with other versions of libzmq assert (false); #endif // Now map event to text equivalent char *name; switch (event) { case ZMQ_EVENT_ACCEPTED: name = "ACCEPTED"; break; case ZMQ_EVENT_ACCEPT_FAILED: name = "ACCEPT_FAILED"; break; case ZMQ_EVENT_BIND_FAILED: name = "BIND_FAILED"; break; case ZMQ_EVENT_CLOSED: name = "CLOSED"; break; case ZMQ_EVENT_CLOSE_FAILED: name = "CLOSE_FAILED"; break; case ZMQ_EVENT_DISCONNECTED: name = "DISCONNECTED"; break; case ZMQ_EVENT_CONNECTED: name = "CONNECTED"; break; case ZMQ_EVENT_CONNECT_DELAYED: name = "CONNECT_DELAYED"; break; case ZMQ_EVENT_CONNECT_RETRIED: name = "CONNECT_RETRIED"; break; case ZMQ_EVENT_LISTENING: name = "LISTENING"; break; #if (ZMQ_VERSION_MAJOR == 4) case ZMQ_EVENT_MONITOR_STOPPED: name = "MONITOR_STOPPED"; break; #endif default: zsys_error ("illegal socket monitor event: %d", event); name = "UNKNOWN"; break; } if (self->verbose) zsys_info ("zmonitor: %s - %s", name, address); zstr_sendfm (self->pipe, "%s", name); zstr_sendfm (self->pipe, "%d", value); zstr_send (self->pipe, address); free (address); #endif } // -------------------------------------------------------------------------- // zmonitor() implements the zmonitor actor interface void zmonitor (zsock_t *pipe, void *sock) { self_t *self = s_self_new (pipe, sock); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (which == self->sink) s_self_handle_sink (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest #if defined (ZMQ_EVENT_ALL) static void s_assert_event (zactor_t *self, char *expected) { zmsg_t *msg = zmsg_recv (self); assert (msg); char *event = zmsg_popstr (msg); assert (streq (event, expected)); free (event); zmsg_destroy (&msg); } #endif void zmonitor_test (bool verbose) { printf (" * zmonitor: "); if (verbose) printf ("\n"); #if defined (ZMQ_EVENT_ALL) // @selftest zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zactor_t *clientmon = zactor_new (zmonitor, client); assert (clientmon); if (verbose) zstr_sendx (clientmon, "VERBOSE", NULL); zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL); zstr_sendx (clientmon, "START", NULL); zsock_wait (clientmon); zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon); // Allow a brief time for the message to get there... zmq_poll (NULL, 0, 200); // Check client is now listening int port_nbr = zsock_bind (client, "tcp://127.0.0.1:*"); assert (port_nbr != -1); s_assert_event (clientmon, "LISTENING"); // Check server connected to client zsock_connect (server, "tcp://127.0.0.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED"); // Check client accepted connection s_assert_event (clientmon, "ACCEPTED"); zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif // @end printf ("OK\n"); } czmq-3.0.2/src/czmq_classes.h0000664000175000017500000000255612535241704015232 0ustar00phph00000000000000/* ========================================================================= czmq_classes - private header file Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ ========================================================================= */ #ifndef CZMQ_CLASSES_H_INCLUDED #define CZMQ_CLASSES_H_INCLUDED // External API #include "../include/czmq.h" // Internal API #include "zgossip_msg.h" #endif czmq-3.0.2/src/zloop.c0000664000175000017500000007727712522736135013720 0ustar00phph00000000000000/* ========================================================================= zloop - event-driven reactor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zloop class provides an event-driven reactor pattern. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once-off or repeated timers. Its resolution is 1 msec. It uses a tickless timer to reduce CPU interrupts in inactive processes. @discuss @end */ #include "../include/czmq.h" typedef struct _s_reader_t s_reader_t; typedef struct _s_poller_t s_poller_t; typedef struct _s_timer_t s_timer_t; typedef struct _s_ticket_t s_ticket_t; // Structure of our class struct _zloop_t { zlistx_t *readers; // List of socket readers zlistx_t *pollers; // List of poll items zlistx_t *timers; // List of timers zlistx_t *tickets; // List of tickets int last_timer_id; // Most recent timer id size_t max_timers; // Limit on number of timers size_t ticket_delay; // Ticket delay value size_t poll_size; // Size of poll set zmq_pollitem_t *pollset; // zmq_poll set s_reader_t *readact; // Readers for this poll set s_poller_t *pollact; // Pollers for this poll set bool need_rebuild; // True if pollset needs rebuilding bool verbose; // True if verbose tracing wanted bool terminated; // True when stopped running bool ignore_interrupts; // True when this loop should ingnore intterupts zlistx_t *zombies; // List of timers to kill }; // Reactor elements are held as structures of their own struct _s_reader_t { void *list_handle; // Handle into list zsock_t *sock; // Socket to read from zloop_reader_fn *handler; // Function to execute void *arg; // Application argument to poll item int errors; // If too many errors, kill reader bool tolerant; // Unless configured as tolerant }; struct _s_poller_t { void *list_handle; // Handle into list zmq_pollitem_t item; // ZeroMQ socket or file descriptor zloop_fn *handler; // Function to execute void *arg; // Application argument to poll item int errors; // If too many errors, kill poller bool tolerant; // Unless configured as tolerant }; struct _s_timer_t { void *list_handle; // Handle into list int timer_id; // Unique timer id, used to cancel timer zloop_timer_fn *handler; // Function to execute size_t delay; // Delay (ms) between executing size_t times; // Number of times to repeat, 0 for forever void *arg; // Application argument to timer int64_t when; // Clock time when alarm goes off }; // As we pass void * to/from the caller for working with tickets, we // check validity using an object tag. This value is unique in CZMQ. #define TICKET_TAG 0x0007cafe struct _s_ticket_t { uint32_t tag; // Object tag for runtime detection void *list_handle; // Handle into list size_t delay; // Delay (ms) before executing int64_t when; // Clock time to invoke the ticket zloop_timer_fn *handler; // Function to execute (use timer fn) void *arg; // Application argument to function bool deleted; // Flag as deleted (to clean up later) }; static int s_next_timer_id (zloop_t *self) { return ++self->last_timer_id; } static s_reader_t * s_reader_new (zsock_t *sock, zloop_reader_fn handler, void *arg) { s_reader_t *self = (s_reader_t *) zmalloc (sizeof (s_reader_t)); if (self) { self->sock = sock; self->handler = handler; self->arg = arg; self->tolerant = false; // By default, errors are bad } return self; } static void s_reader_destroy (s_reader_t **self_p) { assert (self_p); s_reader_t *self = *self_p; if (self) { free (self); *self_p = NULL; } } static s_poller_t * s_poller_new (zmq_pollitem_t *item, zloop_fn handler, void *arg) { s_poller_t *self = (s_poller_t *) zmalloc (sizeof (s_poller_t)); if (self) { self->item = *item; self->handler = handler; self->arg = arg; self->tolerant = false; // By default, errors are bad } return self; } static void s_poller_destroy (s_poller_t **self_p) { assert (self_p); s_poller_t *self = *self_p; if (self) { free (self); *self_p = NULL; } } static s_timer_t * s_timer_new (int timer_id, size_t delay, size_t times, zloop_timer_fn handler, void *arg) { s_timer_t *self = (s_timer_t *) zmalloc (sizeof (s_timer_t)); if (self) { self->timer_id = timer_id; self->delay = delay; self->times = times; self->when = zclock_mono () + delay; self->handler = handler; self->arg = arg; } return self; } static void s_timer_destroy (s_timer_t **self_p) { assert (self_p); s_timer_t *self = *self_p; if (self) { free (self); *self_p = NULL; } } static int s_timer_comparator (s_timer_t *timer1, s_timer_t *timer2) { if (timer1->when > timer2->when) return 1; else if (timer1->when < timer2->when) return -1; else return 0; } static s_ticket_t * s_ticket_new (size_t delay, zloop_timer_fn handler, void *arg) { s_ticket_t *self = (s_ticket_t *) zmalloc (sizeof (s_ticket_t)); if (self) { self->tag = TICKET_TAG; self->delay = delay; self->when = zclock_mono () + delay; self->handler = handler; self->arg = arg; } return self; } static void s_ticket_destroy (s_ticket_t **self_p) { assert (self_p); s_ticket_t *self = *self_p; if (self) { self->tag = 0xDeadBeef; free (self); *self_p = NULL; } } static int s_ticket_comparator (s_ticket_t *ticket1, s_ticket_t *ticket2) { if (ticket1->when > ticket2->when) return 1; else if (ticket1->when < ticket2->when) return -1; else return 0; } // Remove timer with specified id, if it exists static void s_timer_remove (zloop_t *self, int timer_id) { s_timer_t *timer = (s_timer_t *) zlistx_first (self->timers); while (timer) { if (timer->timer_id == timer_id) { zlistx_delete (self->timers, timer->list_handle); break; } timer = (s_timer_t *) zlistx_next (self->timers); } } // We hold an array of pollers that matches the pollset, so we can // register/cancel pollers orthogonally to executing the pollset // activity on pollers. Returns 0 on success, -1 on failure. static int s_rebuild_pollset (zloop_t *self) { free (self->pollset); free (self->readact); free (self->pollact); self->pollset = NULL; self->readact = NULL; self->pollact = NULL; self->poll_size = zlistx_size (self->readers) + zlistx_size (self->pollers); self->pollset = (zmq_pollitem_t *) zmalloc (self->poll_size * sizeof (zmq_pollitem_t)); if (!self->pollset) return -1; self->readact = (s_reader_t *) zmalloc (self->poll_size * sizeof (s_reader_t)); if (!self->readact) return -1; self->pollact = (s_poller_t *) zmalloc (self->poll_size * sizeof (s_poller_t)); if (!self->pollact) return -1; s_reader_t *reader = (s_reader_t *) zlistx_first (self->readers); uint item_nbr = 0; while (reader) { zmq_pollitem_t poll_item = { zsock_resolve (reader->sock), 0, ZMQ_POLLIN }; self->pollset [item_nbr] = poll_item; self->readact [item_nbr] = *reader; item_nbr++; reader = (s_reader_t *) zlistx_next (self->readers); } s_poller_t *poller = (s_poller_t *) zlistx_first (self->pollers); while (poller) { self->pollset [item_nbr] = poller->item; self->pollact [item_nbr] = *poller; item_nbr++; poller = (s_poller_t *) zlistx_next (self->pollers); } self->need_rebuild = false; return 0; } static long s_tickless (zloop_t *self) { // Calculate tickless timer, up to 1 hour int64_t tickless = zclock_mono () + 1000 * 3600; // Scan timers, which are not sorted // TODO: sort timers properly on insertion s_timer_t *timer = (s_timer_t *) zlistx_first (self->timers); while (timer) { // Find earliest timer if (tickless > timer->when) tickless = timer->when; timer = (s_timer_t *) zlistx_next (self->timers); } // Tickets are sorted, so check first ticket s_ticket_t *ticket = (s_ticket_t *) zlistx_first (self->tickets); if (ticket && tickless > ticket->when) tickless = ticket->when; long timeout = (long) (tickless - zclock_mono ()); if (timeout < 0) timeout = 0; if (self->verbose) zsys_debug ("zloop polling for %d msec", (int) timeout); return timeout * ZMQ_POLL_MSEC; } // -------------------------------------------------------------------------- // Constructor zloop_t * zloop_new (void) { zloop_t *self; self = (zloop_t *) zmalloc (sizeof (zloop_t)); if (!self) return NULL; self->readers = zlistx_new (); if (self->readers) self->pollers = zlistx_new (); if (self->pollers) self->timers = zlistx_new (); if (self->timers) self->zombies = zlistx_new (); if (self->zombies) self->tickets = zlistx_new (); if (self->tickets) { self->last_timer_id = 0; zlistx_set_destructor (self->readers, (czmq_destructor *) s_reader_destroy); zlistx_set_destructor (self->pollers, (czmq_destructor *) s_poller_destroy); zlistx_set_destructor (self->timers, (czmq_destructor *) s_timer_destroy); zlistx_set_comparator (self->timers, (czmq_comparator *) s_timer_comparator); zlistx_set_destructor (self->tickets, (czmq_destructor *) s_ticket_destroy); zlistx_set_comparator (self->tickets, (czmq_comparator *) s_ticket_comparator); } else zloop_destroy (&self); return self; } // -------------------------------------------------------------------------- // Destructor void zloop_destroy (zloop_t **self_p) { assert (self_p); if (*self_p) { zloop_t *self = *self_p; // If we never started the loop, yet manipulated timers, we'll have // a zombie list while (zlistx_first (self->zombies)) { // Get timer_id back from pointer ptrdiff_t timer_id = (byte *) zlistx_detach (self->zombies, NULL) - (byte *) NULL; s_timer_remove (self, (int) timer_id); } zlistx_destroy (&self->zombies); zlistx_destroy (&self->readers); zlistx_destroy (&self->pollers); zlistx_destroy (&self->timers); zlistx_destroy (&self->tickets); free (self->pollset); free (self->readact); free (self->pollact); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg) { assert (self); assert (sock); s_reader_t *reader = s_reader_new (sock, handler, arg); if (reader) { reader->list_handle = zlistx_add_end (self->readers, reader); if (!reader->list_handle) { s_reader_destroy (&reader); return -1; } self->need_rebuild = true; if (self->verbose) zsys_debug ("zloop: register %s reader", zsock_type_str (sock)); return 0; } else return -1; } // -------------------------------------------------------------------------- // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void zloop_reader_end (zloop_t *self, zsock_t *sock) { assert (self); assert (sock); s_reader_t *reader = (s_reader_t *) zlistx_first (self->readers); while (reader) { if (reader->sock == sock) { zlistx_delete (self->readers, reader->list_handle); self->need_rebuild = true; } reader = (s_reader_t *) zlistx_next (self->readers); } if (self->verbose) zsys_debug ("zloop: cancel %s reader", zsock_type_str (sock)); } // -------------------------------------------------------------------------- // Configure a registered reader to ignore errors. If you do not set this, // then reader that have errors are removed from the reactor silently. void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock) { assert (self); assert (sock); s_reader_t *reader = (s_reader_t *) zlistx_first (self->readers); while (reader) { if (reader->sock == sock) reader->tolerant = true; reader = (s_reader_t *) zlistx_next (self->readers); } } // -------------------------------------------------------------------------- // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg) { assert (self); if (item->socket && streq (zsys_sockname (zsock_type (item->socket)), "UNKNOWN")) return -1; s_poller_t *poller = s_poller_new (item, handler, arg); if (poller) { poller->list_handle = zlistx_add_end (self->pollers, poller); if (!poller->list_handle) { s_poller_destroy (&poller); return -1; } self->need_rebuild = true; if (self->verbose) zsys_debug ("zloop: register %s poller (%p, %d)", item->socket? zsys_sockname (zsock_type (item->socket)): "FD", item->socket, item->fd); return 0; } else return -1; } // -------------------------------------------------------------------------- // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item) { assert (self); s_poller_t *poller = (s_poller_t *) zlistx_first (self->pollers); while (poller) { bool match = false; if (item->socket) { if (item->socket == poller->item.socket) match = true; } else { if (item->fd == poller->item.fd) match = true; } if (match) { zlistx_delete (self->pollers, poller->list_handle); // Force rebuild to avoid reading from freed poller self->need_rebuild = true; } poller = (s_poller_t *) zlistx_next (self->pollers); } if (self->verbose) zsys_debug ("zloop: cancel %s poller (%p, %d)", item->socket? zsys_sockname (zsock_type (item->socket)): "FD", item->socket, item->fd); } // -------------------------------------------------------------------------- // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item) { assert (self); // Find matching poller(s) and mark as tolerant s_poller_t *poller = (s_poller_t *) zlistx_first (self->pollers); while (poller) { bool match = false; if (item->socket) { if (item->socket == poller->item.socket) match = true; } else { if (item->fd == poller->item.fd) match = true; } if (match) poller->tolerant = true; poller = (s_poller_t *) zlistx_next (self->pollers); } } // -------------------------------------------------------------------------- // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. // // TODO: if we returned a void *handle to the timer then we could work // directly into the list rather than scanning... how to do this without // breaking the API or making the code horribly complex? int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg) { assert (self); // Catch excessive use of timers if (self->max_timers && zlistx_size (self->timers) == self->max_timers) { zsys_error ("zloop: timer limit reached (max=%d)", self->max_timers); return -1; } int timer_id = s_next_timer_id (self); s_timer_t *timer = s_timer_new (timer_id, delay, times, handler, arg); if (timer) { timer->list_handle = zlistx_add_end (self->timers, timer); if (!timer->list_handle) { s_timer_destroy (&timer); return -1; } if (self->verbose) zsys_debug ("zloop: register timer id=%d delay=%d times=%d", timer_id, (int) delay, (int) times); return timer_id; } else return -1; } // -------------------------------------------------------------------------- // Cancel a timer by timer id (as returned by zloop_timer()). // Returns 0 on success. int zloop_timer_end (zloop_t *self, int timer_id) { assert (self); if (self->terminated) s_timer_remove (self, timer_id); else // We cannot touch self->timers because we may be executing that // from inside the poll loop. So, we hold the arg on the zombie // list, and process that list when we're done executing timers. // This hack lets us store an integer timer ID as a pointer if (zlistx_add_end (self->zombies, (byte *) NULL + timer_id) == NULL) return -1; if (self->verbose) zsys_debug ("zloop: cancel timer id=%d", timer_id); return 0; } // -------------------------------------------------------------------------- // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg) { assert (self); assert (self->ticket_delay > 0); s_ticket_t *ticket = s_ticket_new (self->ticket_delay, handler, arg); if (ticket) { ticket->list_handle = zlistx_add_end (self->tickets, ticket); if (!ticket->list_handle) s_ticket_destroy (&ticket); } return ticket; } // -------------------------------------------------------------------------- // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void zloop_ticket_reset (zloop_t *self, void *handle) { s_ticket_t *ticket = (s_ticket_t *) handle; assert (ticket->tag == TICKET_TAG); ticket->when = zclock_mono () + ticket->delay; zlistx_move_end (self->tickets, ticket->list_handle); } // -------------------------------------------------------------------------- // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void zloop_ticket_delete (zloop_t *self, void *handle) { s_ticket_t *ticket = (s_ticket_t *) handle; assert (ticket->tag == TICKET_TAG); ticket->deleted = true; // Move deleted tickets to end of list for fast cleanup zlistx_move_end (self->tickets, ticket->list_handle); } // -------------------------------------------------------------------------- // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay) { assert (self); self->ticket_delay = ticket_delay; } // -------------------------------------------------------------------------- // Set verbose tracing of reactor on/off void zloop_set_verbose (zloop_t *self, bool verbose) { assert (self); self->verbose = verbose; } // -------------------------------------------------------------------------- // Ignore zsys_interrupted flag in this loop. By default, a zloop_start will // exit as soon as it detects zsys_interrupted is set to something other than // zero. Calling zloop_ignore_interrupts will supress this behavior. void zloop_ignore_interrupts(zloop_t *self) { assert (self); self->ignore_interrupts = true; } // -------------------------------------------------------------------------- // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void zloop_set_max_timers (zloop_t *self, size_t max_timers) { assert (self); self->max_timers = max_timers; } // -------------------------------------------------------------------------- // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler, // positive on internal error int zloop_start (zloop_t *self) { assert (self); int rc = 0; // Main reactor loop while (self->ignore_interrupts || !zsys_interrupted) { if (self->need_rebuild) { // If s_rebuild_pollset() fails, break out of the loop and // return its error rc = s_rebuild_pollset (self); if (rc) break; } rc = zmq_poll (self->pollset, (int) self->poll_size, s_tickless (self)); if (rc == -1 || (!self->ignore_interrupts && zsys_interrupted)) { if (self->verbose) zsys_debug ("zloop: interrupted"); rc = 0; break; // Context has been shut down } // Handle any timers that have now expired int64_t time_now = zclock_mono (); s_timer_t *timer = (s_timer_t *) zlistx_first (self->timers); while (timer) { if (time_now >= timer->when) { if (self->verbose) zsys_debug ("zloop: call timer handler id=%d", timer->timer_id); rc = timer->handler (self, timer->timer_id, timer->arg); if (rc == -1) break; // Timer handler signaled break if (timer->times && --timer->times == 0) zlistx_delete (self->timers, timer->list_handle); else timer->when += timer->delay; } timer = (s_timer_t *) zlistx_next (self->timers); } // Handle any tickets that have now expired s_ticket_t *ticket = (s_ticket_t *) zlistx_first (self->tickets); while (ticket && time_now >= ticket->when) { if (self->verbose) zsys_debug ("zloop: call ticket handler"); if (ticket->handler (self, 0, ticket->arg) == -1) break; // Timer handler signaled break zlistx_delete (self->tickets, ticket->list_handle); ticket = (s_ticket_t *) zlistx_next (self->tickets); } // Handle any tickets that were flagged for deletion ticket = (s_ticket_t *) zlistx_last (self->tickets); while (ticket && ticket->deleted) { zlistx_delete (self->tickets, ticket->list_handle); ticket = (s_ticket_t *) zlistx_last (self->tickets); } // Handle any readers and pollers that are ready size_t item_nbr; for (item_nbr = 0; item_nbr < self->poll_size && rc >= 0; item_nbr++) { s_reader_t *reader = &self->readact [item_nbr]; if (reader->handler) { if ((self->pollset [item_nbr].revents & ZMQ_POLLERR) && !reader->tolerant) { if (self->verbose) zsys_warning ("zloop: can't read %s socket: %s", zsock_type_str (reader->sock), zmq_strerror (zmq_errno ())); // Give handler one chance to handle error, then kill // reader because it'll disrupt the reactor otherwise. if (reader->errors++) { zloop_reader_end (self, reader->sock); self->pollset [item_nbr].revents = 0; } } else reader->errors = 0; // A non-error happened if (self->pollset [item_nbr].revents) { if (self->verbose) zsys_debug ("zloop: call %s socket handler", zsock_type_str (reader->sock)); rc = reader->handler (self, reader->sock, reader->arg); if (rc == -1 || self->need_rebuild) break; } } else { s_poller_t *poller = &self->pollact [item_nbr]; assert (self->pollset [item_nbr].socket == poller->item.socket); if ((self->pollset [item_nbr].revents & ZMQ_POLLERR) && !poller->tolerant) { if (self->verbose) zsys_warning ("zloop: can't poll %s socket (%p, %d): %s", poller->item.socket ? zsys_sockname (zsock_type (poller->item.socket)) : "FD", poller->item.socket, poller->item.fd, zmq_strerror (zmq_errno ())); // Give handler one chance to handle error, then kill // poller because it'll disrupt the reactor otherwise. if (poller->errors++) { zloop_poller_end (self, &poller->item); self->pollset [item_nbr].revents = 0; } } else poller->errors = 0; // A non-error happened if (self->pollset [item_nbr].revents) { if (self->verbose) zsys_debug ("zloop: call %s socket handler (%p, %d)", poller->item.socket ? zsys_sockname (zsock_type (poller->item.socket)) : "FD", poller->item.socket, poller->item.fd); rc = poller->handler (self, &self->pollset [item_nbr], poller->arg); if (rc == -1 || self->need_rebuild) break; } } } // Now handle any timer zombies // This is going to be slow if we have many timers; we might use // a faster lookup on the timer list. while (zlistx_first (self->zombies)) { // Get timer_id back from pointer ptrdiff_t timer_id = (byte *) zlistx_detach (self->zombies, NULL) - (byte *) NULL; s_timer_remove (self, (int) timer_id); } if (rc == -1) break; } self->terminated = true; return rc; } // -------------------------------------------------------------------------- // Selftest static int s_cancel_timer_event (zloop_t *loop, int timer_id, void *arg) { // We are handling timer 2, and will cancel timer 1 int cancel_timer_id = *((int *) arg); return zloop_timer_end (loop, cancel_timer_id); } static int s_timer_event (zloop_t *loop, int timer_id, void *output) { zstr_send (output, "PING"); return 0; } static int s_socket_event (zloop_t *loop, zsock_t *handle, void *arg) { // Just end the reactor return -1; } static int s_timer_event3 (zloop_t *loop, int timer_id, void *called) { *((bool*) called) = true; // end the reactor return -1; } void zloop_test (bool verbose) { printf (" * zloop: "); int rc = 0; // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); zsock_bind (output, "inproc://zloop.test"); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); zsock_connect (input, "inproc://zloop.test"); zloop_t *loop = zloop_new (); assert (loop); zloop_set_verbose (loop, verbose); // Create a timer that will be cancelled int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL); zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id); // After 20 msecs, send a ping message to output3 zloop_timer (loop, 20, 1, s_timer_event, output); // Set up some tickets that will never expire zloop_set_ticket_delay (loop, 10000); void *ticket1 = zloop_ticket (loop, s_timer_event, NULL); void *ticket2 = zloop_ticket (loop, s_timer_event, NULL); void *ticket3 = zloop_ticket (loop, s_timer_event, NULL); // When we get the ping message, end the reactor rc = zloop_reader (loop, input, s_socket_event, NULL); assert (rc == 0); zloop_reader_set_tolerant (loop, input); zloop_start (loop); zloop_ticket_delete (loop, ticket1); zloop_ticket_delete (loop, ticket2); zloop_ticket_delete (loop, ticket3); // Check whether loop properly ignores zsys_interrupted flag // when asked to zloop_destroy (&loop); loop = zloop_new (); bool timer_event_called = false; zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called); zsys_interrupted = 1; zloop_start (loop); // zloop returns immediately without giving any handler a chance to run assert (!timer_event_called); zloop_ignore_interrupts (loop); zloop_start (loop); // zloop runs the handler which will terminate the loop assert (timer_event_called); zsys_interrupted = 0; // cleanup zloop_destroy (&loop); assert (loop == NULL); zsock_destroy (&input); zsock_destroy (&output); // @end printf ("OK\n"); } czmq-3.0.2/src/zuuid.c0000664000175000017500000002167012523062450013670 0ustar00phph00000000000000/* ========================================================================= zuuid - UUID support class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zuuid class generates UUIDs and provides methods for working with them. If you build CZMQ with libuuid, on Unix/Linux, it will use that library. On Windows it will use UuidCreate(). Otherwise it will use a random number generator to produce convincing imitations of uuids. @discuss @end */ #include "platform.h" #include "../include/czmq.h" // Structure of our class struct _zuuid_t { byte uuid [ZUUID_LEN]; // Binary UUID char str [ZUUID_STR_LEN + 1]; // Printable UUID char *str_canonical; // Canonical UUID, if any }; // -------------------------------------------------------------------------- // Constructor zuuid_t * zuuid_new (void) { zuuid_t *self = (zuuid_t *) zmalloc (sizeof (zuuid_t)); if (self) { #if defined (HAVE_LIBUUID) # if defined (__WINDOWS__) UUID uuid; assert (sizeof (uuid) == ZUUID_LEN); UuidCreate (&uuid); zuuid_set (self, (byte *) &uuid); # elif defined (__UTYPE_OPENBSD) || defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) uuid_t uuid; uint32_t status = 0; uuid_create (&uuid, &status); if (status != uuid_s_ok) { zuuid_destroy (&self); return NULL; } byte buffer [ZUUID_LEN]; uuid_enc_be (&buffer, &uuid); zuuid_set (self, buffer); # elif defined (__UTYPE_LINUX) || defined (__UTYPE_OSX) uuid_t uuid; assert (sizeof (uuid) == ZUUID_LEN); uuid_generate (uuid); zuuid_set (self, (byte *) uuid); # else # error "Unknow UNIX TYPE" # endif #else // No UUID system calls, so generate a random string byte uuid [ZUUID_LEN]; int fd = open ("/dev/urandom", O_RDONLY); if (fd != -1) { ssize_t bytes_read = read (fd, uuid, ZUUID_LEN); assert (bytes_read == ZUUID_LEN); close (fd); zuuid_set (self, uuid); } else // We couldn't read /dev/urandom and we have no alternative // strategy assert (false); #endif } return self; } // ----------------------------------------------------------------- // Destructor void zuuid_destroy (zuuid_t **self_p) { assert (self_p); if (*self_p) { zuuid_t *self = *self_p; free (self->str_canonical); free (self); *self_p = NULL; } } // ----------------------------------------------------------------- // Create UUID object from supplied ZUUID_LEN-octet value zuuid_t * zuuid_new_from (const byte *source) { zuuid_t *self = (zuuid_t *) zmalloc (sizeof (zuuid_t)); if (self) zuuid_set (self, source); return self; } // ----------------------------------------------------------------- // Set UUID to new supplied ZUUID_LEN-octet value void zuuid_set (zuuid_t *self, const byte *source) { assert (self); memcpy (self->uuid, source, ZUUID_LEN); char hex_char [] = "0123456789ABCDEF"; int byte_nbr; for (byte_nbr = 0; byte_nbr < ZUUID_LEN; byte_nbr++) { uint val = (self->uuid) [byte_nbr]; self->str [byte_nbr * 2 + 0] = hex_char [val >> 4]; self->str [byte_nbr * 2 + 1] = hex_char [val & 15]; } self->str [ZUUID_LEN * 2] = 0; zstr_free (&self->str_canonical); } // ----------------------------------------------------------------- // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int zuuid_set_str (zuuid_t *self, const char *source) { assert (self); assert (source); uint byte_nbr = 0; while (*source) { if (*source == '-' || *source == '{' || *source == '}') source++; else { // Get two hex digits uint value; if (sscanf (source, "%02x", &value) != 1) return -1; if (byte_nbr < ZUUID_LEN) { self->uuid [byte_nbr] = (byte) value; self->str [byte_nbr * 2 + 0] = *source++; self->str [byte_nbr * 2 + 1] = *source++; byte_nbr++; } else return -1; } } zstr_free (&self->str_canonical); return 0; } // ----------------------------------------------------------------- // Return UUID binary data const byte * zuuid_data (zuuid_t *self) { assert (self); return self->uuid; } // ----------------------------------------------------------------- // Return UUID binary size size_t zuuid_size (zuuid_t *self) { assert (self); return ZUUID_LEN; } // ----------------------------------------------------------------- // Returns UUID as string const char * zuuid_str (zuuid_t *self) { assert (self); return self->str; } // ----------------------------------------------------------------- // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const char * zuuid_str_canonical (zuuid_t *self) { assert (self); if (!self->str_canonical) self->str_canonical = (char *) zmalloc (8 + 4 + 4 + 4 + 12 + 5); *self->str_canonical = 0; strncat (self->str_canonical, self->str, 8); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 8, 4); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 12, 4); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 16, 4); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 20, 12); int char_nbr; for (char_nbr = 0; char_nbr < 36; char_nbr++) self->str_canonical [char_nbr] = tolower (self->str_canonical [char_nbr]); return self->str_canonical; } // ----------------------------------------------------------------- // Store UUID blob into a target array void zuuid_export (zuuid_t *self, byte *target) { assert (self); memcpy (target, self->uuid, ZUUID_LEN); } // ----------------------------------------------------------------- // Check if UUID is same as supplied value bool zuuid_eq (zuuid_t *self, const byte *compare) { assert (self); return (memcmp (self->uuid, compare, ZUUID_LEN) == 0); } // ----------------------------------------------------------------- // Check if UUID is different from supplied value bool zuuid_neq (zuuid_t *self, const byte *compare) { assert (self); return (memcmp (self->uuid, compare, ZUUID_LEN) != 0); } // -------------------------------------------------------------------------- // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. zuuid_t * zuuid_dup (zuuid_t *self) { if (self) return zuuid_new_from (zuuid_data (self)); else return NULL; } // -------------------------------------------------------------------------- // Selftest void zuuid_test (bool verbose) { printf (" * zuuid: "); // @selftest // Simple create/destroy test assert (ZUUID_LEN == 16); assert (ZUUID_STR_LEN == 32); zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == ZUUID_LEN); assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN); zuuid_t *copy = zuuid_dup (uuid); assert (streq (zuuid_str (uuid), zuuid_str (copy))); // Check set/set_str/export methods const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38"; const char *myuuid2 = "8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38"; const char *myuuid3 = "{8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38}"; const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838"; int rc = zuuid_set_str (uuid, myuuid); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid2); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid3); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid4); assert (rc == -1); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the canonical string format assert (streq (zuuid_str_canonical (uuid), "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38")); zuuid_destroy (&uuid); zuuid_destroy (©); // @end printf ("OK\n"); } czmq-3.0.2/src/zsock_option.c0000664000175000017500000034230512533132116015250 0ustar00phph00000000000000/* ========================================================================= zsock_option - get/set 0MQ socket options **************************************************** * GENERATED SOURCE CODE, DO NOT EDIT!! * * TO CHANGE THIS, EDIT scripts/sockopts.gsl * * AND RUN ./generate in models/. * **************************************************** Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsock_option class provides access to the 0MQ getsockopt/setsockopt API. All methods in this class take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_r reference, or a libzmq void *. @discuss This class is generated, using the GSL code generator. See the sockopts XML file, which provides the metadata, and the sock_option.gsl template, which does the work. @end */ #include "../include/czmq.h" #if (ZMQ_VERSION_MAJOR == 4) // -------------------------------------------------------------------------- // Set socket ZMQ_TOS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tos (void *self, int tos) { assert (self); # if defined (ZMQ_TOS) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TOS, &tos, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TOS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tos (void *self) { assert (self); # if defined (ZMQ_TOS) int tos; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TOS, &tos, &option_len); return tos; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_HANDOVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_handover (void *self, int router_handover) { assert (self); # if defined (ZMQ_ROUTER_HANDOVER) if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_HANDOVER is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_HANDOVER, &router_handover, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_MANDATORY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_mandatory (void *self, int router_mandatory) { assert (self); # if defined (ZMQ_ROUTER_MANDATORY) if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_MANDATORY is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_MANDATORY, &router_mandatory, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PROBE_ROUTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_probe_router (void *self, int probe_router) { assert (self); # if defined (ZMQ_PROBE_ROUTER) if (zsock_type (self) != ZMQ_ROUTER && zsock_type (self) != ZMQ_DEALER && zsock_type (self) != ZMQ_REQ) { printf ("ZMQ_PROBE_ROUTER is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PROBE_ROUTER, &probe_router, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_REQ_RELAXED value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_req_relaxed (void *self, int req_relaxed) { assert (self); # if defined (ZMQ_REQ_RELAXED) if (zsock_type (self) != ZMQ_REQ) { printf ("ZMQ_REQ_RELAXED is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_REQ_RELAXED, &req_relaxed, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_REQ_CORRELATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_req_correlate (void *self, int req_correlate) { assert (self); # if defined (ZMQ_REQ_CORRELATE) if (zsock_type (self) != ZMQ_REQ) { printf ("ZMQ_REQ_CORRELATE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_REQ_CORRELATE, &req_correlate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CONFLATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_conflate (void *self, int conflate) { assert (self); # if defined (ZMQ_CONFLATE) if (zsock_type (self) != ZMQ_PUSH && zsock_type (self) != ZMQ_PULL && zsock_type (self) != ZMQ_PUB && zsock_type (self) != ZMQ_SUB && zsock_type (self) != ZMQ_DEALER) { printf ("ZMQ_CONFLATE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONFLATE, &conflate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_zap_domain (void *self, const char * zap_domain) { assert (self); # if defined (ZMQ_ZAP_DOMAIN) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ZAP_DOMAIN, zap_domain, strlen (zap_domain)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_zap_domain (void *self) { assert (self); # if defined (ZMQ_ZAP_DOMAIN) size_t option_len = 255; char *zap_domain = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_ZAP_DOMAIN, zap_domain, &option_len); return (char *) zap_domain; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MECHANISM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_mechanism (void *self) { assert (self); # if defined (ZMQ_MECHANISM) int mechanism; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_MECHANISM, &mechanism, &option_len); return mechanism; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_plain_server (void *self, int plain_server) { assert (self); # if defined (ZMQ_PLAIN_SERVER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_SERVER, &plain_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_plain_server (void *self) { assert (self); # if defined (ZMQ_PLAIN_SERVER) int plain_server; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_SERVER, &plain_server, &option_len); return plain_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_plain_username (void *self, const char * plain_username) { assert (self); # if defined (ZMQ_PLAIN_USERNAME) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_USERNAME, plain_username, strlen (plain_username)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_plain_username (void *self) { assert (self); # if defined (ZMQ_PLAIN_USERNAME) size_t option_len = 255; char *plain_username = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_USERNAME, plain_username, &option_len); return (char *) plain_username; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_plain_password (void *self, const char * plain_password) { assert (self); # if defined (ZMQ_PLAIN_PASSWORD) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_PASSWORD, plain_password, strlen (plain_password)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_plain_password (void *self) { assert (self); # if defined (ZMQ_PLAIN_PASSWORD) size_t option_len = 255; char *plain_password = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_PASSWORD, plain_password, &option_len); return (char *) plain_password; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_server (void *self, int curve_server) { assert (self); # if defined (ZMQ_CURVE_SERVER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVER, &curve_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_curve_server (void *self) { assert (self); # if defined (ZMQ_CURVE_SERVER) int curve_server; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SERVER, &curve_server, &option_len); return curve_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_publickey (void *self, const char * curve_publickey) { assert (self); # if defined (ZMQ_CURVE_PUBLICKEY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, strlen (curve_publickey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_PUBLICKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey) { # if defined (ZMQ_CURVE_PUBLICKEY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_curve_publickey (void *self) { assert (self); # if defined (ZMQ_CURVE_PUBLICKEY) size_t option_len = 40 + 1; // Z85 key + terminator char *curve_publickey = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, &option_len); return (char *) curve_publickey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_secretkey (void *self, const char * curve_secretkey) { assert (self); # if defined (ZMQ_CURVE_SECRETKEY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, strlen (curve_secretkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SECRETKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey) { # if defined (ZMQ_CURVE_SECRETKEY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_curve_secretkey (void *self) { assert (self); # if defined (ZMQ_CURVE_SECRETKEY) size_t option_len = 40 + 1; // Z85 key + terminator char *curve_secretkey = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, &option_len); return (char *) curve_secretkey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_serverkey (void *self, const char * curve_serverkey) { assert (self); # if defined (ZMQ_CURVE_SERVERKEY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, strlen (curve_serverkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVERKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey) { # if defined (ZMQ_CURVE_SERVERKEY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_curve_serverkey (void *self) { assert (self); # if defined (ZMQ_CURVE_SERVERKEY) size_t option_len = 40 + 1; // Z85 key + terminator char *curve_serverkey = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, &option_len); return (char *) curve_serverkey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_server (void *self, int gssapi_server) { assert (self); # if defined (ZMQ_GSSAPI_SERVER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVER, &gssapi_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_gssapi_server (void *self) { assert (self); # if defined (ZMQ_GSSAPI_SERVER) int gssapi_server; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVER, &gssapi_server, &option_len); return gssapi_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_PLAINTEXT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext) { assert (self); # if defined (ZMQ_GSSAPI_PLAINTEXT) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_PLAINTEXT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_gssapi_plaintext (void *self) { assert (self); # if defined (ZMQ_GSSAPI_PLAINTEXT) int gssapi_plaintext; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, &option_len); return gssapi_plaintext; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_principal (void *self, const char * gssapi_principal) { assert (self); # if defined (ZMQ_GSSAPI_PRINCIPAL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, strlen (gssapi_principal)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_gssapi_principal (void *self) { assert (self); # if defined (ZMQ_GSSAPI_PRINCIPAL) size_t option_len = 255; char *gssapi_principal = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, &option_len); return (char *) gssapi_principal; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_SERVICE_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal) { assert (self); # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, strlen (gssapi_service_principal)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_SERVICE_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_gssapi_service_principal (void *self) { assert (self); # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL) size_t option_len = 255; char *gssapi_service_principal = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, &option_len); return (char *) gssapi_service_principal; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_ipv6 (void *self, int ipv6) { assert (self); # if defined (ZMQ_IPV6) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV6, &ipv6, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_ipv6 (void *self) { assert (self); # if defined (ZMQ_IPV6) int ipv6; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IPV6, &ipv6, &option_len); return ipv6; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_immediate (void *self, int immediate) { assert (self); # if defined (ZMQ_IMMEDIATE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IMMEDIATE, &immediate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_immediate (void *self) { assert (self); # if defined (ZMQ_IMMEDIATE) int immediate; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IMMEDIATE, &immediate, &option_len); return immediate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_raw (void *self, int router_raw) { assert (self); # if defined (ZMQ_ROUTER_RAW) if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_RAW, &router_raw, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_ipv4only (void *self, int ipv4only) { assert (self); # if defined (ZMQ_IPV4ONLY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_ipv4only (void *self) { assert (self); # if defined (ZMQ_IPV4ONLY) int ipv4only; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, &option_len); return ipv4only; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect) { assert (self); # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_type (void *self) { assert (self); # if defined (ZMQ_TYPE) int type; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndhwm (void *self, int sndhwm) { assert (self); # if defined (ZMQ_SNDHWM) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndhwm (void *self) { assert (self); # if defined (ZMQ_SNDHWM) int sndhwm; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, &option_len); return sndhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvhwm (void *self, int rcvhwm) { assert (self); # if defined (ZMQ_RCVHWM) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvhwm (void *self) { assert (self); # if defined (ZMQ_RCVHWM) int rcvhwm; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, &option_len); return rcvhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_affinity (void *self, int affinity) { assert (self); # if defined (ZMQ_AFFINITY) uint64_t value = affinity; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_affinity (void *self) { assert (self); # if defined (ZMQ_AFFINITY) uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_subscribe (void *self, const char * subscribe) { assert (self); # if defined (ZMQ_SUBSCRIBE) if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_unsubscribe (void *self, const char * unsubscribe) { assert (self); # if defined (ZMQ_UNSUBSCRIBE) if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_identity (void *self, const char * identity) { assert (self); # if defined (ZMQ_IDENTITY) if (zsock_type (self) != ZMQ_REQ && zsock_type (self) != ZMQ_REP && zsock_type (self) != ZMQ_DEALER && zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_identity (void *self) { assert (self); # if defined (ZMQ_IDENTITY) size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rate (void *self, int rate) { assert (self); # if defined (ZMQ_RATE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &rate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rate (void *self) { assert (self); # if defined (ZMQ_RATE) int rate; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len); return rate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_recovery_ivl (void *self, int recovery_ivl) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_recovery_ivl (void *self) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int recovery_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return recovery_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndbuf (void *self, int sndbuf) { assert (self); # if defined (ZMQ_SNDBUF) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndbuf (void *self) { assert (self); # if defined (ZMQ_SNDBUF) int sndbuf; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len); return sndbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvbuf (void *self, int rcvbuf) { assert (self); # if defined (ZMQ_RCVBUF) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvbuf (void *self) { assert (self); # if defined (ZMQ_RCVBUF) int rcvbuf; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len); return rcvbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_linger (void *self, int linger) { assert (self); # if defined (ZMQ_LINGER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_linger (void *self) { assert (self); # if defined (ZMQ_LINGER) int linger; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl (void *self, int reconnect_ivl) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl_max (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_backlog (void *self, int backlog) { assert (self); # if defined (ZMQ_BACKLOG) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_backlog (void *self) { assert (self); # if defined (ZMQ_BACKLOG) int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_maxmsgsize (void *self, int maxmsgsize) { assert (self); # if defined (ZMQ_MAXMSGSIZE) int64_t value = maxmsgsize; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_maxmsgsize (void *self) { assert (self); # if defined (ZMQ_MAXMSGSIZE) int64_t maxmsgsize; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); return (int) maxmsgsize; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_multicast_hops (void *self, int multicast_hops) { assert (self); # if defined (ZMQ_MULTICAST_HOPS) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_multicast_hops (void *self) { assert (self); # if defined (ZMQ_MULTICAST_HOPS) int multicast_hops; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); return multicast_hops; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvtimeo (void *self, int rcvtimeo) { assert (self); # if defined (ZMQ_RCVTIMEO) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvtimeo (void *self) { assert (self); # if defined (ZMQ_RCVTIMEO) int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndtimeo (void *self, int sndtimeo) { assert (self); # if defined (ZMQ_SNDTIMEO) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndtimeo (void *self) { assert (self); # if defined (ZMQ_SNDTIMEO) int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_VERBOSE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_verbose (void *self, int xpub_verbose) { assert (self); # if defined (ZMQ_XPUB_VERBOSE) if (zsock_type (self) != ZMQ_XPUB) { printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive (void *self, int tcp_keepalive) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE) int tcp_keepalive; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); return tcp_keepalive; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_idle (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int tcp_keepalive_idle; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); return tcp_keepalive_idle; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_CNT) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_cnt (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_CNT) int tcp_keepalive_cnt; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); return tcp_keepalive_cnt; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_intvl (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int tcp_keepalive_intvl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); return tcp_keepalive_intvl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter) { assert (self); # if defined (ZMQ_TCP_ACCEPT_FILTER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_tcp_accept_filter (void *self) { assert (self); # if defined (ZMQ_TCP_ACCEPT_FILTER) size_t option_len = 255; char *tcp_accept_filter = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); return (char *) tcp_accept_filter; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvmore (void *self) { assert (self); # if defined (ZMQ_RCVMORE) int rcvmore; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len); return rcvmore; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsock_fd (void *self) { assert (self); # if defined (ZMQ_FD) SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len); return fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_events (void *self) { assert (self); # if defined (ZMQ_EVENTS) int events; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len); return events; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LAST_ENDPOINT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_last_endpoint (void *self) { assert (self); # if defined (ZMQ_LAST_ENDPOINT) size_t option_len = 255; char *last_endpoint = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_LAST_ENDPOINT, last_endpoint, &option_len); return (char *) last_endpoint; # else return NULL; # endif } #endif #if (ZMQ_VERSION_MAJOR == 3) // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_raw (void *self, int router_raw) { assert (self); # if defined (ZMQ_ROUTER_RAW) if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_RAW, &router_raw, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_ipv4only (void *self, int ipv4only) { assert (self); # if defined (ZMQ_IPV4ONLY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_ipv4only (void *self) { assert (self); # if defined (ZMQ_IPV4ONLY) int ipv4only; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, &option_len); return ipv4only; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect) { assert (self); # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_type (void *self) { assert (self); # if defined (ZMQ_TYPE) int type; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndhwm (void *self, int sndhwm) { assert (self); # if defined (ZMQ_SNDHWM) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndhwm (void *self) { assert (self); # if defined (ZMQ_SNDHWM) int sndhwm; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, &option_len); return sndhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvhwm (void *self, int rcvhwm) { assert (self); # if defined (ZMQ_RCVHWM) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvhwm (void *self) { assert (self); # if defined (ZMQ_RCVHWM) int rcvhwm; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, &option_len); return rcvhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_affinity (void *self, int affinity) { assert (self); # if defined (ZMQ_AFFINITY) uint64_t value = affinity; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_affinity (void *self) { assert (self); # if defined (ZMQ_AFFINITY) uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_subscribe (void *self, const char * subscribe) { assert (self); # if defined (ZMQ_SUBSCRIBE) if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_unsubscribe (void *self, const char * unsubscribe) { assert (self); # if defined (ZMQ_UNSUBSCRIBE) if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_identity (void *self, const char * identity) { assert (self); # if defined (ZMQ_IDENTITY) if (zsock_type (self) != ZMQ_REQ && zsock_type (self) != ZMQ_REP && zsock_type (self) != ZMQ_DEALER && zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_identity (void *self) { assert (self); # if defined (ZMQ_IDENTITY) size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rate (void *self, int rate) { assert (self); # if defined (ZMQ_RATE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &rate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rate (void *self) { assert (self); # if defined (ZMQ_RATE) int rate; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len); return rate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_recovery_ivl (void *self, int recovery_ivl) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_recovery_ivl (void *self) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int recovery_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return recovery_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndbuf (void *self, int sndbuf) { assert (self); # if defined (ZMQ_SNDBUF) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndbuf (void *self) { assert (self); # if defined (ZMQ_SNDBUF) int sndbuf; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len); return sndbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvbuf (void *self, int rcvbuf) { assert (self); # if defined (ZMQ_RCVBUF) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvbuf (void *self) { assert (self); # if defined (ZMQ_RCVBUF) int rcvbuf; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len); return rcvbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_linger (void *self, int linger) { assert (self); # if defined (ZMQ_LINGER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_linger (void *self) { assert (self); # if defined (ZMQ_LINGER) int linger; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl (void *self, int reconnect_ivl) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl_max (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_backlog (void *self, int backlog) { assert (self); # if defined (ZMQ_BACKLOG) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_backlog (void *self) { assert (self); # if defined (ZMQ_BACKLOG) int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_maxmsgsize (void *self, int maxmsgsize) { assert (self); # if defined (ZMQ_MAXMSGSIZE) int64_t value = maxmsgsize; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_maxmsgsize (void *self) { assert (self); # if defined (ZMQ_MAXMSGSIZE) int64_t maxmsgsize; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); return (int) maxmsgsize; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_multicast_hops (void *self, int multicast_hops) { assert (self); # if defined (ZMQ_MULTICAST_HOPS) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_multicast_hops (void *self) { assert (self); # if defined (ZMQ_MULTICAST_HOPS) int multicast_hops; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); return multicast_hops; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvtimeo (void *self, int rcvtimeo) { assert (self); # if defined (ZMQ_RCVTIMEO) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvtimeo (void *self) { assert (self); # if defined (ZMQ_RCVTIMEO) int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndtimeo (void *self, int sndtimeo) { assert (self); # if defined (ZMQ_SNDTIMEO) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndtimeo (void *self) { assert (self); # if defined (ZMQ_SNDTIMEO) int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_VERBOSE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_verbose (void *self, int xpub_verbose) { assert (self); # if defined (ZMQ_XPUB_VERBOSE) if (zsock_type (self) != ZMQ_XPUB) { printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive (void *self, int tcp_keepalive) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE) int tcp_keepalive; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); return tcp_keepalive; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_idle (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int tcp_keepalive_idle; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); return tcp_keepalive_idle; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_CNT) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_cnt (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_CNT) int tcp_keepalive_cnt; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); return tcp_keepalive_cnt; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_intvl (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int tcp_keepalive_intvl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); return tcp_keepalive_intvl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter) { assert (self); # if defined (ZMQ_TCP_ACCEPT_FILTER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_tcp_accept_filter (void *self) { assert (self); # if defined (ZMQ_TCP_ACCEPT_FILTER) size_t option_len = 255; char *tcp_accept_filter = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); return (char *) tcp_accept_filter; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvmore (void *self) { assert (self); # if defined (ZMQ_RCVMORE) int rcvmore; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len); return rcvmore; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsock_fd (void *self) { assert (self); # if defined (ZMQ_FD) SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len); return fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_events (void *self) { assert (self); # if defined (ZMQ_EVENTS) int events; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len); return events; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LAST_ENDPOINT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_last_endpoint (void *self) { assert (self); # if defined (ZMQ_LAST_ENDPOINT) size_t option_len = 255; char *last_endpoint = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_LAST_ENDPOINT, last_endpoint, &option_len); return (char *) last_endpoint; # else return NULL; # endif } #endif #if (ZMQ_VERSION_MAJOR == 2) // -------------------------------------------------------------------------- // Set socket ZMQ_HWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_hwm (void *self, int hwm) { assert (self); # if defined (ZMQ_HWM) uint64_t value = hwm; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HWM, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_hwm (void *self) { assert (self); # if defined (ZMQ_HWM) uint64_t hwm; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_HWM, &hwm, &option_len); return (int) hwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SWAP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_swap (void *self, int swap) { assert (self); # if defined (ZMQ_SWAP) int64_t value = swap; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SWAP, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SWAP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_swap (void *self) { assert (self); # if defined (ZMQ_SWAP) int64_t swap; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_SWAP, &swap, &option_len); return (int) swap; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_affinity (void *self, int affinity) { assert (self); # if defined (ZMQ_AFFINITY) uint64_t value = affinity; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_affinity (void *self) { assert (self); # if defined (ZMQ_AFFINITY) uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_identity (void *self, const char * identity) { assert (self); # if defined (ZMQ_IDENTITY) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_identity (void *self) { assert (self); # if defined (ZMQ_IDENTITY) size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rate (void *self, int rate) { assert (self); # if defined (ZMQ_RATE) int64_t value = rate; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rate (void *self) { assert (self); # if defined (ZMQ_RATE) int64_t rate; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len); return (int) rate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_recovery_ivl (void *self, int recovery_ivl) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int64_t value = recovery_ivl; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_recovery_ivl (void *self) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int64_t recovery_ivl; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return (int) recovery_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL_MSEC value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec) { assert (self); # if defined (ZMQ_RECOVERY_IVL_MSEC) int64_t value = recovery_ivl_msec; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL_MSEC value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_recovery_ivl_msec (void *self) { assert (self); # if defined (ZMQ_RECOVERY_IVL_MSEC) int64_t recovery_ivl_msec; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len); return (int) recovery_ivl_msec; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MCAST_LOOP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_mcast_loop (void *self, int mcast_loop) { assert (self); # if defined (ZMQ_MCAST_LOOP) int64_t value = mcast_loop; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MCAST_LOOP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_mcast_loop (void *self) { assert (self); # if defined (ZMQ_MCAST_LOOP) int64_t mcast_loop; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &mcast_loop, &option_len); return (int) mcast_loop; # else return 0; # endif } # if (ZMQ_VERSION_MINOR == 2) // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvtimeo (void *self, int rcvtimeo) { assert (self); # if defined (ZMQ_RCVTIMEO) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvtimeo (void *self) { assert (self); # if defined (ZMQ_RCVTIMEO) int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } # endif # if (ZMQ_VERSION_MINOR == 2) // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndtimeo (void *self, int sndtimeo) { assert (self); # if defined (ZMQ_SNDTIMEO) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndtimeo (void *self) { assert (self); # if defined (ZMQ_SNDTIMEO) int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } # endif // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndbuf (void *self, int sndbuf) { assert (self); # if defined (ZMQ_SNDBUF) uint64_t value = sndbuf; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndbuf (void *self) { assert (self); # if defined (ZMQ_SNDBUF) uint64_t sndbuf; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len); return (int) sndbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvbuf (void *self, int rcvbuf) { assert (self); # if defined (ZMQ_RCVBUF) uint64_t value = rcvbuf; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvbuf (void *self) { assert (self); # if defined (ZMQ_RCVBUF) uint64_t rcvbuf; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len); return (int) rcvbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_linger (void *self, int linger) { assert (self); # if defined (ZMQ_LINGER) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_linger (void *self) { assert (self); # if defined (ZMQ_LINGER) int linger; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl (void *self, int reconnect_ivl) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl_max (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_backlog (void *self, int backlog) { assert (self); # if defined (ZMQ_BACKLOG) int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_backlog (void *self) { assert (self); # if defined (ZMQ_BACKLOG) int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_subscribe (void *self, const char * subscribe) { assert (self); # if defined (ZMQ_SUBSCRIBE) if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_unsubscribe (void *self, const char * unsubscribe) { assert (self); # if defined (ZMQ_UNSUBSCRIBE) if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_type (void *self) { assert (self); # if defined (ZMQ_TYPE) int type; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvmore (void *self) { assert (self); # if defined (ZMQ_RCVMORE) int64_t rcvmore; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len); return (int) rcvmore; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsock_fd (void *self) { assert (self); # if defined (ZMQ_FD) SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len); return fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_events (void *self) { assert (self); # if defined (ZMQ_EVENTS) uint32_t events; size_t option_len = sizeof (uint32_t); zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len); return (int) events; # else return 0; # endif } #endif // -------------------------------------------------------------------------- // Selftest // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_option_test (bool verbose) { printf (" * zsock_option: "); // @selftest zsock_t *self; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_tos (self, 1); assert (zsock_tos (self) == 1); zsock_tos (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_HANDOVER) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_handover (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_MANDATORY) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_mandatory (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_PROBE_ROUTER) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_probe_router (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_RELAXED) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_relaxed (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_CORRELATE) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_correlate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONFLATE) self = zsock_new (ZMQ_PUSH); assert (self); zsock_set_conflate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ZAP_DOMAIN) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_zap_domain (self, "test"); char *zap_domain = zsock_zap_domain (self); assert (zap_domain); free (zap_domain); zsock_destroy (&self); # endif # if defined (ZMQ_MECHANISM) self = zsock_new (ZMQ_SUB); assert (self); zsock_mechanism (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_SERVER) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_plain_server (self, 1); assert (zsock_plain_server (self) == 1); zsock_plain_server (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_USERNAME) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_username (self, "test"); char *plain_username = zsock_plain_username (self); assert (plain_username); free (plain_username); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_PASSWORD) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_password (self, "test"); char *plain_password = zsock_plain_password (self); assert (plain_password); free (plain_password); zsock_destroy (&self); # endif # if defined (ZMQ_IPV6) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv6 (self, 1); assert (zsock_ipv6 (self) == 1); zsock_ipv6 (self); zsock_destroy (&self); # endif # if defined (ZMQ_IMMEDIATE) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_immediate (self, 1); assert (zsock_immediate (self) == 1); zsock_immediate (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_hwm (self, 1); assert (zsock_hwm (self) == 1); zsock_hwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_SWAP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_swap (self, 1); assert (zsock_swap (self) == 1); zsock_swap (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl_msec (self, 1); assert (zsock_recovery_ivl_msec (self) == 1); zsock_recovery_ivl_msec (self); zsock_destroy (&self); # endif # if defined (ZMQ_MCAST_LOOP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_mcast_loop (self, 1); assert (zsock_mcast_loop (self) == 1); zsock_mcast_loop (self); zsock_destroy (&self); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif #endif // @end printf ("OK\n"); } czmq-3.0.2/src/zauth.c0000664000175000017500000004774012505070716013675 0ustar00phph00000000000000/* ========================================================================= zauth - authentication for ZeroMQ security mechanisms Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header A zauth actor takes over authentication for all incoming connections in its context. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections. @discuss This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "../include/czmq.h" #define ZAP_ENDPOINT "inproc://zeromq.zap.01" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zsock_t *handler; // ZAP handler socket zhashx_t *whitelist; // Whitelisted addresses zhashx_t *blacklist; // Blacklisted addresses zhashx_t *passwords; // PLAIN passwords, if loaded zpoller_t *poller; // Socket poller zcertstore_t *certstore; // CURVE certificate store, if loaded bool allow_any; // CURVE allows arbitrary clients bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zhashx_destroy (&self->passwords); zhashx_destroy (&self->whitelist); zhashx_destroy (&self->blacklist); zcertstore_destroy (&self->certstore); zpoller_destroy (&self->poller); if (self->handler) { zsock_unbind (self->handler, ZAP_ENDPOINT); zsock_destroy (&self->handler); } free (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); int rc = -1; if (self) { self->pipe = pipe; self->whitelist = zhashx_new (); if (self->whitelist) self->blacklist = zhashx_new (); // Create ZAP handler and get ready for requests if (self->blacklist) self->handler = zsock_new (ZMQ_REP); if (self->handler) rc = zsock_bind (self->handler, ZAP_ENDPOINT); if (rc == 0) self->poller = zpoller_new (self->pipe, self->handler, NULL); if (!self->poller) s_self_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (self->verbose) zsys_info ("zauth: API command=%s", command); if (streq (command, "ALLOW")) { char *address = zmsg_popstr (request); while (address) { if (self->verbose) zsys_info ("zauth: - whitelisting ipaddress=%s", address); zhashx_insert (self->whitelist, address, "OK"); zstr_free (&address); address = zmsg_popstr (request); } zsock_signal (self->pipe, 0); } else if (streq (command, "DENY")) { char *address = zmsg_popstr (request); while (address) { if (self->verbose) zsys_info ("zauth: - blacklisting ipaddress=%s", address); zhashx_insert (self->blacklist, address, "OK"); zstr_free (&address); address = zmsg_popstr (request); } zsock_signal (self->pipe, 0); } else if (streq (command, "PLAIN")) { // Get password file and load into zhash table // If the file doesn't exist we'll get an empty table char *filename = zmsg_popstr (request); zhashx_destroy (&self->passwords); self->passwords = zhashx_new (); if (zhashx_load (self->passwords, filename) && self->verbose) zsys_info ("zauth: could not load file=%s", filename); zstr_free (&filename); zsock_signal (self->pipe, 0); } else if (streq (command, "CURVE")) { // If location is CURVE_ALLOW_ANY, allow all clients. Otherwise // treat location as a directory that holds the certificates. char *location = zmsg_popstr (request); if (streq (location, CURVE_ALLOW_ANY)) self->allow_any = true; else { zcertstore_destroy (&self->certstore); // FIXME: what if this fails? self->certstore = zcertstore_new (location); self->allow_any = false; } zstr_free (&location); zsock_signal (self->pipe, 0); } else if (streq (command, "GSSAPI")) // GSSAPI authentication is not yet implemented here zsock_signal (self->pipe, 0); else if (streq (command, "VERBOSE")) { self->verbose = true; zsock_signal (self->pipe, 0); } else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zauth: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // A small class for working with ZAP requests and replies. // Used internally in zauth to simplify working with RFC 27 messages. // Structure of a ZAP request typedef struct { zsock_t *handler; // Socket we're talking to bool verbose; // Log ZAP requests and replies? char *version; // Version number, must be "1.0" char *sequence; // Sequence number of request char *domain; // Server socket domain char *address; // Client IP address char *identity; // Server socket idenntity char *mechanism; // Security mechansim char *username; // PLAIN user name char *password; // PLAIN password, in clear text char *client_key; // CURVE client public key in ASCII char *principal; // GSSAPI client principal } zap_request_t; static void s_zap_request_destroy (zap_request_t **self_p) { assert (self_p); if (*self_p) { zap_request_t *self = *self_p; free (self->version); free (self->sequence); free (self->domain); free (self->address); free (self->identity); free (self->mechanism); free (self->username); free (self->password); free (self->client_key); free (self->principal); free (self); *self_p = NULL; } } // Receive a valid ZAP request from the handler socket // If the request was not valid, returns NULL. static zap_request_t * s_zap_request_new (zsock_t *handler, bool verbose) { zap_request_t *self = (zap_request_t *) zmalloc (sizeof (zap_request_t)); if (!self) return NULL; // Store handler socket so we can send a reply easily self->handler = handler; self->verbose = verbose; zmsg_t *request = zmsg_recv (handler); if (!request) { // interrupted s_zap_request_destroy (&self); return NULL; } // Get all standard frames off the handler socket self->version = zmsg_popstr (request); self->sequence = zmsg_popstr (request); self->domain = zmsg_popstr (request); self->address = zmsg_popstr (request); self->identity = zmsg_popstr (request); self->mechanism = zmsg_popstr (request); // If the version is wrong, we're linked with a bogus libzmq, so die assert (streq (self->version, "1.0")); // Get mechanism-specific frames if (streq (self->mechanism, "PLAIN")) { self->username = zmsg_popstr (request); self->password = zmsg_popstr (request); } else if (streq (self->mechanism, "CURVE")) { zframe_t *frame = zmsg_pop (request); assert (zframe_size (frame) == 32); self->client_key = (char *) zmalloc (41); #if (ZMQ_VERSION_MAJOR == 4) zmq_z85_encode (self->client_key, zframe_data (frame), 32); #endif zframe_destroy (&frame); } else if (streq (self->mechanism, "GSSAPI")) self->principal = zmsg_popstr (request); if (self->verbose) zsys_info ("zauth: ZAP request mechanism=%s ipaddress=%s", self->mechanism, self->address); zmsg_destroy (&request); return self; } // Send a ZAP reply to the handler socket static int s_zap_request_reply (zap_request_t *self, char *status_code, char *status_text) { if (self->verbose) zsys_info ("zauth: - ZAP reply status_code=%s status_text=%s", status_code, status_text); zstr_sendx (self->handler, "1.0", self->sequence, status_code, status_text, "", "", NULL); return 0; } // -------------------------------------------------------------------------- // Handle an authentication request from libzmq core static bool s_authenticate_plain (self_t *self, zap_request_t *request) { if (self->passwords) { zhashx_refresh (self->passwords); char *password = (char *) zhashx_lookup (self->passwords, request->username); if (password && streq (password, request->password)) { if (self->verbose) zsys_info ("zauth: - allowed (PLAIN) username=%s password=%s", request->username, request->password); return true; } else { if (self->verbose) zsys_info ("zauth: - denied (PLAIN) username=%s password=%s", request->username, request->password); return false; } } else { if (self->verbose) zsys_info ("zauth: - denied (PLAIN) no password file defined"); return false; } } static bool s_authenticate_curve (self_t *self, zap_request_t *request) { // TODO: load metadata from certificate and return via ZAP response if (self->allow_any) { if (self->verbose) zsys_info ("zauth: - allowed (CURVE allow any client)"); return true; } else if (self->certstore && zcertstore_lookup (self->certstore, request->client_key)) { if (self->verbose) zsys_info ("zauth: - allowed (CURVE) client_key=%s", request->client_key); return true; } else { if (self->verbose) zsys_info ("zauth: - denied (CURVE) client_key=%s", request->client_key); return false; } } static bool s_authenticate_gssapi (self_t *self, zap_request_t *request) { if (self->verbose) zsys_info ("zauth: - allowed (GSSAPI) principal=%s identity=%s", request->principal, request->identity); return true; } // TODO: allow regular expressions in addresses static int s_self_authenticate (self_t *self) { zap_request_t *request = s_zap_request_new (self->handler, self->verbose); if (request) { // Is address explicitly whitelisted or blacklisted? bool allowed = false; bool denied = false; if (zhashx_size (self->whitelist)) { if (zhashx_lookup (self->whitelist, request->address)) { allowed = true; if (self->verbose) zsys_info ("zauth: - passed (whitelist) address=%s", request->address); } else { denied = true; if (self->verbose) zsys_info ("zauth: - denied (not in whitelist) address=%s", request->address); } } else if (zhashx_size (self->blacklist)) { if (zhashx_lookup (self->blacklist, request->address)) { denied = true; if (self->verbose) zsys_info ("zauth: - denied (blacklist) address=%s", request->address); } else { allowed = true; if (self->verbose) zsys_info ("zauth: - passed (not in blacklist) address=%s", request->address); } } // Mechanism-specific checks if (!denied) { if (streq (request->mechanism, "NULL") && !allowed) { // For NULL, we allow if the address wasn't blacklisted if (self->verbose) zsys_info ("zauth: - allowed (NULL)"); allowed = true; } else if (streq (request->mechanism, "PLAIN")) // For PLAIN, even a whitelisted address must authenticate allowed = s_authenticate_plain (self, request); else if (streq (request->mechanism, "CURVE")) // For CURVE, even a whitelisted address must authenticate allowed = s_authenticate_curve (self, request); else if (streq (request->mechanism, "GSSAPI")) // For GSSAPI, even a whitelisted address must authenticate allowed = s_authenticate_gssapi (self, request); } if (allowed) s_zap_request_reply (request, "200", "OK"); else s_zap_request_reply (request, "400", "No access"); s_zap_request_destroy (&request); } else s_zap_request_reply (request, "500", "Internal error"); return 0; } // -------------------------------------------------------------------------- // zauth() implements the zauth actor interface void zauth (zsock_t *pipe, void *unused) { self_t *self = s_self_new (pipe); if (!self) return; // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (which == self->handler) s_self_authenticate (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest #if (ZMQ_VERSION_MAJOR == 4) // Checks whether client can connect to server static bool s_can_connect (zsock_t **server, zsock_t **client) { int port_nbr = zsock_bind (*server, "tcp://127.0.0.1:*"); assert (port_nbr > 0); int rc = zsock_connect (*client, "tcp://127.0.0.1:%d", port_nbr); assert (rc == 0); zstr_send (*server, "Hello, World"); zpoller_t *poller = zpoller_new (*client, NULL); assert (poller); bool success = (zpoller_wait (poller, 200) == *client); zpoller_destroy (&poller); zsock_destroy (client); zsock_destroy (server); *server = zsock_new (ZMQ_PUSH); assert (*server); *client = zsock_new (ZMQ_PULL); assert (*client); return success; } #endif void zauth_test (bool verbose) { printf (" * zauth: "); #if (ZMQ_VERSION_MAJOR == 4) if (verbose) printf ("\n"); // @selftest // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Check there's no authentication zsock_t *server = zsock_new (ZMQ_PUSH); assert (server); zsock_t *client = zsock_new (ZMQ_PULL); assert (client); bool success = s_can_connect (&server, &client); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server success = s_can_connect (&server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client); assert (success); // Blacklist 127.0.0.1, connection should fail zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Try PLAIN authentication zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); success = s_can_connect (&server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); zstr_sendx (auth, "PLAIN", TESTDIR "/password-file", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Bogus"); success = s_can_connect (&server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); success = s_can_connect (&server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zstr_sendx (auth, "CURVE", TESTDIR, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); success = s_can_connect (&server, &client); assert (success); zsock_destroy (&client); zsock_destroy (&server); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); // @end #endif printf ("OK\n"); } czmq-3.0.2/src/zchunk.c0000664000175000017500000004150312532610055014027 0ustar00phph00000000000000/* ========================================================================= zchunk - work with memory chunks Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. =========================================================================*/ /* @header The zchunk class works with variable sized blobs. Not as efficient as MQ's messages but they do less weirdness and so are easier to understand. The chunk class has methods to read and write chunks from disk. @discuss @end */ #include "../include/czmq.h" // zchunk_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZCHUNK_TAG 0x0001cafe // Structure of our class struct _zchunk_t { uint32_t tag; // Object tag for runtime detection size_t size; // Current size of data part size_t max_size; // Maximum allocated size size_t consumed; // Amount already consumed zdigest_t *digest; // Chunk digest, if known byte *data; // Data part follows here }; // -------------------------------------------------------------------------- // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. zchunk_t * zchunk_new (const void *data, size_t size) { // Use malloc, not zmalloc, to avoid nullification costs zchunk_t *self = (zchunk_t *) malloc (sizeof (zchunk_t) + size); if (self) { self->tag = ZCHUNK_TAG; self->size = 0; self->max_size = size; self->consumed = 0; self->data = (byte *) self + sizeof (zchunk_t); self->digest = NULL; if (data) { self->size = size; memcpy (self->data, data, self->size); } } return self; } // -------------------------------------------------------------------------- // Destroy a chunk void zchunk_destroy (zchunk_t **self_p) { assert (self_p); if (*self_p) { zchunk_t *self = *self_p; assert (zchunk_is (self)); // If data was reallocated independently, free it independently if (self->data != (byte *) self + sizeof (zchunk_t)) free (self->data); self->tag = 0xDeadBeef; zdigest_destroy (&self->digest); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Resizes chunk max_size as requested; chunk size is set to zero void zchunk_resize (zchunk_t *self, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); // Set new sizes self->max_size = size; self->size = 0; // TODO: this is a bit annoying, is it needed? // We can't realloc the chunk itself, as the caller's reference // won't change. So we modify self->data only, depending on whether // it was already reallocated, or not. if (self->data == (byte *) self + sizeof (zchunk_t)) self->data = (byte *) malloc (self->max_size); else self->data = (byte *) realloc (self->data, self->max_size); } // -------------------------------------------------------------------------- // Return chunk current size size_t zchunk_size (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return self->size; } // -------------------------------------------------------------------------- // Return chunk max size size_t zchunk_max_size (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return self->max_size; } // -------------------------------------------------------------------------- // Return chunk data byte * zchunk_data (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return self->data; } // -------------------------------------------------------------------------- // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t zchunk_set (zchunk_t *self, const void *data, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); if (size > self->max_size) size = self->max_size; if (data) memcpy (self->data, data, size); self->size = size; return size; } // -------------------------------------------------------------------------- // Fill chunk data from user-supplied octet // Returns actual size of chunk size_t zchunk_fill (zchunk_t *self, byte filler, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); if (size > self->max_size) size = self->max_size; memset (self->data, filler, size); self->size = size; return size; } // -------------------------------------------------------------------------- // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeed the available space, it is truncated. If you want to // grow the chunk to accomodate new data, use the zchunk_extend method. size_t zchunk_append (zchunk_t *self, const void *data, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); if (self->size + size > self->max_size) size = self->max_size - self->size; memcpy (self->data + self->size, data, size); self->size += size; return self->size; } // -------------------------------------------------------------------------- // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeed the available space, the chunk grows in size. size_t zchunk_extend (zchunk_t *self, const void *data, size_t size) { assert (self); if (self->size + size > self->max_size) { self->max_size = (self->size + size) * 2; // We can't realloc the chunk itself, as the caller's reference // won't change. So we modify self->data only, depending on whether // it was already reallocated, or not. if (self->data == (byte *) self + sizeof (zchunk_t)) { byte *old_data = self->data; self->data = (byte *) malloc (self->max_size); memcpy (self->data, old_data, self->size); } else self->data = (byte *) realloc (self->data, self->max_size); } assert (self->size + size <= self->max_size); memcpy (self->data + self->size, data, size); self->size += size; return self->size; } // -------------------------------------------------------------------------- // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t zchunk_consume (zchunk_t *self, zchunk_t *source) { assert (self); assert (zchunk_is (self)); assert (source); assert (zchunk_is (source)); // We can take at most this many bytes from source size_t size = source->size - source->consumed; // And we can store at most this many bytes in chunk if (self->size + size > self->max_size) size = self->max_size - self->size; memcpy (self->data + self->size, source->data + source->consumed, size); source->consumed += size; self->size += size; return self->size; } // -------------------------------------------------------------------------- // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool zchunk_exhausted (zchunk_t *self) { assert (self); assert (zchunk_is (self)); assert (self->consumed <= self->size); return self->consumed == self->size; } // -------------------------------------------------------------------------- // Read chunk from an open file descriptor zchunk_t * zchunk_read (FILE *handle, size_t bytes) { assert (handle); zchunk_t *self = zchunk_new (NULL, bytes); if (self) self->size = fread (self->data, 1, bytes, handle); return self; } // -------------------------------------------------------------------------- // Write chunk to an open file descriptor int zchunk_write (zchunk_t *self, FILE *handle) { assert (self); assert (zchunk_is (self)); size_t items = fwrite (self->data, 1, self->size, handle); int rc = (items < self->size)? -1: 0; return rc; } // -------------------------------------------------------------------------- // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. zchunk_t * zchunk_slurp (const char *filename, size_t maxsize) { size_t size = zsys_file_size (filename); if ((ssize_t) size == -1) return NULL; if (size > maxsize && maxsize != 0) size = maxsize; FILE *handle = fopen (filename, "r"); zchunk_t *chunk = zchunk_read (handle, size); assert (chunk); fclose (handle); return chunk; } // -------------------------------------------------------------------------- // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // or memory was exhausted, returns null. zchunk_t * zchunk_dup (zchunk_t *self) { if (self) { assert (zchunk_is (self)); return zchunk_new (self->data, self->max_size); } else return NULL; } // -------------------------------------------------------------------------- // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. char * zchunk_strhex (zchunk_t *self) { assert (self); assert (zchunk_is (self)); static const char hex_char [] = "0123456789ABCDEF"; size_t size = zchunk_size (self); byte *data = zchunk_data (self); char *hex_str = (char *) zmalloc (size * 2 + 1); if (!hex_str) return NULL; uint byte_nbr; for (byte_nbr = 0; byte_nbr < size; byte_nbr++) { hex_str [byte_nbr * 2 + 0] = hex_char [data [byte_nbr] >> 4]; hex_str [byte_nbr * 2 + 1] = hex_char [data [byte_nbr] & 15]; } hex_str [size * 2] = 0; return hex_str; } // -------------------------------------------------------------------------- // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. char * zchunk_strdup (zchunk_t *self) { assert (self); assert (zchunk_is (self)); size_t size = zchunk_size (self); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zchunk_data (self), size); string [size] = 0; } return string; } // -------------------------------------------------------------------------- // Return true if chunk body is equal to string, excluding terminator bool zchunk_streq (zchunk_t *self, const char *string) { assert (self); assert (zchunk_is (self)); if (zchunk_size (self) == strlen (string) && memcmp (zchunk_data (self), string, strlen (string)) == 0) return true; else return false; } // -------------------------------------------------------------------------- // Create a zframe from a zchunk. The zframe can be sent in a message. zframe_t * zchunk_pack (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return zframe_new (self->data, self->max_size); } // -------------------------------------------------------------------------- // Create a zchunk from a zframe. zchunk_t * zchunk_unpack (zframe_t *frame) { assert (frame); assert (zframe_is (frame)); return zchunk_new (zframe_data (frame), zframe_size (frame)); } // -------------------------------------------------------------------------- // Calculate SHA1 digest for chunk, using zdigest class. Caller should not // modify digest. const char * zchunk_digest (zchunk_t *self) { assert (self); if (!self->digest) self->digest = zdigest_new (); if (self->digest) { zdigest_update (self->digest, self->data, self->size); return zdigest_string (self->digest); } else return NULL; } // -------------------------------------------------------------------------- // Dump chunk to FILE stream, for debugging and tracing. void zchunk_fprint (zchunk_t *self, FILE *file) { assert (self); assert (zchunk_is (self)); fprintf (file, "--------------------------------------\n"); if (!self) { fprintf (file, "NULL"); return; } assert (self); int is_bin = 0; uint char_nbr; for (char_nbr = 0; char_nbr < self->size; char_nbr++) if (self->data [char_nbr] < 9 || self->data [char_nbr] > 127) is_bin = 1; fprintf (file, "[%03d] ", (int) self->size); for (char_nbr = 0; char_nbr < self->size; char_nbr++) { if (is_bin) { fprintf (file, "%02X", (unsigned char) self->data [char_nbr]); if (char_nbr > 35) { fprintf (file, "..."); break; } } else { fprintf (file, "%c", self->data [char_nbr]); if (char_nbr > 70) { fprintf (file, "..."); break; } } } fprintf (file, "\n"); } // -------------------------------------------------------------------------- // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void zchunk_print (zchunk_t *self) { assert (self); assert (zchunk_is (self)); zchunk_fprint (self, stderr); } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zchunk_t. bool zchunk_is (void *self) { assert (self); return ((zchunk_t *) self)->tag == ZCHUNK_TAG; } // -------------------------------------------------------------------------- // Self test of this class void zchunk_test (bool verbose) { printf (" * zchunk: "); // @selftest zchunk_t *chunk = zchunk_new ("1234567890", 10); assert (chunk); assert (zchunk_size (chunk) == 10); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 10); assert (chunk); zchunk_append (chunk, "12345678", 8); zchunk_append (chunk, "90ABCDEF", 8); zchunk_append (chunk, "GHIJKLMN", 8); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); assert (zchunk_size (chunk) == 10); assert (zchunk_streq (chunk, "1234567890")); assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A")); char *string = zchunk_strdup (chunk); assert (streq (string, "1234567890")); free (string); string = zchunk_strhex (chunk); assert (streq (string, "31323334353637383930")); free (string); zframe_t *frame = zchunk_pack (chunk); assert (frame); zchunk_t *chunk2 = zchunk_unpack (frame); assert (chunk2); assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0); zframe_destroy (&frame); zchunk_destroy (&chunk2); zchunk_t *copy = zchunk_dup (chunk); assert (copy); assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0); assert (zchunk_size (copy) == 10); zchunk_destroy (©); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 0); zchunk_extend (chunk, "12345678", 8); zchunk_extend (chunk, "90ABCDEF", 8); zchunk_extend (chunk, "GHIJKLMN", 8); assert (zchunk_size (chunk) == 24); assert (zchunk_streq (chunk, "1234567890ABCDEFGHIJKLMN")); zchunk_destroy (&chunk); copy = zchunk_new ("1234567890abcdefghij", 20); assert (copy); chunk = zchunk_new (NULL, 8); assert (chunk); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (zchunk_exhausted (copy)); assert (zchunk_size (chunk) == 4); assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0); zchunk_destroy (©); zchunk_destroy (&chunk); // @end printf ("OK\n"); } czmq-3.0.2/src/zhashx.c0000664000175000017500000011660112522736135014043 0ustar00phph00000000000000/* ========================================================================= zhashx - extended generic hash container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zhashx is an extended hash table container with more functionality than zhash, its simpler cousin. @discuss The hash table always has a size that is prime and roughly doubles its size when 75% full. In case of hash collisions items are chained in a linked list. The hash table size is increased slightly (up to 5 times before roughly doubling the size) when an overly long chain (between 1 and 63 items depending on table size) is detected. @end */ #include "../include/czmq.h" // Hash table performance parameters #define INITIAL_PRIME 0 // Initial size in items (index into primes) #define GROWTH_FACTOR 5 // Increase after splitting (index into primes) #define LOAD_FACTOR 75 // Percent loading before splitting #define INITIAL_CHAIN 1 // Initial chaining limit #define CHAIN_GROWS 1 // Increase after splitting (chaining limit) #include "zhash_primes.inc" // Hash item, used internally only typedef struct _item_t { void *value; // Opaque item value struct _item_t *next; // Next item in the hash slot size_t index; // Index of item in table const void *key; // Item's original key // Supporting deprecated v2 functionality; we can't quite replace // this with strdup/zstr_free as zhashx_insert also uses autofree. zhashx_free_fn *free_fn; // Value free function if any } item_t; // --------------------------------------------------------------------- // Structure of our class struct _zhashx_t { size_t size; // Current size of hash table uint prime_index; // Current prime number used as limit uint chain_limit; // Current limit on chain length item_t **items; // Array of items size_t cached_index; // Avoids duplicate hash calculations size_t cursor_index; // For first/next iteration item_t *cursor_item; // For first/next iteration const void *cursor_key; // After first/next call, points to key zlistx_t *comments; // File comments, if any time_t modified; // Set during zhashx_load char *filename; // Set during zhashx_load // Function callbacks for duplicating and destroying items, if any zhashx_duplicator_fn *duplicator; zhashx_destructor_fn *destructor; // Function callbacks for duplicating and destroying keys, if any zhashx_duplicator_fn *key_duplicator; zhashx_destructor_fn *key_destructor; zhashx_comparator_fn *key_comparator; // Custom hash function zhashx_hash_fn *hasher; }; // Local helper functions static item_t *s_item_lookup (zhashx_t *self, const void *key); static item_t *s_item_insert (zhashx_t *self, const void *key, void *value); static void s_item_destroy (zhashx_t *self, item_t *item, bool hard); // -------------------------------------------------------------------------- // Modified Bernstein hashing function static size_t s_bernstein_hash (const void *key) { const char *pointer = (const char *) key; size_t key_hash = 0; while (*pointer) key_hash = 33 * key_hash ^ *pointer++; return key_hash; } // -------------------------------------------------------------------------- // Hash table constructor zhashx_t * zhashx_new (void) { zhashx_t *self = (zhashx_t *) zmalloc (sizeof (zhashx_t)); if (self) { self->prime_index = INITIAL_PRIME; self->chain_limit = INITIAL_CHAIN; size_t limit = primes [self->prime_index]; self->items = (item_t **) zmalloc (sizeof (item_t *) * limit); if (self->items) { self->hasher = s_bernstein_hash; self->key_destructor = (zhashx_destructor_fn *) zstr_free; self->key_duplicator = (zhashx_duplicator_fn *) strdup; self->key_comparator = (zhashx_comparator_fn *) strcmp; } else zhashx_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Purge all items from a hash table static void s_purge (zhashx_t *self) { uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } self->items [index] = NULL; } } // -------------------------------------------------------------------------- // Hash table destructor void zhashx_destroy (zhashx_t **self_p) { assert (self_p); if (*self_p) { zhashx_t *self = *self_p; if (self->items) { s_purge (self); free (self->items); } zlistx_destroy (&self->comments); free (self->filename); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Local helper function // Destroy item in hash table, item must exist in table static void s_item_destroy (zhashx_t *self, item_t *item, bool hard) { // Find previous item since it's a singly-linked list item_t *cur_item = self->items [item->index]; item_t **prev_item = &(self->items [item->index]); while (cur_item) { if (cur_item == item) break; prev_item = &(cur_item->next); cur_item = cur_item->next; } assert (cur_item); *prev_item = item->next; self->size--; if (hard) { if (self->destructor) (self->destructor)(&item->value); else if (item->free_fn) (item->free_fn)(item->value); self->cursor_item = NULL; self->cursor_key = NULL; if (self->key_destructor) (self->key_destructor)((void **) &item->key); free (item); } } // -------------------------------------------------------------------------- // Rehash hash table with specified new prime index // Returns 0 on success, or -1 on failure (insufficient memory) static int s_zhashx_rehash (zhashx_t *self, uint new_prime_index) { assert (self); assert (new_prime_index < sizeof (primes)); size_t limit = primes [self->prime_index]; size_t new_limit = primes [new_prime_index]; item_t **new_items = (item_t **) zmalloc (sizeof (item_t *) * new_limit); if (!new_items) return -1; // Move all items to the new hash table, rehashing to // take into account new hash table limit size_t index; for (index = 0; index < limit; index++) { item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; size_t new_index = self->hasher (cur_item->key); new_index %= new_limit; cur_item->index = new_index; cur_item->next = new_items [new_index]; new_items [new_index] = cur_item; cur_item = next_item; } } // Destroy old hash table free (self->items); self->items = new_items; self->prime_index = new_prime_index; return 0; } // -------------------------------------------------------------------------- // Insert item into hash table with specified key and item. Returns 0 on // success. If the key is already present, or the process heap memory ran // out, returns -1 and leaves existing item unchanged. Sets the hash cursor // to the item, if found. int zhashx_insert (zhashx_t *self, const void *key, void *value) { assert (self); assert (key); // If we're exceeding the load factor of the hash table, // resize it according to the growth factor size_t limit = primes [self->prime_index]; if (self->size >= limit * LOAD_FACTOR / 100) { // Create new hash table uint new_prime_index = self->prime_index + GROWTH_FACTOR; if (s_zhashx_rehash (self, new_prime_index)) return -1; self->chain_limit += CHAIN_GROWS; } return s_item_insert (self, key, value) ? 0 : -1; } // -------------------------------------------------------------------------- // Local helper function // Insert new item into hash table, returns item // If item already existed, returns NULL // Sets the hash cursor to the item, if found. static item_t * s_item_insert (zhashx_t *self, const void *key, void *value) { // Check that item does not already exist in hash table // Leaves self->cached_index with calculated hash item item_t *item = s_item_lookup (self, key); if (item == NULL) { item = (item_t *) zmalloc (sizeof (item_t)); if (!item) return NULL; // If necessary, take duplicate of item key if (self->key_duplicator) item->key = (self->key_duplicator)((void *) key); else item->key = key; // If necessary, take duplicate of item value if (self->duplicator) item->value = (self->duplicator)(value); else item->value = value; item->index = self->cached_index; // Insert into start of bucket list item->next = self->items [self->cached_index]; self->items [self->cached_index] = item; self->size++; self->cursor_item = item; self->cursor_key = item->key; } else item = NULL; // Signal duplicate insertion return item; } // -------------------------------------------------------------------------- // Local helper function // Lookup item in hash table, returns item or NULL static item_t * s_item_lookup (zhashx_t *self, const void *key) { // Look in bucket list for item by key size_t limit = primes [self->prime_index]; self->cached_index = self->hasher (key) % limit; item_t *item = self->items [self->cached_index]; uint len = 0; while (item) { if ((self->key_comparator)(item->key, key) == 0) break; item = item->next; ++len; } if (len > self->chain_limit) { // Create new hash table uint new_prime_index = self->prime_index + GROWTH_FACTOR; if (s_zhashx_rehash (self, new_prime_index)) return NULL; limit = primes [self->prime_index]; self->cached_index = self->hasher (key) % limit; } return item; } // -------------------------------------------------------------------------- // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void zhashx_update (zhashx_t *self, const void *key, void *value) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { if (self->destructor) (self->destructor)(&item->value); else if (item->free_fn) (item->free_fn)(item->value); // If necessary, take duplicate of item value if (self->duplicator) item->value = (self->duplicator)(value); else item->value = value; } else zhashx_insert (self, key, value); } // -------------------------------------------------------------------------- // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhashx_delete (zhashx_t *self, const void *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) s_item_destroy (self, item, true); } // -------------------------------------------------------------------------- // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void zhashx_purge (zhashx_t *self) { assert (self); s_purge (self); if (self->prime_index > INITIAL_PRIME) { // Try to shrink hash table size_t limit = primes [INITIAL_PRIME]; item_t **items = (item_t **) zmalloc (sizeof (item_t *) * limit); if (items) { free (self->items); self->prime_index = INITIAL_PRIME; self->chain_limit = INITIAL_CHAIN; self->items = items; } } } // -------------------------------------------------------------------------- // Look for item in hash table and return its item, or NULL. Sets the hash // cursor to the item, if found. void * zhashx_lookup (zhashx_t *self, const void *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { self->cursor_item = item; self->cursor_key = item->key; return item->value; } else return NULL; } // -------------------------------------------------------------------------- // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. If the new key already exists, deletes old item. // Sets the item cursor to the renamed item. int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key) { item_t *old_item = s_item_lookup (self, old_key); item_t *new_item = s_item_lookup (self, new_key); if (old_item && !new_item) { s_item_destroy (self, old_item, false); if (self->key_destructor) (self->key_destructor)((void **) &old_item->key); if (self->key_duplicator) old_item->key = (self->key_duplicator)(new_key); else old_item->key = new_key; old_item->index = self->cached_index; old_item->next = self->items [self->cached_index]; self->items [self->cached_index] = old_item; self->size++; self->cursor_item = old_item; self->cursor_key = old_item->key; return 0; } else return -1; } // -------------------------------------------------------------------------- // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn *free_fn) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { item->free_fn = free_fn; return item->value; } else return NULL; } // -------------------------------------------------------------------------- // Return size of hash table size_t zhashx_size (zhashx_t *self) { assert (self); return self->size; } // -------------------------------------------------------------------------- // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. zlistx_t * zhashx_keys (zhashx_t *self) { assert (self); zlistx_t *keys = zlistx_new (); if (!keys) return NULL; zlistx_set_destructor (keys, self->key_destructor); zlistx_set_duplicator (keys, self->key_duplicator); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zlistx_add_end (keys, (void *) item->key) == NULL) { zlistx_destroy (&keys); return NULL; } item = item->next; } } return keys; } // Return a zlistx_t containing the items in the table. If there exists // a duplicator, then it is used to duplicate all items, and if there // is a destructor then it set as the destructor for the list. zlistx_t *zhashx_values(zhashx_t *self) { assert(self); zlistx_t *values = zlistx_new (); if (!values) return NULL; zlistx_set_destructor (values, self->destructor); zlistx_set_duplicator (values, self->duplicator); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zlistx_add_end (values, (void *) item->value) == NULL) { zlistx_destroy (&values); return NULL; } item = item->next; } } return values; } // -------------------------------------------------------------------------- // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. NOTE: do NOT modify the table // while iterating. void * zhashx_first (zhashx_t *self) { assert (self); // Point to before or at first item self->cursor_index = 0; self->cursor_item = self->items [self->cursor_index]; // Now scan forwards to find it, leave cursor after item return zhashx_next (self); } // -------------------------------------------------------------------------- // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). NOTE: // do NOT modify the table while iterating. void * zhashx_next (zhashx_t *self) { assert (self); // Scan forward from cursor until we find an item size_t limit = primes [self->prime_index]; while (self->cursor_item == NULL) { if (self->cursor_index < limit - 1) self->cursor_index++; else return NULL; // At end of table // Get first item in next bucket self->cursor_item = self->items [self->cursor_index]; } // We have an item, so return it, and bump past it assert (self->cursor_item); item_t *item = self->cursor_item; self->cursor_key = item->key; self->cursor_item = self->cursor_item->next; return item->value; } // -------------------------------------------------------------------------- // After a successful insert, update, or first/next method, returns the key // for the item that was returned. You may not modify or deallocate // the key, and it lasts as long as the item in the hash. // After an unsuccessful first/next, returns NULL. const void * zhashx_cursor (zhashx_t *self) { assert (self); return self->cursor_key; } // -------------------------------------------------------------------------- // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. // FIXME: return 0 on success, -1 on error void zhashx_comment (zhashx_t *self, const char *format, ...) { if (format) { if (!self->comments) { self->comments = zlistx_new (); if (!self->comments) return; zlistx_set_destructor (self->comments, (zhashx_destructor_fn *) zstr_free); } va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (string) zlistx_add_end (self->comments, string); } else zlistx_destroy (&self->comments); } // -------------------------------------------------------------------------- // Save hash table to a text file in name=value format // Hash values must be printable strings. // Returns 0 if OK, else -1 if a file error occurred int zhashx_save (zhashx_t *self, const char *filename) { assert (self); FILE *handle = fopen (filename, "w"); if (!handle) return -1; // Failed to create file if (self->comments) { char *comment = (char *) zlistx_first (self->comments); while (comment) { fprintf (handle, "# %s\n", comment); comment = (char *) zlistx_next (self->comments); } fprintf (handle, "\n"); } uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { fprintf (handle, "%s=%s\n", (char *) item->key, (char *) item->value); item = item->next; } } fclose (handle); return 0; } // -------------------------------------------------------------------------- // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings. // Returns 0 if OK, else -1 if a file was not readable. int zhashx_load (zhashx_t *self, const char *filename) { assert (self); zhashx_autofree (self); // Whether or not file exists, we'll track the filename and last // modification date (0 for unknown files), so that zhashx_refresh () // will always work after zhashx_load (), to load a newly-created // file. // Take copy of filename in case self->filename is same string. char *filename_copy = strdup (filename); if (filename_copy) { free (self->filename); self->filename = filename_copy; self->modified = zsys_file_modified (self->filename); FILE *handle = fopen (self->filename, "r"); if (handle) { char *buffer = (char *) zmalloc (1024); if (buffer) { while (fgets (buffer, 1024, handle)) { // Skip lines starting with "#" or that do not look like // name=value data. char *equals = strchr (buffer, '='); if (buffer [0] == '#' || equals == buffer || !equals) continue; // Buffer may end in newline, which we don't want if (buffer [strlen (buffer) - 1] == '\n') buffer [strlen (buffer) - 1] = 0; *equals++ = 0; zhashx_update (self, buffer, equals); } free (buffer); } else { fclose (handle); return -1; // Out of memory } fclose (handle); } else return -1; // Failed to open file for reading } else return -1; // Out of memory return 0; } // -------------------------------------------------------------------------- // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhashx_refresh (zhashx_t *self) { assert (self); if (self->filename) { if (zsys_file_modified (self->filename) > self->modified && zsys_file_stable (self->filename)) { // Empty the hash table; code is copied from zhashx_destroy uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } } zhashx_load (self, self->filename); } } return 0; } // -------------------------------------------------------------------------- // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhashx_pack (zhashx_t *self) { assert (self); // First, calculate packed data size size_t frame_size = 4; // Dictionary size, number-4 uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { // We store key as short string frame_size += 1 + strlen ((char *) item->key); // We store value as long string frame_size += 4 + strlen ((char *) item->value); item = item->next; } } // Now serialize items into the frame zframe_t *frame = zframe_new (NULL, frame_size); if (!frame) return NULL; byte *needle = zframe_data (frame); // Store size as number-4 *(uint32_t *) needle = htonl ((u_long) self->size); needle += 4; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { // Store key as string *needle++ = (byte) strlen ((char *) item->key); memcpy (needle, item->key, strlen ((char *) item->key)); needle += strlen ((char *) item->key); // Store value as longstr size_t lenth = strlen ((char *) item->value); *(uint32_t *) needle = htonl ((u_long) lenth); needle += 4; memcpy (needle, (char *) item->value, strlen ((char *) item->value)); needle += strlen ((char *) item->value); item = item->next; } } return frame; } // -------------------------------------------------------------------------- // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhashx_t * zhashx_unpack (zframe_t *frame) { zhashx_t *self = zhashx_new (); if (!self) return NULL; assert (frame); if (zframe_size (frame) < 4) return self; // Arguable... byte *needle = zframe_data (frame); byte *ceiling = needle + zframe_size (frame); size_t nbr_items = ntohl (*(uint32_t *) needle); needle += 4; while (nbr_items && needle < ceiling) { // Get key as string size_t key_size = *needle++; if (needle + key_size <= ceiling) { char key [256]; memcpy (key, needle, key_size); key [key_size] = 0; needle += key_size; // Get value as longstr if (needle + 4 <= ceiling) { size_t value_size = ntohl (*(uint32_t *) needle); needle += 4; // Be wary of malformed frames if (needle + value_size <= ceiling) { char *value = (char *) zmalloc (value_size + 1); if (!value) { zhashx_destroy (&self); return NULL; } memcpy (value, needle, value_size); value [value_size] = 0; needle += value_size; // Hash takes ownership of value if (zhashx_insert (self, key, value)) { zhashx_destroy (&self); break; } } } } } // Hash will free values in destructor if (self) zhashx_autofree (self); return self; } // -------------------------------------------------------------------------- // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. zhashx_t * zhashx_dup (zhashx_t *self) { if (!self) return NULL; zhashx_t *copy = zhashx_new (); if (copy) { copy->destructor = self->destructor; copy->duplicator = self->duplicator; uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zhashx_insert (copy, item->key, item->value)) { zhashx_destroy (©); break; } item = item->next; } } } return copy; } // -------------------------------------------------------------------------- // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor) { assert (self); self->destructor = destructor; } // -------------------------------------------------------------------------- // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator) { assert (self); self->duplicator = duplicator; } // -------------------------------------------------------------------------- // Set a user-defined deallocator for keyss; by default keys are // freed when the hash is destroyed by calling free(). void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor) { assert (self); self->key_destructor = destructor; } // -------------------------------------------------------------------------- // Set a user-defined duplicator for keys; by default keys are // duplicated by calling strdup(). void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator) { assert (self); self->key_duplicator = duplicator; } // -------------------------------------------------------------------------- // Set a user-defined comparator for keys; by default keys are // compared using streq. void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator) { assert (self); assert (comparator != NULL); self->key_comparator = comparator; } // -------------------------------------------------------------------------- // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher) { assert (self); self->hasher = hasher; } // -------------------------------------------------------------------------- // DEPRECATED by zhashx_dup // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhashx_t * zhashx_dup_v2 (zhashx_t *self) { if (!self) return NULL; zhashx_t *copy = zhashx_new (); if (copy) { zhashx_autofree (copy); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zhashx_insert (copy, item->key, item->value)) { zhashx_destroy (©); break; } item = item->next; } } } return copy; } // -------------------------------------------------------------------------- // DEPRECATED as clumsy -- use set_destructor instead // Set hash for automatic value destruction void zhashx_autofree (zhashx_t *self) { assert (self); zhashx_set_destructor (self, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (self, (zhashx_duplicator_fn *) strdup); } // -------------------------------------------------------------------------- // DEPRECATED as clumsy -- use zhashx_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). int zhashx_foreach (zhashx_t *self, zhashx_foreach_fn *callback, void *argument) { assert (self); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { // Invoke callback, passing item properties and argument item_t *next = item->next; int rc = callback ((const char *) item->key, item->value, argument); if (rc) return rc; // End if non-zero return code item = next; } } return 0; } // -------------------------------------------------------------------------- // Runs selftest of class // void zhashx_test (int verbose) { printf (" * zhashx: "); // @selftest zhashx_t *hash = zhashx_new (); assert (hash); assert (zhashx_size (hash) == 0); assert (zhashx_first (hash) == NULL); assert (zhashx_cursor (hash) == NULL); // Insert some items int rc; rc = zhashx_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhashx_first (hash); assert (streq ((char *) zhashx_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhashx_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhashx_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhashx_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhashx_size (hash) == 4); // Look for existing items item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhashx_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhashx_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhashx_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhashx_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhashx_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhashx_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhashx_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhashx_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlistx_t *keys = zhashx_keys (hash); assert (zlistx_size (keys) == 4); zlistx_destroy (&keys); zlistx_t *values = zhashx_values(hash); assert (zlistx_size (values) == 4); zlistx_destroy (&values); // Test dup method zhashx_t *copy = zhashx_dup (hash); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test pack/unpack methods zframe_t *frame = zhashx_pack (hash); copy = zhashx_unpack (frame); zframe_destroy (&frame); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test save and load zhashx_comment (hash, "This is a test file"); zhashx_comment (hash, "Created by %s", "czmq_selftest"); zhashx_save (hash, ".cache"); copy = zhashx_new (); assert (copy); zhashx_load (copy, ".cache"); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); zsys_file_delete (".cache"); // Delete a item zhashx_delete (hash, "LIVEBEEF"); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhashx_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr].exists) { item = (char *) zhashx_lookup (hash, testset [testnbr].name); assert (item); zhashx_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhashx_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhashx_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhashx_destroy (&hash); zhashx_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhashx_new (); assert (hash); zhashx_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhashx_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); zhashx_destroy (&hash); // @end printf ("OK\n"); } czmq-3.0.2/src/zmutex.c0000664000175000017500000000674612505070716014077 0ustar00phph00000000000000/* ========================================================================= zmutex - working with mutexes (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zmutex class provides a portable wrapper for mutexes. Please do not use this class to do multi-threading. It is for the rare case where you absolutely need thread-safe global state. This should happen in system code only. DO NOT USE THIS TO SHARE SOCKETS BETWEEN THREADS, OR DARK THINGS WILL HAPPEN TO YOUR CODE. @discuss @end */ #include "../include/czmq.h" // Structure of our class struct _zmutex_t { #if defined (__UNIX__) pthread_mutex_t mutex; #elif defined (__WINDOWS__) CRITICAL_SECTION mutex; #endif }; // -------------------------------------------------------------------------- // Constructor zmutex_t * zmutex_new (void) { zmutex_t *self = (zmutex_t *) zmalloc (sizeof (zmutex_t)); if (!self) return NULL; #if defined (__UNIX__) if (pthread_mutex_init (&self->mutex, NULL) != 0) { free (self); return NULL; } #elif defined (__WINDOWS__) InitializeCriticalSection (&self->mutex); #endif return self; } // -------------------------------------------------------------------------- // Destructor void zmutex_destroy (zmutex_t **self_p) { assert (self_p); if (*self_p) { zmutex_t *self = *self_p; #if defined (__UNIX__) pthread_mutex_destroy (&self->mutex); #elif defined (__WINDOWS__) DeleteCriticalSection (&self->mutex); #endif free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Lock mutex void zmutex_lock (zmutex_t *self) { assert (self); #if defined (__UNIX__) pthread_mutex_lock (&self->mutex); #elif defined (__WINDOWS__) EnterCriticalSection (&self->mutex); #endif } // -------------------------------------------------------------------------- // Unlock mutex void zmutex_unlock (zmutex_t *self) { assert (self); #if defined (__UNIX__) pthread_mutex_unlock (&self->mutex); #elif defined (__WINDOWS__) LeaveCriticalSection (&self->mutex); #endif } // -------------------------------------------------------------------------- // Try to lock mutex. // Returns: // 0 if the mutex is already locked // 1 if the mutex lock has successfully been acquired // -1 on error int zmutex_try_lock (zmutex_t *self) { assert (self); #if defined (__UNIX__) // rc is either EBUSY or 0 int rc = pthread_mutex_trylock (&self->mutex); return rc == EBUSY ? 0 : 1; #elif defined (__WINDOWS__) // rc is nonzero if the mutex lock has been acquired int rc = TryEnterCriticalSection (&self->mutex); return rc != 0 ? 1 : 0; #endif } // -------------------------------------------------------------------------- // Selftest void zmutex_test (bool verbose) { printf (" * zmutex (deprecated): "); // @selftest zmutex_t *mutex = zmutex_new (); assert (mutex); zmutex_lock (mutex); zmutex_unlock (mutex); zmutex_destroy (&mutex); // @end printf ("OK\n"); } czmq-3.0.2/src/zgossip_msg.h0000664000175000017500000001066112533132116015075 0ustar00phph00000000000000/* ========================================================================= zgossip_msg - ZeroMQ Gossip Protocol Codec header for zgossip_msg. ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip_msg.xml, or * The code generation script that built this file: zproto_codec_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZGOSSIP_MSG_H_INCLUDED #define ZGOSSIP_MSG_H_INCLUDED /* These are the zgossip_msg messages: HELLO - Client says hello to server version number 1 Version = 1 PUBLISH - Client or server announces a new tuple version number 1 Version = 1 key string Tuple key, globally unique value longstr Tuple value, as printable string ttl number 4 Time to live, msecs PING - Client signals liveness version number 1 Version = 1 PONG - Server responds to ping; note that pongs are not correlated with pings, and may be mixed with other commands, and the client should treat any incoming traffic as valid activity. version number 1 Version = 1 INVALID - Server rejects command as invalid version number 1 Version = 1 */ #define ZGOSSIP_MSG_HELLO 1 #define ZGOSSIP_MSG_PUBLISH 2 #define ZGOSSIP_MSG_PING 3 #define ZGOSSIP_MSG_PONG 4 #define ZGOSSIP_MSG_INVALID 5 #include "czmq.h" #ifdef __cplusplus extern "C" { #endif // Opaque class structure #ifndef ZGOSSIP_MSG_T_DEFINED typedef struct _zgossip_msg_t zgossip_msg_t; #define ZGOSSIP_MSG_T_DEFINED #endif // @interface // Create a new empty zgossip_msg CZMQ_EXPORT zgossip_msg_t * zgossip_msg_new (void); // Destroy a zgossip_msg instance CZMQ_EXPORT void zgossip_msg_destroy (zgossip_msg_t **self_p); // Receive a zgossip_msg from the socket. Returns 0 if OK, -1 if // there was an error. Blocks if there is no message waiting. CZMQ_EXPORT int zgossip_msg_recv (zgossip_msg_t *self, zsock_t *input); // Send the zgossip_msg to the output socket, does not destroy it CZMQ_EXPORT int zgossip_msg_send (zgossip_msg_t *self, zsock_t *output); // Print contents of message to stdout CZMQ_EXPORT void zgossip_msg_print (zgossip_msg_t *self); // Get/set the message routing id CZMQ_EXPORT zframe_t * zgossip_msg_routing_id (zgossip_msg_t *self); CZMQ_EXPORT void zgossip_msg_set_routing_id (zgossip_msg_t *self, zframe_t *routing_id); // Get the zgossip_msg id and printable command CZMQ_EXPORT int zgossip_msg_id (zgossip_msg_t *self); CZMQ_EXPORT void zgossip_msg_set_id (zgossip_msg_t *self, int id); CZMQ_EXPORT const char * zgossip_msg_command (zgossip_msg_t *self); // Get/set the key field CZMQ_EXPORT const char * zgossip_msg_key (zgossip_msg_t *self); CZMQ_EXPORT void zgossip_msg_set_key (zgossip_msg_t *self, const char *value); // Get/set the value field CZMQ_EXPORT const char * zgossip_msg_value (zgossip_msg_t *self); CZMQ_EXPORT void zgossip_msg_set_value (zgossip_msg_t *self, const char *value); // Get/set the ttl field CZMQ_EXPORT uint32_t zgossip_msg_ttl (zgossip_msg_t *self); CZMQ_EXPORT void zgossip_msg_set_ttl (zgossip_msg_t *self, uint32_t ttl); // Self test of this class CZMQ_EXPORT int zgossip_msg_test (bool verbose); // @end // For backwards compatibility with old codecs #define zgossip_msg_dump zgossip_msg_print #ifdef __cplusplus } #endif #endif czmq-3.0.2/src/zgossip_engine.inc0000664000175000017500000010136112533132116016074 0ustar00phph00000000000000/* ========================================================================= zgossip_engine - zgossip engine ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip.xml, or * The code generation script that built this file: zproto_server_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ // --------------------------------------------------------------------------- // State machine constants typedef enum { start_state = 1, have_tuple_state = 2, connected_state = 3, external_state = 4 } state_t; typedef enum { NULL_event = 0, terminate_event = 1, hello_event = 2, ok_event = 3, finished_event = 4, publish_event = 5, forward_event = 6, ping_event = 7, expired_event = 8 } event_t; // Names for state machine logging and error reporting static char * s_state_name [] = { "(NONE)", "start", "have tuple", "connected", "external" }; static char * s_event_name [] = { "(NONE)", "terminate", "HELLO", "ok", "finished", "PUBLISH", "forward", "PING", "expired" }; // --------------------------------------------------------------------------- // Context for the whole server task. This embeds the application-level // server context at its start (the entire structure, not a reference), // so we can cast a pointer between server_t and s_server_t arbitrarily. typedef struct { server_t server; // Application-level server context zsock_t *pipe; // Socket to back to caller API zsock_t *router; // Socket to talk to clients int port; // Server port bound to zloop_t *loop; // Reactor for server sockets zgossip_msg_t *message; // Message received or sent zhash_t *clients; // Clients we're connected to zconfig_t *config; // Configuration tree uint client_id; // Client identifier counter size_t timeout; // Default client expiry timeout bool verbose; // Verbose logging enabled? char *log_prefix; // Default log prefix } s_server_t; // --------------------------------------------------------------------------- // Context for each connected client. This embeds the application-level // client context at its start (the entire structure, not a reference), // so we can cast a pointer between client_t and s_client_t arbitrarily. typedef struct { client_t client; // Application-level client context s_server_t *server; // Parent server context char *hashkey; // Key into server->clients hash zframe_t *routing_id; // Routing_id back to client uint unique_id; // Client identifier in server state_t state; // Current state event_t event; // Current event event_t next_event; // The next event event_t exception; // Exception event, if any int wakeup; // zloop timer for client alarms void *ticket; // zloop ticket for client timeouts event_t wakeup_event; // Wake up with this event char log_prefix [41]; // Log prefix string } s_client_t; static int server_initialize (server_t *self); static void server_terminate (server_t *self); static zmsg_t * server_method (server_t *self, const char *method, zmsg_t *msg); static int client_initialize (client_t *self); static void client_terminate (client_t *self); static void s_client_execute (s_client_t *client, event_t event); static int s_client_handle_wakeup (zloop_t *loop, int timer_id, void *argument); static int s_client_handle_ticket (zloop_t *loop, int timer_id, void *argument); static void get_first_tuple (client_t *self); static void get_next_tuple (client_t *self); static void store_tuple_if_new (client_t *self); static void get_tuple_to_forward (client_t *self); // --------------------------------------------------------------------------- // These methods are an internal API for actions // Set the next event, needed in at least one action in an internal // state; otherwise the state machine will wait for a message on the // router socket and treat that as the event. static void engine_set_next_event (client_t *client, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; self->next_event = event; } } // Raise an exception with 'event', halting any actions in progress. // Continues execution of actions defined for the exception event. static void engine_set_exception (client_t *client, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; self->exception = event; } } // Set wakeup alarm after 'delay' msecs. The next state should // handle the wakeup event. The alarm is cancelled on any other // event. static void engine_set_wakeup_event (client_t *client, size_t delay, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; if (self->wakeup) { zloop_timer_end (self->server->loop, self->wakeup); self->wakeup = 0; } self->wakeup = zloop_timer ( self->server->loop, delay, 1, s_client_handle_wakeup, self); self->wakeup_event = event; } } // Execute 'event' on specified client. Use this to send events to // other clients. Cancels any wakeup alarm on that client. static void engine_send_event (client_t *client, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; s_client_execute (self, event); } } // Execute 'event' on all clients known to the server. If you pass a // client argument, that client will not receive the broadcast. If you // want to pass any arguments, store them in the server context. static void engine_broadcast_event (server_t *server, client_t *client, event_t event) { if (server) { s_server_t *self = (s_server_t *) server; zlist_t *keys = zhash_keys (self->clients); char *key = (char *) zlist_first (keys); while (key) { s_client_t *target = (s_client_t *) zhash_lookup (self->clients, key); if (target != (s_client_t *) client) s_client_execute (target, event); key = (char *) zlist_next (keys); } zlist_destroy (&keys); } } // Poll actor or zsock for activity, invoke handler on any received // message. Handler must be a CZMQ zloop_fn function; receives server // as arg. static void engine_handle_socket (server_t *server, void *sock, zloop_reader_fn handler) { if (server) { s_server_t *self = (s_server_t *) server; // Resolve zactor_t -> zsock_t if (zactor_is (sock)) sock = zactor_sock ((zactor_t *) sock); else assert (zsock_is (sock)); if (handler != NULL) { int rc = zloop_reader (self->loop, (zsock_t *) sock, handler, self); assert (rc == 0); zloop_reader_set_tolerant (self->loop, (zsock_t *) sock); } else zloop_reader_end (self->loop, (zsock_t *) sock); } } // Register monitor function that will be called at regular intervals // by the server engine static void engine_set_monitor (server_t *server, size_t interval, zloop_timer_fn monitor) { if (server) { s_server_t *self = (s_server_t *) server; int rc = zloop_timer (self->loop, interval, 0, monitor, self); assert (rc >= 0); } } // Set log file prefix; this string will be added to log data, to make // log data more searchable. The string is truncated to ~20 chars. static void engine_set_log_prefix (client_t *client, const char *string) { if (client) { s_client_t *self = (s_client_t *) client; snprintf (self->log_prefix, sizeof (self->log_prefix) - 1, "%6d:%-33s", self->unique_id, string); } } // Set a configuration value in the server's configuration tree. The // properties this engine uses are: server/verbose, server/timeout, and // server/background. You can also configure other abitrary properties. static void engine_configure (server_t *server, const char *path, const char *value) { if (server) { s_server_t *self = (s_server_t *) server; zconfig_put (self->config, path, value); } } // Return true if server is running in verbose mode, else return false. static bool engine_verbose (server_t *server) { if (server) { s_server_t *self = (s_server_t *) server; return self->verbose; } return false; } // Pedantic compilers don't like unused functions, so we call the whole // API, passing null references. It's nasty and horrid and sufficient. static void s_satisfy_pedantic_compilers (void) { engine_set_next_event (NULL, NULL_event); engine_set_exception (NULL, NULL_event); engine_set_wakeup_event (NULL, 0, NULL_event); engine_send_event (NULL, NULL_event); engine_broadcast_event (NULL, NULL, NULL_event); engine_handle_socket (NULL, 0, NULL); engine_set_monitor (NULL, 0, NULL); engine_set_log_prefix (NULL, NULL); engine_configure (NULL, NULL, NULL); engine_verbose (NULL); } // --------------------------------------------------------------------------- // Generic methods on protocol messages // TODO: replace with lookup table, since ID is one byte static event_t s_protocol_event (zgossip_msg_t *message) { assert (message); switch (zgossip_msg_id (message)) { case ZGOSSIP_MSG_HELLO: return hello_event; break; case ZGOSSIP_MSG_PUBLISH: return publish_event; break; case ZGOSSIP_MSG_PING: return ping_event; break; default: // Invalid zgossip_msg_t return terminate_event; } } // --------------------------------------------------------------------------- // Client methods static s_client_t * s_client_new (s_server_t *server, zframe_t *routing_id) { s_client_t *self = (s_client_t *) zmalloc (sizeof (s_client_t)); assert (self); assert ((s_client_t *) &self->client == self); self->server = server; self->hashkey = zframe_strhex (routing_id); self->routing_id = zframe_dup (routing_id); self->unique_id = server->client_id++; engine_set_log_prefix (&self->client, server->log_prefix); self->client.server = (server_t *) server; self->client.message = server->message; // If expiry timers are being used, create client ticket if (server->timeout) self->ticket = zloop_ticket (server->loop, s_client_handle_ticket, self); // Give application chance to initialize and set next event self->state = start_state; self->event = NULL_event; client_initialize (&self->client); return self; } static void s_client_destroy (s_client_t **self_p) { assert (self_p); if (*self_p) { s_client_t *self = *self_p; if (self->wakeup) zloop_timer_end (self->server->loop, self->wakeup); if (self->ticket) zloop_ticket_delete (self->server->loop, self->ticket); zframe_destroy (&self->routing_id); // Provide visual clue if application misuses client reference engine_set_log_prefix (&self->client, "*** TERMINATED ***"); client_terminate (&self->client); free (self->hashkey); free (self); *self_p = NULL; } } // Callback when we remove client from 'clients' hash table static void s_client_free (void *argument) { s_client_t *client = (s_client_t *) argument; s_client_destroy (&client); } // Execute state machine as long as we have events static void s_client_execute (s_client_t *self, event_t event) { self->next_event = event; // Cancel wakeup timer, if any was pending if (self->wakeup) { zloop_timer_end (self->server->loop, self->wakeup); self->wakeup = 0; } while (self->next_event > 0) { self->event = self->next_event; self->next_event = NULL_event; self->exception = NULL_event; if (self->server->verbose) { zsys_debug ("%s: %s:", self->log_prefix, s_state_name [self->state]); zsys_debug ("%s: %s", self->log_prefix, s_event_name [self->event]); } switch (self->state) { case start_state: if (self->event == hello_event) { if (!self->exception) { // get first tuple if (self->server->verbose) zsys_debug ("%s: $ get first tuple", self->log_prefix); get_first_tuple (&self->client); } if (!self->exception) self->state = have_tuple_state; } else if (self->event == ping_event) { if (!self->exception) { // send PONG if (self->server->verbose) zsys_debug ("%s: $ send PONG", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PONG); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == expired_event) { if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } else { // Handle unexpected protocol events if (!self->exception) { // send INVALID if (self->server->verbose) zsys_debug ("%s: $ send INVALID", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_INVALID); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } break; case have_tuple_state: if (self->event == ok_event) { if (!self->exception) { // send PUBLISH if (self->server->verbose) zsys_debug ("%s: $ send PUBLISH", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // get next tuple if (self->server->verbose) zsys_debug ("%s: $ get next tuple", self->log_prefix); get_next_tuple (&self->client); } } else if (self->event == finished_event) { if (!self->exception) self->state = connected_state; } else { // Handle unexpected internal events zsys_warning ("%s: unhandled event %s in %s", self->log_prefix, s_event_name [self->event], s_state_name [self->state]); assert (false); } break; case connected_state: if (self->event == publish_event) { if (!self->exception) { // store tuple if new if (self->server->verbose) zsys_debug ("%s: $ store tuple if new", self->log_prefix); store_tuple_if_new (&self->client); } } else if (self->event == forward_event) { if (!self->exception) { // get tuple to forward if (self->server->verbose) zsys_debug ("%s: $ get tuple to forward", self->log_prefix); get_tuple_to_forward (&self->client); } if (!self->exception) { // send PUBLISH if (self->server->verbose) zsys_debug ("%s: $ send PUBLISH", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == ping_event) { if (!self->exception) { // send PONG if (self->server->verbose) zsys_debug ("%s: $ send PONG", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PONG); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == expired_event) { if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } else { // Handle unexpected protocol events if (!self->exception) { // send INVALID if (self->server->verbose) zsys_debug ("%s: $ send INVALID", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_INVALID); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } break; case external_state: if (self->event == ping_event) { if (!self->exception) { // send PONG if (self->server->verbose) zsys_debug ("%s: $ send PONG", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PONG); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == expired_event) { if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } else { // Handle unexpected protocol events if (!self->exception) { // send INVALID if (self->server->verbose) zsys_debug ("%s: $ send INVALID", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_INVALID); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } break; } // If we had an exception event, interrupt normal programming if (self->exception) { if (self->server->verbose) zsys_debug ("%s: ! %s", self->log_prefix, s_event_name [self->exception]); self->next_event = self->exception; } if (self->next_event == terminate_event) { // Automatically calls s_client_destroy zhash_delete (self->server->clients, self->hashkey); break; } else if (self->server->verbose) zsys_debug ("%s: > %s", self->log_prefix, s_state_name [self->state]); } } // zloop callback when client ticket expires static int s_client_handle_ticket (zloop_t *loop, int timer_id, void *argument) { s_client_t *self = (s_client_t *) argument; s_client_execute (self, expired_event); self->ticket = NULL; // Ticket is now dead return 0; } // zloop callback when client wakeup timer expires static int s_client_handle_wakeup (zloop_t *loop, int timer_id, void *argument) { s_client_t *self = (s_client_t *) argument; s_client_execute (self, self->wakeup_event); return 0; } // Server methods static void s_server_config_global (s_server_t *self) { // Built-in server configuration options // // If we didn't already set verbose, check if the config tree wants it if (!self->verbose && atoi (zconfig_resolve (self->config, "server/verbose", "0"))) self->verbose = true; // Default client timeout is 60 seconds self->timeout = atoi ( zconfig_resolve (self->config, "server/timeout", "60000")); zloop_set_ticket_delay (self->loop, self->timeout); // Do we want to run server in the background? int background = atoi ( zconfig_resolve (self->config, "server/background", "0")); if (!background) zsys_set_logstream (stdout); } static s_server_t * s_server_new (zsock_t *pipe) { s_server_t *self = (s_server_t *) zmalloc (sizeof (s_server_t)); assert (self); assert ((s_server_t *) &self->server == self); self->pipe = pipe; self->router = zsock_new (ZMQ_ROUTER); // By default the socket will discard outgoing messages above the // HWM of 1,000. This isn't helpful for high-volume streaming. We // will use a unbounded queue here. If applications need to guard // against queue overflow, they should use a credit-based flow // control scheme. zsock_set_unbounded (self->router); self->message = zgossip_msg_new (); self->clients = zhash_new (); self->config = zconfig_new ("root", NULL); self->loop = zloop_new (); srandom ((unsigned int) zclock_time ()); self->client_id = randof (1000); s_server_config_global (self); // Initialize application server context self->server.pipe = self->pipe; self->server.config = self->config; server_initialize (&self->server); s_satisfy_pedantic_compilers (); return self; } static void s_server_destroy (s_server_t **self_p) { assert (self_p); if (*self_p) { s_server_t *self = *self_p; zgossip_msg_destroy (&self->message); // Destroy clients before destroying the server zhash_destroy (&self->clients); server_terminate (&self->server); zsock_destroy (&self->router); zconfig_destroy (&self->config); zloop_destroy (&self->loop); free (self); *self_p = NULL; } } // Apply service-specific configuration tree: // * apply server configuration // * print any echo items in top-level sections // * apply sections that match methods static void s_server_config_service (s_server_t *self) { // Apply echo commands and class methods zconfig_t *section = zconfig_locate (self->config, "zgossip"); if (section) section = zconfig_child (section); while (section) { if (streq (zconfig_name (section), "echo")) zsys_notice ("%s", zconfig_value (section)); else if (streq (zconfig_name (section), "bind")) { char *endpoint = zconfig_resolve (section, "endpoint", "?"); if (zsock_bind (self->router, "%s", endpoint) == -1) zsys_warning ("could not bind to %s (%s)", endpoint, zmq_strerror (zmq_errno ())); } #if (ZMQ_VERSION_MAJOR >= 4) else if (streq (zconfig_name (section), "security")) { char *mechanism = zconfig_resolve (section, "mechanism", "null"); char *domain = zconfig_resolve (section, "domain", NULL); if (streq (mechanism, "null")) { zsys_notice ("server is using NULL security"); if (domain) zsock_set_zap_domain (self->router, NULL); } else if (streq (mechanism, "plain")) { zsys_notice ("server is using PLAIN security"); zsock_set_plain_server (self->router, 1); } else zsys_warning ("mechanism=%s is not supported", mechanism); } #endif section = zconfig_next (section); } s_server_config_global (self); } // Process message from pipe static int s_server_handle_pipe (zloop_t *loop, zsock_t *reader, void *argument) { s_server_t *self = (s_server_t *) argument; zmsg_t *msg = zmsg_recv (self->pipe); if (!msg) return -1; // Interrupted; exit zloop char *method = zmsg_popstr (msg); if (self->verbose) zsys_debug ("%s: API command=%s", self->log_prefix, method); if (streq (method, "VERBOSE")) self->verbose = true; else if (streq (method, "$TERM")) { // Shutdown the engine free (method); zmsg_destroy (&msg); return -1; } else if (streq (method, "BIND")) { // Bind to a specified endpoint, which may use an ephemeral port char *endpoint = zmsg_popstr (msg); self->port = zsock_bind (self->router, "%s", endpoint); if (self->port == -1) zsys_warning ("could not bind to %s", endpoint); free (endpoint); } else if (streq (method, "PORT")) { // Return PORT + port number from the last bind, if any zstr_sendm (self->pipe, "PORT"); zstr_sendf (self->pipe, "%d", self->port); } else // Deprecated method name if (streq (method, "LOAD") || streq (method, "CONFIGURE")) { char *filename = zmsg_popstr (msg); zconfig_destroy (&self->config); self->config = zconfig_load (filename); if (self->config) { s_server_config_service (self); self->server.config = self->config; } else { zsys_warning ("cannot load config file '%s'", filename); self->config = zconfig_new ("root", NULL); } free (filename); } else if (streq (method, "SET")) { char *path = zmsg_popstr (msg); char *value = zmsg_popstr (msg); zconfig_put (self->config, path, value); if (streq (path, "server/animate")) { zsys_warning ("'%s' is deprecated, use VERBOSE command instead", path); self->verbose = atoi (value); } s_server_config_global (self); free (path); free (value); } else if (streq (method, "SAVE")) { char *filename = zmsg_popstr (msg); if (zconfig_save (self->config, filename)) zsys_warning ("cannot save config file '%s'", filename); free (filename); } else { // Execute custom method zmsg_t *reply = server_method (&self->server, method, msg); // If reply isn't null, send it to caller zmsg_send (&reply, self->pipe); } free (method); zmsg_destroy (&msg); return 0; } // Handle a protocol message from the client static int s_server_handle_protocol (zloop_t *loop, zsock_t *reader, void *argument) { s_server_t *self = (s_server_t *) argument; // We process as many messages as we can, to reduce the overhead // of polling and the reactor: while (zsock_events (self->router) & ZMQ_POLLIN) { if (zgossip_msg_recv (self->message, self->router)) return -1; // Interrupted; exit zloop // TODO: use binary hashing on routing_id char *hashkey = zframe_strhex (zgossip_msg_routing_id (self->message)); s_client_t *client = (s_client_t *) zhash_lookup (self->clients, hashkey); if (client == NULL) { client = s_client_new (self, zgossip_msg_routing_id (self->message)); zhash_insert (self->clients, hashkey, client); zhash_freefn (self->clients, hashkey, s_client_free); } free (hashkey); // Any input from client counts as activity if (client->ticket) zloop_ticket_reset (self->loop, client->ticket); // Pass to client state machine s_client_execute (client, s_protocol_event (self->message)); } return 0; } // Watch server config file and reload if changed static int s_watch_server_config (zloop_t *loop, int timer_id, void *argument) { s_server_t *self = (s_server_t *) argument; if (zconfig_has_changed (self->config) && zconfig_reload (&self->config) == 0) { s_server_config_service (self); self->server.config = self->config; zsys_notice ("reloaded configuration from %s", zconfig_filename (self->config)); } return 0; } // --------------------------------------------------------------------------- // This is the server actor, which polls its two sockets and processes // incoming messages void zgossip (zsock_t *pipe, void *args) { // Initialize s_server_t *self = s_server_new (pipe); assert (self); zsock_signal (pipe, 0); // Actor argument may be a string used for logging self->log_prefix = args? (char *) args: ""; // Set-up server monitor to watch for config file changes engine_set_monitor ((server_t *) self, 1000, s_watch_server_config); // Set up handler for the two main sockets the server uses engine_handle_socket ((server_t *) self, self->pipe, s_server_handle_pipe); engine_handle_socket ((server_t *) self, self->router, s_server_handle_protocol); // Run reactor until there's a termination signal zloop_start (self->loop); // Reactor has ended s_server_destroy (&self); } czmq-3.0.2/src/platform.h.in0000664000175000017500000001275412535241743015000 0ustar00phph00000000000000/* src/platform.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Have AIX OS */ #undef CZMQ_HAVE_AIX /* Have Android OS */ #undef CZMQ_HAVE_ANDROID /* Have Cygwin */ #undef CZMQ_HAVE_CYGWIN /* Have FreeBSD OS */ #undef CZMQ_HAVE_FREEBSD /* Have HPUX OS */ #undef CZMQ_HAVE_HPUX /* Have Linux OS */ #undef CZMQ_HAVE_LINUX /* Have MinGW32 */ #undef CZMQ_HAVE_MINGW32 /* Have NetBSD OS */ #undef CZMQ_HAVE_NETBSD /* Have OpenBSD OS */ #undef CZMQ_HAVE_OPENBSD /* Have DarwinOSX OS */ #undef CZMQ_HAVE_OSX /* Have QNX Neutrino OS */ #undef CZMQ_HAVE_QNXNTO /* Have Solaris OS */ #undef CZMQ_HAVE_SOLARIS /* Have Windows OS */ #undef CZMQ_HAVE_WINDOWS /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the `getifaddrs' function. */ #undef HAVE_GETIFADDRS /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_IFADDRS_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_WIRELESS_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_MEDIA_H /* Define to 1 if you have the `perror' function. */ #undef HAVE_PERROR /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* CZMQ major version */ #undef PACKAGE_VERSION_MAJOR /* CZMQ minor version */ #undef PACKAGE_VERSION_MINOR /* CZMQ patchlevel */ #undef PACKAGE_VERSION_PATCH /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile czmq-3.0.2/src/zclock.c0000664000175000017500000001660712505070716014025 0ustar00phph00000000000000/* ========================================================================= zclock - millisecond clocks and delays Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling. Wraps the non-portable system calls in a simple portable API. @discuss The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity. @end */ #include "../include/czmq.h" #if defined (__WINDOWS__) // -------------------------------------------------------------------------- // Convert FILETIME "Contains a 64-bit value representing the number of // 100-nanosecond intervals since January 1, 1601 (UTC)." static int64_t s_filetime_to_msec (const FILETIME *ft) { // As per Windows documentation for FILETIME, copy the resulting FILETIME // structure to a ULARGE_INTEGER structure using memcpy (using memcpy // instead of direct assignment can prevent alignment faults on 64-bit // Windows). ULARGE_INTEGER dateTime; memcpy (&dateTime, ft, sizeof (dateTime)); return (int64_t) (dateTime.QuadPart / 10000); } #endif // -------------------------------------------------------------------------- // Sleep for a number of milliseconds void zclock_sleep (int msecs) { #if defined (__UNIX__) struct timespec t; t.tv_sec = msecs / 1000; t.tv_nsec = (msecs % 1000) * 1000000; nanosleep (&t, NULL); #elif (defined (__WINDOWS__)) // Windows XP/2000: A value of zero causes the thread to relinquish the // remainder of its time slice to any other thread of equal priority that // is ready to run. If there are no other threads of equal priority ready // to run, the function returns immediately, and the thread continues // execution. This behavior changed starting with Windows Server 2003. # if defined (NTDDI_VERSION) && defined (NTDDI_WS03) && (NTDDI_VERSION >= NTDDI_WS03) Sleep (msecs); # else if (msecs > 0) Sleep (msecs); # endif #endif } // -------------------------------------------------------------------------- // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t zclock_time (void) { #if defined (__UNIX__) struct timeval tv; gettimeofday (&tv, NULL); return (int64_t) ((int64_t) tv.tv_sec * 1000 + (int64_t) tv.tv_usec / 1000); #elif (defined (__WINDOWS__)) FILETIME ft; GetSystemTimeAsFileTime (&ft); return s_filetime_to_msec (&ft); #endif } // -------------------------------------------------------------------------- // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_mono (void) { #if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &cclock); clock_get_time (cclock, &mts); mach_port_deallocate (mach_task_self (), cclock); return (int64_t) ((int64_t) mts.tv_sec * 1000 + (int64_t) mts.tv_nsec / 1000000); #elif defined (__UNIX__) struct timespec ts; clock_gettime (CLOCK_MONOTONIC, &ts); return (int64_t) ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000); #elif (defined (__WINDOWS__)) // System frequency does not change at run-time, cache it static int64_t frequency = 0; if (frequency == 0) { LARGE_INTEGER freq; QueryPerformanceFrequency (&freq); // Windows documentation says that XP and later will always return non-zero assert (freq.QuadPart != 0); frequency = freq.QuadPart; } LARGE_INTEGER count; QueryPerformanceCounter (&count); return (int64_t) (count.QuadPart * 1000) / frequency; #endif } // -------------------------------------------------------------------------- // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_usecs (void) { #if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &cclock); clock_get_time (cclock, &mts); mach_port_deallocate (mach_task_self (), cclock); return (int64_t) ((int64_t) mts.tv_sec * 1000000 + (int64_t) mts.tv_nsec / 1000); #elif defined (__UNIX__) struct timespec ts; clock_gettime (CLOCK_MONOTONIC, &ts); return (int64_t) ((int64_t) ts.tv_sec * 1000000 + (int64_t) ts.tv_nsec / 1000); #elif (defined (__WINDOWS__)) // System frequency does not change at run-time, cache it static int64_t frequency = 0; if (frequency == 0) { LARGE_INTEGER freq; QueryPerformanceFrequency (&freq); // Windows documentation says that XP and later will always return non-zero assert (freq.QuadPart != 0); frequency = freq.QuadPart; } LARGE_INTEGER count; QueryPerformanceCounter (&count); return (int64_t) (count.QuadPart * 1000000) / frequency; #endif } // -------------------------------------------------------------------------- // Return formatted date/time as fresh string. Free using zstr_free(). char * zclock_timestr (void) { time_t curtime = time (NULL); struct tm *loctime = localtime (&curtime); char formatted [20]; strftime (formatted, 20, "%Y-%m-%d %H:%M:%S", loctime); return strdup (formatted); } // -------------------------------------------------------------------------- // DEPRECATED in favor of zsys logging, see issue #519 // Print formatted string to stdout, prefixed by date/time and // terminated with a newline. void zclock_log (const char *format, ...) { time_t curtime = time (NULL); struct tm *loctime = localtime (&curtime); char formatted [20]; strftime (formatted, 20, "%y-%m-%d %H:%M:%S ", loctime); printf ("%s", formatted); va_list argptr; va_start (argptr, format); vprintf (format, argptr); va_end (argptr); printf ("\n"); fflush (stdout); } // -------------------------------------------------------------------------- // Self test of this class void zclock_test (bool verbose) { printf (" * zclock: "); // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); start = zclock_mono (); int64_t usecs = zclock_usecs (); zclock_sleep (10); assert ((zclock_mono () - start) >= 10); assert ((zclock_usecs () - usecs) >= 10000); char *timestr = zclock_timestr (); if (verbose) puts (timestr); free (timestr); // @end printf ("OK\n"); } czmq-3.0.2/src/zstr.c0000664000175000017500000002045712522736135013543 0ustar00phph00000000000000/* ========================================================================= zstr - sending and receiving strings Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zstr class provides utility functions for sending and receiving C strings across 0MQ sockets. It sends strings without a terminating null, and appends a null byte on received strings. This class is for simple message sending. @discuss Memory Wire +-------------+---+ +---+-------------+ Send | S t r i n g | 0 | ----> | 6 | S t r i n g | +-------------+---+ +---+-------------+ Wire Heap +---+-------------+ +-------------+---+ Recv | 6 | S t r i n g | ----> | S t r i n g | 0 | +---+-------------+ +-------------+---+ @end */ #include "../include/czmq.h" static int s_send_string (void *dest, bool more, char *string) { assert (dest); void *handle = zsock_resolve (dest); size_t len = strlen (string); zmq_msg_t message; zmq_msg_init_size (&message, len); memcpy (zmq_msg_data (&message), string, len); if (zmq_sendmsg (handle, &message, more ? ZMQ_SNDMORE : 0) == -1) { zmq_msg_close (&message); return -1; } else return 0; } // -------------------------------------------------------------------------- // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. char * zstr_recv (void *source) { assert (source); void *handle = zsock_resolve (source); zmq_msg_t message; zmq_msg_init (&message); if (zmq_recvmsg (handle, &message, 0) < 0) return NULL; size_t size = zmq_msg_size (&message); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zmq_msg_data (&message), size); string [size] = 0; } zmq_msg_close (&message); return string; } // -------------------------------------------------------------------------- // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int zstr_send (void *dest, const char *string) { assert (dest); return s_send_string (dest, false, string ? (char *) string : ""); } // -------------------------------------------------------------------------- // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. String // may be NULL, which is sent as "". int zstr_sendm (void *dest, const char *string) { assert (dest); assert (string); return s_send_string (dest, true, (char *) string); } // -------------------------------------------------------------------------- // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int zstr_sendf (void *dest, const char *format, ...) { assert (dest); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); if (!string) return -1; va_end (argptr); int rc = s_send_string (dest, false, string); free (string); return rc; } // -------------------------------------------------------------------------- // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int zstr_sendfm (void *dest, const char *format, ...) { assert (dest); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); if (!string) return -1; va_end (argptr); int rc = s_send_string (dest, true, string); free (string); return rc; } // -------------------------------------------------------------------------- // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int zstr_sendx (void *dest, const char *string, ...) { zmsg_t *msg = zmsg_new (); if (!msg) return -1; va_list args; va_start (args, string); while (string) { zmsg_addstr (msg, string); string = va_arg (args, char *); } va_end (args); return zmsg_send (&msg, dest); } // -------------------------------------------------------------------------- // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int zstr_recvx (void *source, char **string_p, ...) { assert (source); void *handle = zsock_resolve (source); zmsg_t *msg = zmsg_recv (handle); if (!msg) return -1; // Filter a signal that may come from a dying actor if (zmsg_signal (msg) >= 0) { zmsg_destroy (&msg); return -1; } int count = 0; va_list args; va_start (args, string_p); while (string_p) { *string_p = zmsg_popstr (msg); string_p = va_arg (args, char **); count++; } va_end (args); zmsg_destroy (&msg); return count; } // -------------------------------------------------------------------------- // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zstr_free (char **string_p) { assert (string_p); free (*string_p); *string_p = NULL; } // -------------------------------------------------------------------------- // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive C string from socket, if socket had input ready. Caller must // free returned string using zstr_free. Returns NULL if there was no input // waiting, or if the context was terminated. Use zsys_interrupted to exit // any loop that relies on this method. char * zstr_recv_nowait (void *dest) { assert (dest); void *handle = zsock_resolve (dest); zmq_msg_t message; zmq_msg_init (&message); if (zmq_recvmsg (handle, &message, ZMQ_DONTWAIT) < 0) return NULL; size_t size = zmq_msg_size (&message); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zmq_msg_data (&message), size); string [size] = 0; } zmq_msg_close (&message); return string; } // -------------------------------------------------------------------------- // Selftest void zstr_test (bool verbose) { printf (" * zstr: "); // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zstr.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zstr.test"); assert (input); // Send ten strings, five strings with MORE flag and then END int string_nbr; for (string_nbr = 0; string_nbr < 10; string_nbr++) zstr_sendf (output, "this is string %d", string_nbr); zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL); // Read and count until we receive END string_nbr = 0; for (string_nbr = 0;; string_nbr++) { char *string = zstr_recv (input); assert (string); if (streq (string, "END")) { zstr_free (&string); break; } zstr_free (&string); } assert (string_nbr == 15); zsock_destroy (&input); zsock_destroy (&output); // @end printf ("OK\n"); } czmq-3.0.2/src/zconfig.c0000664000175000017500000006754112522736135014205 0ustar00phph00000000000000/* ========================================================================= zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Lets applications load, work with, and save configuration files. This implements rfc.zeromq.org/spec:4/ZPL, which is a simple structured text format for configuration files. @discuss Here is an example ZPL stream and corresponding config structure: context iothreads = 1 verbose = 1 # Ask for a trace main type = zqueue # ZMQ_DEVICE type frontend option hwm = 1000 swap = 25000000 # 25MB bind = 'inproc://addr1' bind = 'ipc://addr2' backend bind = inproc://addr3 root Down = child | Across = next v context-->main | | | v | type=queue-->frontend-->backend | | | | | v | | bind=inproc://addr3 | v | option-->bind=inproc://addr1-->bind=ipc://addr2 | | | v | hwm=1000-->swap=25000000 v iothreads=1-->verbose=false @end */ #include "../include/czmq.h" // Structure of our class struct _zconfig_t { char *name; // Property name if any char *value; // Property value, if any struct _zconfig_t *child, // First child if any *next, // Next sibling if any *parent; // Parent if any zlist_t *comments; // Comments if any zfile_t *file; // Config file handle }; // Local functions for parsing and saving ZPL tokens static int s_collect_level (char **start, int lineno); static char * s_collect_name (char **start, int lineno); static int s_verify_eoln (char *readptr, int lineno); static char * s_collect_value (char **start, int lineno); static int s_config_save (zconfig_t *self, void *arg, int level); static int s_config_execute (zconfig_t *self, zconfig_fct handler, void *arg, int level); // -------------------------------------------------------------------------- // Constructor // // Optionally attach new config to parent config, as first or next child. zconfig_t * zconfig_new (const char *name, zconfig_t *parent) { zconfig_t *self = (zconfig_t *) zmalloc (sizeof (zconfig_t)); if (!self) return NULL; zconfig_set_name (self, name); if (parent) { if (parent->child) { // Attach as last child of parent zconfig_t *last = parent->child; while (last->next) last = last->next; last->next = self; } else // Attach as first child of parent parent->child = self; } self->parent = parent; return self; } // -------------------------------------------------------------------------- // Destructor void zconfig_destroy (zconfig_t **self_p) { assert (self_p); if (*self_p) { zconfig_t *self = *self_p; // Destroy all children and siblings recursively zconfig_destroy (&self->child); zconfig_destroy (&self->next); // Destroy other properties and then self zlist_destroy (&self->comments); zfile_destroy (&self->file); free (self->name); free (self->value); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return name of config item char * zconfig_name (zconfig_t *self) { assert (self); return self->name; } // -------------------------------------------------------------------------- // Return value of config item char * zconfig_value (zconfig_t *self) { assert (self); return self->value; } // -------------------------------------------------------------------------- // Insert or update configuration key with value; leading slash is optional // and ignored. void zconfig_put (zconfig_t *self, const char *path, const char *value) { if (*path == '/') path++; // Check length of next path segment const char *slash = strchr (path, '/'); size_t length = strlen (path); if (slash) length = slash - path; // Find or create items starting at first child of root zconfig_t *child = self->child; while (child) { if (strlen (child->name) == length && memcmp (child->name, path, length) == 0) { // This segment exists if (slash) // Recurse to next level zconfig_put (child, slash + 1, value); else zconfig_set_value (child, "%s", value); return; } child = child->next; } // This segment doesn't exist, create it child = zconfig_new (path, self); assert (child); child->name [length] = 0; if (slash) // Recurse down further zconfig_put (child, slash, value); else zconfig_set_value (child, "%s", value); } // -------------------------------------------------------------------------- // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...) { assert (self); va_list argptr; va_start (argptr, format); char *value = zsys_vprintf (format, argptr); va_end (argptr); zconfig_put (self, path, value); zstr_free (&value); } // -------------------------------------------------------------------------- // Set new name for config item; this may be null. void zconfig_set_name (zconfig_t *self, const char *name) { assert (self); free (self->name); self->name = name? strdup (name): NULL; } // -------------------------------------------------------------------------- // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void zconfig_set_value (zconfig_t *self, const char *format, ...) { assert (self); free (self->value); if (format) { va_list argptr; va_start (argptr, format); self->value = zsys_vprintf (format, argptr); va_end (argptr); } else self->value = NULL; } // -------------------------------------------------------------------------- // Find our first child, if any zconfig_t * zconfig_child (zconfig_t *self) { assert (self); return self->child; } // -------------------------------------------------------------------------- // Find our first sibling, if any zconfig_t * zconfig_next (zconfig_t *self) { assert (self); return self->next; } // -------------------------------------------------------------------------- // Find a config item along a path; leading slash is optional and ignored. zconfig_t * zconfig_locate (zconfig_t *self, const char *path) { assert (self); // Check length of next path segment if (*path == '/') path++; const char *slash = strchr (path, '/'); size_t length = strlen (path); if (slash) length = slash - path; // Find matching name starting at first child of root zconfig_t *child = self->child; while (child) { if (strlen (child->name) == length && memcmp (child->name, path, length) == 0) { if (slash) // Look deeper return zconfig_locate (child, slash); else return child; } child = child->next; } return NULL; } // -------------------------------------------------------------------------- // Get value for config item into a string value; leading slash is optional // and ignored. char * zconfig_get (zconfig_t *self, const char *path, const char *default_value) { assert (self); zconfig_t *item = zconfig_locate (self, path); if (item) return zconfig_value (item); else return (char *) default_value; } // -------------------------------------------------------------------------- // Finds the latest node at the specified depth, where 0 is the root. If no // such node exists, returns NULL. zconfig_t * zconfig_at_depth (zconfig_t *self, int level) { assert (self); while (level > 0) { if (self->child) { self = self->child; while (self->next) self = self->next; level--; } else return NULL; } return self; } // -------------------------------------------------------------------------- // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg) { // Execute top level config at level zero assert (self); return s_config_execute (self, handler, arg, 0) >= 0? 0: -1; } // Return number of bytes processed, or zero static int s_config_execute (zconfig_t *self, zconfig_fct handler, void *arg, int level) { assert (self); int size = handler (self, arg, level); // Process all children in one go, as a list zconfig_t *child = self->child; while (child) { int rc = s_config_execute (child, handler, arg, level + 1); if (rc == -1) return -1; size += rc; child = child->next; } return size; } // -------------------------------------------------------------------------- // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. zconfig_t * zconfig_load (const char *filename) { // Load entire file into memory as a chunk, then process it zconfig_t *self = NULL; zfile_t *file = zfile_new (NULL, filename); if (!file) return NULL; if (zfile_input (file) == 0) { zchunk_t *chunk = zfile_read (file, zfile_cursize (file), 0); if (chunk) { self = zconfig_chunk_load (chunk); zchunk_destroy (&chunk); if (self) self->file = file; zfile_close (file); file = NULL; // Config tree now owns file handle } } zfile_destroy (&file); return self; } // -------------------------------------------------------------------------- // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int zconfig_save (zconfig_t *self, const char *filename) { assert (self); int rc = 0; if (streq (filename, "-")) // "-" means write to stdout rc = zconfig_execute (self, s_config_save, stdout); else { FILE *file; file = fopen (filename, "w"); if (file) { rc = zconfig_execute (self, s_config_save, file); fflush (file); fclose (file); // If we saved back to original file, restat it so that // the file does not appear as "changed" if (self->file && streq (filename, zconfig_filename (self))) zfile_restat (self->file); } else rc = -1; // File not writeable } return rc; } // Save an item, polymorphic: if arg is a zchunk_t *, appends the // data to the chunk; else if arg is not null, writes data to the // arg as FILE *, or appends to the chunk data. If arg is null, // stores nothing. Returns data size, or -1 if memory is exhausted. static int s_config_printf (zconfig_t *self, void *arg, char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (!string) return -1; if (arg) { if (zchunk_is (arg)) zchunk_append ((zchunk_t *) arg, string, strlen (string)); else fprintf ((FILE *) arg, "%s", string); } size_t size = strlen (string); free (string); if (size > INT_MAX) return -1; return (int) size; } static int s_config_save (zconfig_t *self, void *arg, int level) { assert (self); // Store any comments on the item int size = 0; if (self->comments) { char *comment = (char *) zlist_first (self->comments); while (comment) { size += s_config_printf (self, arg, "#%s\n", comment); comment = (char *) zlist_next (self->comments); } size += s_config_printf (self, arg, "\n"); } if (level > 0) { if (self->value) size += s_config_printf (self, arg, "%*s%s = \"%s\"\n", (level - 1) * 4, "", self->name? self->name: "(Unnamed)", self->value); else size += s_config_printf (self, arg, "%*s%s\n", (level - 1) * 4, "", self->name? self->name: "(Unnamed)"); } return size; } // -------------------------------------------------------------------------- // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. zconfig_t * zconfig_loadf (const char *format, ...) { va_list argptr; va_start (argptr, format); char *filename = zsys_vprintf (format, argptr); va_end (argptr); if (filename) { zconfig_t *config = zconfig_load (filename); free (filename); return config; } else return NULL; } // -------------------------------------------------------------------------- // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int zconfig_savef (zconfig_t *self, const char *format, ...) { assert (self); va_list argptr; va_start (argptr, format); char *filename = zsys_vprintf (format, argptr); va_end (argptr); if (filename) { int rc = zconfig_save (self, filename); free (filename); return rc; } else return -1; } // -------------------------------------------------------------------------- // Report filename used during zconfig_load, or NULL if none const char * zconfig_filename (zconfig_t *self) { assert (self); if (self->file) return (zfile_filename (self->file, NULL)); else return NULL; } // -------------------------------------------------------------------------- // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int zconfig_reload (zconfig_t **self_p) { assert (self_p); zconfig_t *self = *self_p; if (self->file) { zconfig_t *copy = zconfig_load (zfile_filename (self->file, NULL)); if (copy) { // Destroy old tree and install new one zconfig_destroy (self_p); *self_p = copy; return 0; } } return -1; // Not successful } // -------------------------------------------------------------------------- // Load a config tree from a memory chunk zconfig_t * zconfig_chunk_load (zchunk_t *chunk) { // Parse the chunk line by line zconfig_t *self = zconfig_new ("root", NULL); if (!self) return NULL; bool valid = true; int lineno = 0; char *data_ptr = (char *) zchunk_data (chunk); size_t remaining = zchunk_size (chunk); while (remaining) { // Copy stuff into cur_line; not fastest but safest option // since chunk may not be null terminated, etc. char *eoln = (char *) memchr (data_ptr, '\n', remaining); size_t cur_size; if (eoln) cur_size = eoln - data_ptr; else cur_size = remaining; if (cur_size > 1024) cur_size = 1024; char cur_line [1024 + 1]; memcpy (cur_line, data_ptr, cur_size); cur_line [cur_size] = '\0'; data_ptr = eoln? eoln + 1: NULL; remaining -= cur_size + (eoln? 1: 0); // Trim line size_t length = strlen (cur_line); while (length && isspace ((byte) cur_line [length - 1])) cur_line [--length] = 0; // Collect indentation level and name, if any lineno++; // Handle whole-line comment if present if (cur_line [0] == '#') { if (!self->comments) { self->comments = zlist_new (); assert (self->comments); zlist_autofree (self->comments); } zlist_append (self->comments, cur_line + 1); } char *scanner = cur_line; int level = s_collect_level (&scanner, lineno); if (level == -1) { valid = false; break; } char *name = s_collect_name (&scanner, lineno); if (name == NULL) { valid = false; break; } // If name is not empty, collect property value if (*name) { char *value = s_collect_value (&scanner, lineno); if (value == NULL) valid = false; else { // Navigate to parent for this element zconfig_t *parent = zconfig_at_depth (self, level); if (parent) { zconfig_t *item = zconfig_new (name, parent); assert (item); item->value = value; } else { zclock_log ("E (zconfig): (%d) indentation error", lineno); free (value); valid = false; } } } else if (s_verify_eoln (scanner, lineno)) valid = false; free (name); if (!valid) break; } // Either the whole ZPL stream is valid or none of it is if (!valid) zconfig_destroy (&self); return self; } // Count and verify indentation level, -1 means a syntax error or overflow static int s_collect_level (char **start, int lineno) { char *readptr = *start; while (*readptr == ' ') readptr++; ptrdiff_t level = (readptr - *start) / 4; if (level * 4 != readptr - *start) { zclock_log ("E (zconfig): (%d) indent 4 spaces at once", lineno); level = -1; } *start = readptr; if (level > INT_MAX) return -1; return (int) level; } // Collect property name static bool s_is_namechar (char thischar) { return ( isalnum (thischar) || thischar == '$' || thischar == '-' || thischar == '_' || thischar == '@' || thischar == '.' || thischar == '&' || thischar == '+' || thischar == '/'); } static char * s_collect_name (char **start, int lineno) { char *readptr = *start; while (s_is_namechar ((char) **start)) (*start)++; size_t length = *start - readptr; char *name = (char *) zmalloc (length + 1); if (!name) return NULL; memcpy (name, readptr, length); name [length] = 0; if (length > 0 && (name [0] == '/' || name [length - 1] == '/')) { zclock_log ("E (zconfig): (%d) '/' not valid at name start or end", lineno); free (name); name = NULL; } return name; } // Check there's no junk after value on line, returns 0 if OK else -1. static int s_verify_eoln (char *readptr, int lineno) { while (*readptr) { if (isspace ((byte) *readptr)) readptr++; else if (*readptr == '#') break; else { zclock_log ("E (zconfig): (%d) invalid syntax '%s'", lineno, readptr); return -1; break; } } return 0; } // Return value for name, or "" - if syntax error, returns NULL. static char * s_collect_value (char **start, int lineno) { char *value = NULL; char *readptr = *start; int rc = 0; while (isspace ((byte) *readptr)) readptr++; if (*readptr == '=') { readptr++; while (isspace ((byte) *readptr)) readptr++; // If value starts with quote or apost, collect it if (*readptr == '"' || *readptr == '\'') { char *endquote = strchr (readptr + 1, *readptr); if (endquote) { size_t value_length = endquote - readptr - 1; value = (char *) zmalloc (value_length + 1); if (!value) return NULL; memcpy (value, readptr + 1, value_length); value [value_length] = 0; rc = s_verify_eoln (endquote + 1, lineno); } else { zclock_log ("E (zconfig): (%d) missing %c", lineno, *readptr); rc = -1; } } else { // Collect unquoted value up to comment char *comment = strchr (readptr, '#'); if (comment) { while (isspace ((byte) comment [-1])) comment--; *comment = 0; } value = strdup (readptr); } } else { value = strdup (""); rc = s_verify_eoln (readptr, lineno); } // If we had an error, drop value and return NULL if (rc) { free (value); value = NULL; } return value; } // -------------------------------------------------------------------------- // Save a config tree to a new memory chunk; the chunk zchunk_t * zconfig_chunk_save (zconfig_t *self) { assert (self); int size = s_config_execute (self, s_config_save, NULL, 0); // Allow an extra byte so we can null-terminate the data zchunk_t *chunk = zchunk_new (NULL, size + 1); if (chunk) { s_config_execute (self, s_config_save, chunk, 0); // This lets us treat the chunk data as a string zchunk_data (chunk) [zchunk_size (chunk)] = 0; } return chunk; } // -------------------------------------------------------------------------- // Create a new config tree from a null-terminated string zconfig_t * zconfig_str_load (const char *string) { zchunk_t *chunk = zchunk_new (string, strlen (string)); zconfig_t *config = zconfig_chunk_load (chunk); zchunk_destroy (&chunk); return config; } // -------------------------------------------------------------------------- // Save a config tree to a new null terminated string char * zconfig_str_save (zconfig_t *self) { zchunk_t *chunk = zconfig_chunk_save (self); char *string = strdup ((char *) zchunk_data (chunk)); zchunk_destroy (&chunk); return string; } // -------------------------------------------------------------------------- // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool zconfig_has_changed (zconfig_t *self) { assert (self); if (self->file && zfile_has_changed (self->file)) return true; else return false; } // -------------------------------------------------------------------------- // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void zconfig_set_comment (zconfig_t *self, const char *format, ...) { if (format) { if (!self->comments) { self->comments = zlist_new (); assert (self->comments); zlist_autofree (self->comments); } va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zlist_append (self->comments, string); free (string); } else zlist_destroy (&self->comments); } // -------------------------------------------------------------------------- // Return comments of config item, as zlist. zlist_t * zconfig_comments (zconfig_t *self) { assert (self); return self->comments; } // -------------------------------------------------------------------------- // Print the config file to open stream void zconfig_fprint (zconfig_t *self, FILE *file) { zconfig_execute (self, s_config_save, file); } // -------------------------------------------------------------------------- // Print the config file to stdout void zconfig_print (zconfig_t *self) { zconfig_fprint (self, stdout); } // -------------------------------------------------------------------------- // Self test of this class void zconfig_test (bool verbose) { printf (" * zconfig: "); // @selftest // Create temporary directory for test files # define TESTDIR ".test_zconfig" zsys_dir_create (TESTDIR); zconfig_t *root = zconfig_new ("root", NULL); assert (root); zconfig_t *section, *item; section = zconfig_new ("headers", root); assert (section); item = zconfig_new ("email", section); assert (item); zconfig_set_value (item, "some@random.com"); item = zconfig_new ("name", section); assert (item); zconfig_set_value (item, "Justin Kayce"); zconfig_putf (root, "/curve/secret-key", "%s", "Top Secret"); zconfig_set_comment (root, " CURVE certificate"); zconfig_set_comment (root, " -----------------"); assert (zconfig_comments (root)); zconfig_save (root, TESTDIR "/test.cfg"); zconfig_destroy (&root); root = zconfig_load (TESTDIR "/test.cfg"); if (verbose) zconfig_save (root, "-"); assert (streq (zconfig_filename (root), TESTDIR "/test.cfg")); char *email = zconfig_get (root, "/headers/email", NULL); assert (email); assert (streq (email, "some@random.com")); char *passwd = zconfig_get (root, "/curve/secret-key", NULL); assert (passwd); assert (streq (passwd, "Top Secret")); zconfig_savef (root, "%s/%s", TESTDIR, "test.cfg"); assert (!zconfig_has_changed (root)); int rc = zconfig_reload (&root); assert (rc == 0); assert (!zconfig_has_changed (root)); zconfig_destroy (&root); // Test chunk load/save root = zconfig_new ("root", NULL); assert (root); section = zconfig_new ("section", root); assert (section); item = zconfig_new ("value", section); assert (item); zconfig_set_value (item, "somevalue"); zconfig_t *search = zconfig_locate (root, "section/value"); assert (search == item); zchunk_t *chunk = zconfig_chunk_save (root); assert (strlen ((char *) zchunk_data (chunk)) == 32); char *string = zconfig_str_save (root); assert (string); assert (streq (string, (char *) zchunk_data (chunk))); free (string); assert (chunk); zconfig_destroy (&root); root = zconfig_chunk_load (chunk); assert (root); char *value = zconfig_get (root, "/section/value", NULL); assert (value); assert (streq (value, "somevalue")); // Test config can't be saved to a file in a path that doesn't // exist or isn't writable rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", TESTDIR, "test.cfg"); assert (rc == -1); zconfig_destroy (&root); zchunk_destroy (&chunk); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); // @end printf ("OK\n"); } czmq-3.0.2/src/zthread.c0000664000175000017500000002062312505070716014172 0ustar00phph00000000000000/* ========================================================================= zthread - working with system threads (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zthread class wraps OS thread creation. It creates detached threads that look like normal OS threads, or attached threads that share the caller's 0MQ context, and get an inproc pipe to talk back to the parent thread. Detached threads create their own 0MQ contexts as needed. NOTE: this class is deprecated in favor of zactor. @discuss We have several use cases for multiple threads. One is to simulate many processes, so we can test 0MQ designs and flows more easily. Another is to create APIs that can send and receive 0MQ messages in the background. zthread solves these two use cases separately, using the zthread_new and zthead_fork methods respectively. These methods wrap the native system calls needed to start threads, so your code can remain fully portable. Detached threads follow the POSIX pthreads API; they accept a void * argument and return a void * result (always NULL in our case). Attached thread receive a void * argument, a zctx_t context, and a pipe socket. The pipe socket is a PAIR socket that is connected back to the caller. When you call zthread_fork, it returns you a PAIR socket that is the other end of this pipe. Thus attached threads can talk back to their parent threads over the pipe. We use this very heavily when making so-called "asynchronous" APIs, which you can see in the Guide examples like 'clone'. To recap some rules about threading: do not share sockets between threads or your code will crash. You can migrate a socket from one thread to a child thread, if you stop using it in the parent thread immediately after creating the child thread. If you want to connect sockets over inproc:// they must share the same 0MQ context, i.e. be attached threads. You should always use zthread_fork to create an attached thread; it is not sufficient to pass a zctx_t structure to a detached thread (this will crash). If you want to communicate over ipc:// or tcp:// you may be sharing the same context, or use separate contexts. Thus, every detached thread usually starts by creating its own zctx_t instance. @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // Thread creation code, wrapping POSIX and Win32 thread APIs typedef struct { // Two thread handlers, one will be set, one NULL zthread_attached_fn *attached; zthread_detached_fn *detached; void *args; // Application arguments zctx_t *ctx; // Context object if any void *pipe; // Pipe, if any, back to parent #if defined (__WINDOWS__) HANDLE handle; // Win32 thread handle #endif } shim_t; #if defined (__UNIX__) // Thread shim for UNIX calls the real thread and cleans up afterwards. static void * s_thread_shim (void *args) { assert (args); shim_t *shim = (shim_t *) args; if (shim->attached) shim->attached (shim->args, shim->ctx, shim->pipe); else shim->detached (shim->args); zctx_destroy (&shim->ctx); free (shim); return NULL; } #elif defined (__WINDOWS__) // Thread shim for Windows that wraps a POSIX-style thread handler // and does the _endthreadex for us automatically. static unsigned __stdcall s_thread_shim (void *args) { assert (args); shim_t *shim = (shim_t *) args; if (shim->attached) shim->attached (shim->args, shim->ctx, shim->pipe); else shim->detached (shim->args); zctx_destroy (&shim->ctx); // Close any dangling sockets free (shim); _endthreadex (0); // Terminates thread return 0; } #endif static void s_thread_start (shim_t *shim) { #if defined (__UNIX__) pthread_t thread; pthread_create (&thread, NULL, s_thread_shim, shim); pthread_detach (thread); #elif defined (__WINDOWS__) shim->handle = (HANDLE) _beginthreadex ( NULL, // Handle is private to this process 0, // Use a default stack size for new thread &s_thread_shim, // Start real thread function via this shim shim, // Which gets the current object as argument CREATE_SUSPENDED, // Set thread priority before starting it NULL); // We don't use the thread ID assert (shim->handle); // Set child thread priority to same as current int priority = GetThreadPriority (GetCurrentThread ()); SetThreadPriority (shim->handle, priority); // Start thread ResumeThread (shim->handle); // Release resources CloseHandle (shim->handle); shim->handle = 0; #endif } // -------------------------------------------------------------------------- // Create a detached thread. A detached thread operates autonomously // and is used to simulate a separate process. It gets no ctx, and no // pipe. Returns 0 on success, -1 if insufficient memory. int zthread_new (zthread_detached_fn *thread_fn, void *args) { // Prepare argument shim for child thread shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t)); if (shim) { shim->detached = thread_fn; shim->args = args; s_thread_start (shim); return 0; } return -1; } // -------------------------------------------------------------------------- // Create an attached thread. An attached thread gets a ctx and a PAIR // pipe back to its parent. It must monitor its pipe, and exit if the // pipe becomes unreadable. Returns pipe, or NULL if there was an error. void * zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args) { shim_t *shim = NULL; // Create our end of the pipe void *pipe = zctx__socket_pipe (ctx); if (pipe) zsocket_bind (pipe, "inproc://zctx-pipe-%p", pipe); else return NULL; // Prepare argument shim for child thread shim = (shim_t *) zmalloc (sizeof (shim_t)); if (shim) { shim->attached = thread_fn; shim->args = args; shim->ctx = zctx_shadow (ctx); if (!shim->ctx) { zctx__socket_destroy (ctx, pipe); return NULL; } } else return NULL; // Connect child pipe to our pipe shim->pipe = zctx__socket_pipe (shim->ctx); if (!shim->pipe) { zctx__socket_destroy (ctx, pipe); return NULL; } zsocket_connect (shim->pipe, "inproc://zctx-pipe-%p", pipe); s_thread_start (shim); return pipe; } // -------------------------------------------------------------------------- // Selftest // @selftest static void * s_test_detached (void *args) { // Create a socket to check it'll be automatically deleted zctx_t *ctx = zctx_new (); assert (ctx); void *push = zsocket_new (ctx, ZMQ_PUSH); assert (push); zctx_destroy (&ctx); return NULL; } static void s_test_attached (void *args, zctx_t *ctx, void *pipe) { // Create a socket to check it'll be automatically deleted zsocket_new (ctx, ZMQ_PUSH); assert (ctx); // Wait for our parent to ping us, and pong back char *ping = zstr_recv (pipe); assert (ping); zstr_free (&ping); zstr_send (pipe, "pong"); } // @end void zthread_test (bool verbose) { printf (" * zthread (deprecated): "); // @selftest zctx_t *ctx = zctx_new (); assert (ctx); int rc = 0; // Create a detached thread, let it run rc = zthread_new (s_test_detached, NULL); assert (rc == 0); zclock_sleep (100); // Create an attached thread, check it's safely alive void *pipe = zthread_fork (ctx, s_test_attached, NULL); assert (pipe); zstr_send (pipe, "ping"); char *pong = zstr_recv (pipe); assert (pong); assert (streq (pong, "pong")); zstr_free (&pong); // Everything should be cleanly closed now zctx_destroy (&ctx); // @end printf ("OK\n"); } czmq-3.0.2/src/zauth_v2.c0000664000175000017500000006105312505070716014275 0ustar00phph00000000000000/* ========================================================================= zauth_v2 - authentication for ZeroMQ servers (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header A zauth object takes over authentication for all incoming connections in its context. @discuss This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets. @end */ #include "../include/czmq.h" #define ZAP_ENDPOINT "inproc://zeromq.zap.01" // Structure of our class // All work is done by a background thread, the "agent", which we talk // to over a pipe (created by zthread_fork). This lets the agent do work // asynchronously in the background while our application does other // things. This is invisible to the caller, who sees a classic API. struct _zauth_t { void *pipe; // Pipe through to background agent }; // The background agent task does all the real work static void s_agent_task (void *args, zctx_t *ctx, void *pipe); // -------------------------------------------------------------------------- // Constructor // // Install authentication for the specified context. Returns a new zauth // object that you can use to configure authentication. Note that until you // add policies, all incoming NULL connections are allowed (classic ZeroMQ // behavior), and all PLAIN and CURVE connections are denied. If there was // an error during initialization, returns NULL. zauth_t * zauth_new (zctx_t *ctx) { zauth_t *self = (zauth_t *) zmalloc (sizeof (zauth_t)); if (!self) return NULL; // Start background agent and wait for it to initialize assert (ctx); self->pipe = zthread_fork (ctx, s_agent_task, NULL); if (self->pipe) { char *status = zstr_recv (self->pipe); if (strneq (status, "OK")) zauth_destroy (&self); zstr_free (&status); } else { zauth_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Destructor void zauth_destroy (zauth_t **self_p) { assert (self_p); if (*self_p) { zauth_t *self = *self_p; zstr_send (self->pipe, "TERMINATE"); char *reply = zstr_recv (self->pipe); zstr_free (&reply); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Allow (whitelist) a single IP address. For NULL, all clients from this // address will be accepted. For PLAIN and CURVE, they will be allowed to // continue with authentication. You can call this method multiple times // to whitelist multiple IP addresses. If you whitelist a single address, // any non-whitelisted addresses are treated as blacklisted. void zauth_allow (zauth_t *self, const char *address) { zstr_sendx (self->pipe, "ALLOW", address, NULL); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Deny (blacklist) a single IP address. For all security mechanisms, this // rejects the connection without any further authentication. Use either a // whitelist, or a blacklist, not not both. If you define both a whitelist // and a blacklist, only the whitelist takes effect. void zauth_deny (zauth_t *self, const char *address) { zstr_sendx (self->pipe, "DENY", address, NULL); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Configure PLAIN authentication for a given domain. PLAIN authentication // uses a plain-text password file. To cover all domains, use "*". You can // modify the password file at any time; it is reloaded automatically. void zauth_configure_plain (zauth_t *self, const char *domain, const char *filename) { assert (self); assert (domain); assert (filename); zstr_sendx (self->pipe, "PLAIN", domain, filename, NULL); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Configure CURVE authentication for a given domain. CURVE authentication // uses a directory that holds all public client certificates, i.e. their // public keys. The certificates must be in zcert_save () format. To cover // all domains, use "*". You can add and remove certificates in that // directory at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the location. void zauth_configure_curve (zauth_t *self, const char *domain, const char *location) { assert (self); assert (domain); assert (location); zstr_sendx (self->pipe, "CURVE", domain, location, NULL); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Configure GSSAPI authentication for a given domain. GSSAPI authentication // uses an underlying mechanism (usually Kerberos) to establish a secure // context and perform mutual authentication. To cover all domains, use "*". void zauth_configure_gssapi (zauth_t *self, char *domain) { assert (self); assert (domain); zstr_sendx (self->pipe, "GSSAPI", domain, NULL); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Enable verbose tracing of commands and activity void zauth_set_verbose (zauth_t *self, bool verbose) { assert (self); zstr_sendm (self->pipe, "VERBOSE"); zstr_sendf (self->pipe, "%d", verbose); zsocket_wait (self->pipe); } // ************************* ZAP REQUESTS ************************* // A small class for working with ZAP requests and replies // This isn't exported in the CZMQ API just used internally in zauth // to simplify working with RFC 27 requests and replies. // Structure of a ZAP request typedef struct { void *handler; // Socket we're talking to char *version; // Version number, must be "1.0" char *sequence; // Sequence number of request char *domain; // Server socket domain char *address; // Client IP address char *identity; // Server socket idenntity char *mechanism; // Security mechansim char *username; // PLAIN user name char *password; // PLAIN password, in clear text char *client_key; // CURVE client public key in ASCII char *principal; // GSSAPI client principal } zap_request_t; static void zap_request_destroy (zap_request_t **self_p) { assert (self_p); if (*self_p) { zap_request_t *self = *self_p; free (self->version); free (self->sequence); free (self->domain); free (self->address); free (self->identity); free (self->mechanism); free (self->username); free (self->password); free (self->client_key); free (self->principal); free (self); *self_p = NULL; } } // Receive a valid ZAP request from the handler socket // If the request was not valid, returns NULL. static zap_request_t * zap_request_new (void *handler) { #if (ZMQ_VERSION_MAJOR == 4) zap_request_t *self = (zap_request_t *) zmalloc (sizeof (zap_request_t)); if (!self) return NULL; // Store handler socket so we can send a reply easily self->handler = handler; zmsg_t *request = zmsg_recv (handler); if (!request) { zap_request_destroy (&self); return NULL; } // Get all standard frames off the handler socket self->version = zmsg_popstr (request); self->sequence = zmsg_popstr (request); self->domain = zmsg_popstr (request); self->address = zmsg_popstr (request); self->identity = zmsg_popstr (request); self->mechanism = zmsg_popstr (request); // If the version is wrong, we're linked with a bogus libzmq, so die assert (streq (self->version, "1.0")); // Get mechanism-specific frames if (streq (self->mechanism, "PLAIN")) { self->username = zmsg_popstr (request); self->password = zmsg_popstr (request); } else if (streq (self->mechanism, "CURVE")) { zframe_t *frame = zmsg_pop (request); assert (zframe_size (frame) == 32); self->client_key = (char *) zmalloc (41); zmq_z85_encode (self->client_key, zframe_data (frame), 32); zframe_destroy (&frame); } else if (streq (self->mechanism, "GSSAPI")) self->principal = zmsg_popstr (request); zmsg_destroy (&request); return self; #else return NULL; #endif } // Send a ZAP reply to the handler socket static int zap_request_reply (zap_request_t *self, char *status_code, char *status_text) { zstr_sendx (self->handler, "1.0", self->sequence, status_code, status_text, "", "", NULL); return 0; } // ************************* BACK END AGENT ************************* // This structure holds the context for our agent, so we can // pass that around cleanly to methods which need it typedef struct { zctx_t *ctx; // CZMQ context we're working for void *pipe; // Pipe back to application API void *handler; // ZAP handler socket bool verbose; // Trace activity to stdout zhash_t *whitelist; // Whitelisted addresses zhash_t *blacklist; // Blacklisted addresses zhash_t *passwords; // PLAIN passwords, if loaded zcertstore_t *certstore; // CURVE certificate store, if loaded bool allow_any; // CURVE allows arbitrary clients bool terminated; // Did API ask us to quit? } agent_t; static void s_agent_destroy (agent_t **self_p) { assert (self_p); if (*self_p) { agent_t *self = *self_p; zhash_destroy (&self->passwords); zhash_destroy (&self->whitelist); zhash_destroy (&self->blacklist); zcertstore_destroy (&self->certstore); zsocket_unbind (self->handler, ZAP_ENDPOINT); zsocket_destroy (self->ctx, self->handler); free (self); *self_p = NULL; } } static agent_t * s_agent_new (zctx_t *ctx, void *pipe) { agent_t *self = (agent_t *) zmalloc (sizeof (agent_t)); if (!self) return NULL; self->ctx = ctx; self->pipe = pipe; self->whitelist = zhash_new (); if (self->whitelist) self->blacklist = zhash_new (); // Create ZAP handler and get ready for requests if (self->blacklist) self->handler = zsocket_new (self->ctx, ZMQ_REP); if (self->handler) { if (zsocket_bind (self->handler, ZAP_ENDPOINT) == 0) zstr_send (self->pipe, "OK"); else zstr_send (self->pipe, "ERROR"); } else s_agent_destroy (&self); return self; } // Handle a message from front-end API static int s_agent_handle_pipe (agent_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (!command) { zmsg_destroy (&request); return -1; // Interrupted } if (streq (command, "ALLOW")) { char *address = zmsg_popstr (request); zhash_insert (self->whitelist, address, "OK"); zstr_free (&address); zsocket_signal (self->pipe); } else if (streq (command, "DENY")) { char *address = zmsg_popstr (request); zhash_insert (self->blacklist, address, "OK"); zstr_free (&address); zsocket_signal (self->pipe); } else if (streq (command, "PLAIN")) { // For now we don't do anything with domains char *domain = zmsg_popstr (request); zstr_free (&domain); // Get password file and load into zhash table // If the file doesn't exist we'll get an empty table char *filename = zmsg_popstr (request); zhash_destroy (&self->passwords); self->passwords = zhash_new (); zhash_load (self->passwords, filename); zstr_free (&filename); zsocket_signal (self->pipe); } else if (streq (command, "CURVE")) { char *domain = zmsg_popstr (request); // For now we don't do anything with domains zstr_free (&domain); // If location is CURVE_ALLOW_ANY, allow all clients. Otherwise // treat location as a directory that holds the certificates. char *location = zmsg_popstr (request); if (streq (location, CURVE_ALLOW_ANY)) self->allow_any = true; else { zcertstore_destroy (&self->certstore); self->certstore = zcertstore_new (location); self->allow_any = false; } zstr_free (&location); zsocket_signal (self->pipe); } else if (streq (command, "GSSAPI")) { char *domain = zmsg_popstr (request); // For now we don't do anything with domains zstr_free (&domain); zsocket_signal (self->pipe); } else if (streq (command, "VERBOSE")) { char *verbose = zmsg_popstr (request); self->verbose = *verbose == '1'; zstr_free (&verbose); zsocket_signal (self->pipe); } else if (streq (command, "TERMINATE")) { self->terminated = true; zsocket_signal (self->pipe); } else { zsys_error ("invalid command from API: %s\n", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // Handle an authentication request from libzmq core static bool s_authenticate_plain (agent_t *self, zap_request_t *request); static bool s_authenticate_curve (agent_t *self, zap_request_t *request); static bool s_authenticate_gssapi (agent_t *self, zap_request_t *request); static int s_agent_authenticate (agent_t *self) { zap_request_t *request = zap_request_new (self->handler); if (request) { // Is address explicitly whitelisted or blacklisted? bool allowed = false; bool denied = false; if (zhash_size (self->whitelist)) { if (zhash_lookup (self->whitelist, request->address)) { allowed = true; if (self->verbose) printf ("ZAUTH I: PASSED (whitelist) address=%s\n", request->address); } else { denied = true; if (self->verbose) printf ("ZAUTH I: DENIED (not in whitelist) address=%s\n", request->address); } } else if (zhash_size (self->blacklist)) { if (zhash_lookup (self->blacklist, request->address)) { denied = true; if (self->verbose) printf ("ZAUTH I: DENIED (blacklist) address=%s\n", request->address); } else { allowed = true; if (self->verbose) printf ("ZAUTH I: PASSED (not in blacklist) address=%s\n", request->address); } } // Mechanism-specific checks if (!denied) { if (streq (request->mechanism, "NULL") && !allowed) { // For NULL, we allow if the address wasn't blacklisted if (self->verbose) printf ("ZAUTH I: ALLOWED (NULL)\n"); allowed = true; } else if (streq (request->mechanism, "PLAIN")) // For PLAIN, even a whitelisted address must authenticate allowed = s_authenticate_plain (self, request); else if (streq (request->mechanism, "CURVE")) // For CURVE, even a whitelisted address must authenticate allowed = s_authenticate_curve (self, request); else if (streq (request->mechanism, "GSSAPI")) // For GSSAPI, even a whitelisted address must authenticate allowed = s_authenticate_gssapi (self, request); } if (allowed) zap_request_reply (request, "200", "OK"); else zap_request_reply (request, "400", "NO ACCESS"); zap_request_destroy (&request); } else zap_request_reply (request, "500", "Internal error"); return 0; } static bool s_authenticate_plain (agent_t *self, zap_request_t *request) { if (self->passwords) { zhash_refresh (self->passwords); char *password = (char *) zhash_lookup (self->passwords, request->username); if (password && streq (password, request->password)) { if (self->verbose) printf ("ZAUTH I: ALLOWED (PLAIN) username=%s password=%s\n", request->username, request->password); return true; } else { if (self->verbose) printf ("ZAUTH I: DENIED (PLAIN) username=%s password=%s\n", request->username, request->password); return false; } } else { if (self->verbose) printf ("ZAUTH I: DENIED (PLAIN) no password file defined\n"); return false; } } static bool s_authenticate_curve (agent_t *self, zap_request_t *request) { // TODO: load metadata from certificate and return via ZAP response if (self->allow_any) { if (self->verbose) printf ("ZAUTH I: ALLOWED (CURVE allow any client)\n"); return true; } else if (self->certstore && zcertstore_lookup (self->certstore, request->client_key)) { if (self->verbose) printf ("ZAUTH I: ALLOWED (CURVE) client_key=%s\n", request->client_key); return true; } else { if (self->verbose) printf ("ZAUTH I: DENIED (CURVE) client_key=%s\n", request->client_key); return false; } } static bool s_authenticate_gssapi (agent_t *self, zap_request_t *request) { if (self->verbose) printf ("I: ALLOWED (GSSAPI) principal=%s identity=%s\n", request->principal, request->identity); return true; } // Handle a message from front-end API static void s_agent_task (void *args, zctx_t *ctx, void *pipe) { // Create agent instance as we start this task agent_t *self = s_agent_new (ctx, pipe); if (!self) // Interrupted return; zpoller_t *poller = zpoller_new (self->pipe, self->handler, NULL); if (poller) while (!zpoller_terminated (poller) && !self->terminated) { void *which = zpoller_wait (poller, -1); if (which == self->pipe) s_agent_handle_pipe (self); else if (which == self->handler) s_agent_authenticate (self); } // Done, free all agent resources zpoller_destroy (&poller); s_agent_destroy (&self); } // -------------------------------------------------------------------------- // Selftest #if (ZMQ_VERSION_MAJOR == 4) // Checks whether client can connect to server static bool s_can_connect (zctx_t *ctx, void **server, void **client) { int port_nbr = zsocket_bind (*server, "tcp://127.0.0.1:*"); assert (port_nbr > 0); int rc = zsocket_connect (*client, "tcp://127.0.0.1:%d", port_nbr); assert (rc == 0); zstr_send (*server, "Hello, World"); zpoller_t *poller = zpoller_new (*client, NULL); bool success = (zpoller_wait (poller, 200) == *client); zpoller_destroy (&poller); zsocket_destroy (ctx, *client); zsocket_destroy (ctx, *server); *server = zsocket_new (ctx, ZMQ_PUSH); assert (*server); *client = zsocket_new (ctx, ZMQ_PULL); assert (*client); return success; } #endif // -------------------------------------------------------------------------- // Selftest void zauth_v2_test (bool verbose) { printf (" * zauth (deprecated): "); #if (ZMQ_VERSION_MAJOR == 4) if (verbose) printf ("\n"); // @selftest // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Install the authenticator zctx_t *ctx = zctx_new (); assert (ctx); zauth_t *auth = zauth_new (ctx); assert (auth); zauth_set_verbose (auth, verbose); // A default NULL connection should always success, and not // go through our authentication infrastructure at all. void *server = zsocket_new (ctx, ZMQ_PUSH); assert (server); void *client = zsocket_new (ctx, ZMQ_PULL); assert (client); bool success = s_can_connect (ctx, &server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsocket_set_zap_domain (server, "global"); success = s_can_connect (ctx, &server, &client); assert (success); // Blacklist 127.0.0.1, connection should fail zsocket_set_zap_domain (server, "global"); zauth_deny (auth, "127.0.0.1"); success = s_can_connect (ctx, &server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsocket_set_zap_domain (server, "global"); zauth_allow (auth, "127.0.0.1"); success = s_can_connect (ctx, &server, &client); assert (success); // Try PLAIN authentication zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); success = s_can_connect (ctx, &server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); zauth_configure_plain (auth, "*", TESTDIR "/password-file"); success = s_can_connect (ctx, &server, &client); assert (success); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Bogus"); success = s_can_connect (ctx, &server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); success = s_can_connect (ctx, &server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zauth_configure_curve (auth, "*", CURVE_ALLOW_ANY); success = s_can_connect (ctx, &server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zauth_configure_curve (auth, "*", TESTDIR); success = s_can_connect (ctx, &server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zauth_destroy (&auth); success = s_can_connect (ctx, &server, &client); assert (success); zctx_destroy (&ctx); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); // @end #endif printf ("OK\n"); } czmq-3.0.2/src/zcertstore.c0000664000175000017500000002114312505070716014733 0ustar00phph00000000000000/* ========================================================================= zcertstore - work with CURVE security certificate stores Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client's public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. The zcert class does the work of managing a single certificate. @discuss The certificate store can be memory-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically. In most applications you won't use this class directly but through the zauth class, which provides a high-level API for authentication (and manages certificate stores for you). To actually create certificates on disk, use the zcert class in code, or the tools/makecert.c command line tool, or any text editor. The format of a certificate file is defined in the zcert man page. @end */ #include "../include/czmq.h" // Structure of our class struct _zcertstore_t { char *location; // Directory location // This isn't sufficient; we should check the hash of all files // or else use a trigger like inotify on Linux. time_t modified; // Modified time of directory size_t count; // Number of certificates size_t cursize; // Total size of certificates zhashx_t *certs; // Loaded certificates }; // -------------------------------------------------------------------------- // Constructor // // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. static void s_load_certs_from_disk (zcertstore_t *self); zcertstore_t * zcertstore_new (const char *location) { zcertstore_t *self = (zcertstore_t *) zmalloc (sizeof (zcertstore_t)); if (!self) return NULL; self->certs = zhashx_new (); if (self->certs) { zhashx_set_destructor (self->certs, (czmq_destructor *) zcert_destroy); if (location) { self->location = strdup (location); if (!self->location) { zcertstore_destroy (&self); return NULL; } s_load_certs_from_disk (self); } } else zcertstore_destroy (&self); return self; } // Load certificates from directory location, if it exists static void s_load_certs_from_disk (zcertstore_t *self) { zhashx_purge (self->certs); zdir_t *dir = zdir_new (self->location, NULL); if (dir) { // Load all certificates including those in subdirectories zfile_t **filelist = zdir_flatten (dir); assert (filelist); zrex_t *rex = zrex_new ("_secret$"); assert (rex); uint index; for (index = 0;; index++) { zfile_t *file = filelist [index]; if (!file) break; // End of list if (zfile_is_regular (file) && !zrex_matches (rex, zfile_filename (file, NULL))) { zcert_t *cert = zcert_load (zfile_filename (file, NULL)); if (cert) zcertstore_insert (self, &cert); } } zdir_flatten_free (&filelist); self->modified = zdir_modified (dir); self->count = zdir_count (dir); self->cursize = zdir_cursize (dir); zrex_destroy (&rex); zdir_destroy (&dir); } } // -------------------------------------------------------------------------- // Destructor // // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void zcertstore_destroy (zcertstore_t **self_p) { assert (self_p); if (*self_p) { zcertstore_t *self = *self_p; zhashx_destroy (&self->certs); free (self->location); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key) { // If directory has changed, reload all certificates if (self->location) { zdir_t *dir = zdir_new (self->location, NULL); if (dir && (self->modified != zdir_modified (dir) || self->count != zdir_count (dir) || self->cursize != zdir_cursize (dir))) s_load_certs_from_disk (self); zdir_destroy (&dir); } return (zcert_t *) zhashx_lookup (self->certs, public_key); } // -------------------------------------------------------------------------- // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p) { int rc = zhashx_insert (self->certs, zcert_public_txt (*cert_p), *cert_p); assert (rc == 0); *cert_p = NULL; // We own this now } // -------------------------------------------------------------------------- // Print list of certificates in store to stdout void zcertstore_print (zcertstore_t *self) { if (self->location) zsys_info ("zcertstore: certificates at location=%s:", self->location); else zsys_info ("zcertstore: certificates in memory"); zcert_t *cert = (zcert_t *) zhashx_first (self->certs); while (cert) { zcert_print (cert); cert = (zcert_t *) zhashx_next (self->certs); } } // -------------------------------------------------------------------------- // DEPRECATED as incompatible with centralized logging // Print list of certificates in store to open stream void zcertstore_fprint (zcertstore_t *self, FILE *file) { if (self->location) fprintf (file, "Certificate store at %s:\n", self->location); else fprintf (file, "Certificate store\n"); zcert_t *cert = (zcert_t *) zhashx_first (self->certs); while (cert) { zcert_fprint (cert, file); cert = (zcert_t *) zhashx_next (self->certs); } } // -------------------------------------------------------------------------- // Selftest void zcertstore_test (bool verbose) { printf (" * zcertstore: "); if (verbose) printf ("\n"); // @selftest // Create temporary directory for test files # define TESTDIR ".test_zcertstore" zsys_dir_create (TESTDIR); // Load certificate store from disk; it will be empty zcertstore_t *certstore = zcertstore_new (TESTDIR); assert (certstore); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); assert (cert); char *client_key = strdup (zcert_public_txt (cert)); assert (client_key); zcert_set_meta (cert, "name", "John Doe"); zcert_save (cert, TESTDIR "/mycert.txt"); zcert_destroy (&cert); // Check that certificate store refreshes as expected cert = zcertstore_lookup (certstore, client_key); assert (cert); assert (streq (zcert_meta (cert, "name"), "John Doe")); free (client_key); if (verbose) zcertstore_print (certstore); zcertstore_destroy (&certstore); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); // @end printf ("OK\n"); } czmq-3.0.2/src/Makemodule.am0000664000175000017500000001153012535241704014764 0ustar00phph00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ program_libs = \ src/libczmq.la \ ${project_libs} # Programs need to link the c++ runtime if everything was compiled statically. if !ENABLE_SHARED program_libs += -lstdc++ endif lib_LTLIBRARIES += src/libczmq.la pkgconfig_DATA = src/libczmq.pc include_HEADERS = \ include/czmq_prelude.h \ include/czmq.h \ include/zactor.h \ include/zauth.h \ include/zarmour.h \ include/zbeacon.h \ include/zcert.h \ include/zcertstore.h \ include/zchunk.h \ include/zclock.h \ include/zconfig.h \ include/zdigest.h \ include/zdir.h \ include/zdir_patch.h \ include/zfile.h \ include/zframe.h \ include/zgossip.h \ include/zhashx.h \ include/ziflist.h \ include/zlistx.h \ include/zloop.h \ include/zmonitor.h \ include/zmsg.h \ include/zpoller.h \ include/zproxy.h \ include/zrex.h \ include/zsock.h \ include/zsock_option.h \ include/zstr.h \ include/zsys.h \ include/zuuid.h \ include/zauth_v2.h \ include/zbeacon_v2.h \ include/zctx.h \ include/zhash.h \ include/zlist.h \ include/zmonitor_v2.h \ include/zmutex.h \ include/zproxy_v2.h \ include/zsocket.h \ include/zsockopt.h \ include/zthread.h \ include/czmq_library.h src_libczmq_la_SOURCES = \ src/zactor.c \ src/zauth.c \ src/zarmour.c \ src/zbeacon.c \ src/zcert.c \ src/zcertstore.c \ src/zchunk.c \ src/zclock.c \ src/zconfig.c \ src/zdigest.c \ src/zdir.c \ src/zdir_patch.c \ src/zfile.c \ src/zframe.c \ src/zgossip.c \ src/zhashx.c \ src/ziflist.c \ src/zlistx.c \ src/zloop.c \ src/zmonitor.c \ src/zmsg.c \ src/zpoller.c \ src/zproxy.c \ src/zrex.c \ src/zsock.c \ src/zsock_option.c \ src/zstr.c \ src/zsys.c \ src/zuuid.c \ src/zgossip_msg.c \ src/zauth_v2.c \ src/zbeacon_v2.c \ src/zctx.c \ src/zhash.c \ src/zlist.c \ src/zmonitor_v2.c \ src/zmutex.c \ src/zproxy_v2.c \ src/zsocket.c \ src/zsockopt.c \ src/zthread.c \ src/zgossip_engine.inc \ src/zhash_primes.inc \ src/zclass_example.xml \ src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h \ src/foreign/slre/readme.txt \ src/platform.h src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS} src_libczmq_la_LDFLAGS = \ -version-info @LTVER@ \ $(LIBTOOL_EXTRA_LDFLAGS) if ON_MINGW src_libczmq_la_LDFLAGS += \ -no-undefined \ -avoid-version endif if ON_CYGWIN src_libczmq_la_LDFLAGS += \ -no-undefined \ -avoid-version endif src_libczmq_la_LIBADD = ${project_libs} if WITH_MAKECERT bin_PROGRAMS += src/makecert src_makecert_CPPFLAGS = ${AM_CPPFLAGS} src_makecert_LDADD = ${program_libs} src_makecert_SOURCES = src/makecert.c endif if WITH_TEST_ZGOSSIP noinst_PROGRAMS += src/test_zgossip src_test_zgossip_CPPFLAGS = ${AM_CPPFLAGS} src_test_zgossip_LDADD = ${program_libs} src_test_zgossip_SOURCES = src/test_zgossip.c endif check_PROGRAMS += src/czmq_selftest src_czmq_selftest_CPPFLAGS = ${src_libczmq_la_CPPFLAGS} src_czmq_selftest_LDADD = ${program_libs} src_czmq_selftest_SOURCES = src/czmq_selftest.c # define custom target for all products of /src src: src/libczmq.la src/czmq_selftest # Produce generated code from models in the src directory code: cd $(srcdir)/src; gsl -q sockopts.xml cd $(srcdir)/src; gsl -q zgossip.xml cd $(srcdir)/src; gsl -q zgossip_msg.xml check-local: src/czmq_selftest $(LIBTOOL) --mode=execute $(srcdir)/src/czmq_selftest check-verbose: src/czmq_selftest $(LIBTOOL) --mode=execute $(srcdir)/src/czmq_selftest -v # Run the selftest binary under valgrind to check for memory leaks memcheck: src/czmq_selftest $(LIBTOOL) --mode=execute valgrind --tool=memcheck \ --leak-check=full --show-reachable=yes --error-exitcode=1 \ --suppressions=$(srcdir)/src/.valgrind.supp \ $(srcdir)/src/czmq_selftest # Run the selftest binary under gdb for debugging debug: src/czmq_selftest $(LIBTOOL) --mode=execute gdb -q \ $(srcdir)/src/czmq_selftest # Run the selftest binary with verbose switch for tracing animate: src/czmq_selftest $(LIBTOOL) --mode=execute $(srcdir)/src/czmq_selftest -v ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/src/zlistx.c0000664000175000017500000005377212527573335014112 0ustar00phph00000000000000/* ========================================================================= zlistx - extended generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Provides a generic doubly-linked list container. This container provides hooks for duplicator, comparator, and destructor functions. These tie into CZMQ and standard C semantics, so e.g. for string items you can use strdup, strcmp, and zstr_free. To store custom objects, define your own duplicator and comparator, and use the standard object destructor. @discuss This is a reworking of the simpler zlist container. It is faster to insert and delete items anywhere in the list, and to keep ordered lists. @end */ #include "../include/czmq.h" #define NODE_TAG 0x0006cafe // List node, used internally only typedef struct _node_t { uint32_t tag; // Object tag for validity checking struct _node_t *next; struct _node_t *prev; void *item; } node_t; // --------------------------------------------------------------------- // Structure of our class struct _zlistx_t { node_t *head; // First item in list, if any node_t *tail; // Last item in list, if any node_t *cursor; // Current cursors for iteration size_t size; // Number of items in list czmq_duplicator *duplicator; // Item duplicator, if any czmq_comparator *comparator; // Item comparator, if any czmq_destructor *destructor; // Item destructor, if any }; // Initialize a list node and attach to the prev and next nodes, or itself // if these are specified as null. Returns new node, or NULL if there was // no more heap memory. static node_t * s_node_new (void *item) { node_t *self = (node_t *) zmalloc (sizeof (node_t)); if (self) { self->tag = NODE_TAG; self->prev = self; self->next = self; self->item = item; } return self; } // Removing and inserting a node are actually the same operation: // swap (node->next, prev->next) // swap (node->prev, next->prev) // Which require only that the node be initialized to point to itself. // When inserting, node goes in between prev and next. static void s_node_relink (node_t *node, node_t *prev, node_t *next) { node_t *temp = node->next; node->next = prev->next; prev->next = temp; temp = node->prev; node->prev = next->prev; next->prev = temp; } // Default comparator static int s_comparator (const void *item1, const void *item2) { if (item1 == item2) return 0; else if (item1 < item2) return -1; else return 1; } // -------------------------------------------------------------------------- // Create a new, empty list. zlistx_t * zlistx_new (void) { zlistx_t *self = (zlistx_t *) zmalloc (sizeof (zlistx_t)); if (self) { self->head = s_node_new (NULL); if (self->head) { self->cursor = self->head; self->comparator = s_comparator; } else zlistx_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void zlistx_destroy (zlistx_t **self_p) { assert (self_p); if (*self_p) { zlistx_t *self = *self_p; zlistx_purge (self); free (self->head); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_start (zlistx_t *self, void *item) { assert (self); assert (item); if (self->duplicator) { item = (self->duplicator)(item); if (!item) return NULL; // Out of memory } node_t *node = s_node_new (item); if (node) { // Insert after head s_node_relink (node, self->head, self->head->next); self->cursor = self->head; self->size++; return node; } else return NULL; // Out of memory } // -------------------------------------------------------------------------- // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_end (zlistx_t *self, void *item) { assert (self); assert (item); if (self->duplicator) { item = (self->duplicator)(item); if (!item) return NULL; // Out of memory } node_t *node = s_node_new (item); if (node) { // Insert before head s_node_relink (node, self->head->prev, self->head); self->cursor = self->head; self->size++; return node; } else return NULL; // Out of memory } // -------------------------------------------------------------------------- // Return the number of items in the list size_t zlistx_size (zlistx_t *self) { assert (self); return self->size; } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlistx_first (zlistx_t *self) { assert (self); self->cursor = self->head->next; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * zlistx_next (zlistx_t *self) { assert (self); self->cursor = self->cursor->next; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * zlistx_prev (zlistx_t *self) { assert (self); self->cursor = self->cursor->prev; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlistx_last (zlistx_t *self) { assert (self); self->cursor = self->head->prev; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_item (zlistx_t *self) { assert (self); return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_cursor (zlistx_t *self) { assert (self); return self->cursor == self->head? NULL: self->cursor; } // -------------------------------------------------------------------------- // Returns the item associated with the given list handle, or NULL if passed // handle is NULL. asserts that the passed in ptr points to a list node. void * zlistx_handle_item (void *handle) { if (!handle) return NULL; node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); return node->item; } // -------------------------------------------------------------------------- // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * zlistx_find (zlistx_t *self, void *item) { assert (self); assert (item); // Scan list for item, this is a O(N) operation node_t *node = self->head->next; while (node != self->head) { if (self->comparator (node->item, item) == 0) { self->cursor = node; return node; } node = node->next; } return NULL; } // -------------------------------------------------------------------------- // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * zlistx_detach (zlistx_t *self, void *handle) { assert (self); node_t *node = (node_t *) handle; if (!node) node = self->head->next == self->head? NULL: self->head->next; // Now detach node from list, without destroying item if (node) { // Reposition cursor so that delete/detach works during iteration if (self->cursor == node) self->cursor = self->cursor->prev; // Remove node from list assert (node->tag == NODE_TAG); s_node_relink (node, node->prev, node->next); node->tag = 0xDeadBeef; void *item = node->item; free (node); self->size--; return item; } else { assert (self->size == 0); return NULL; } } // -------------------------------------------------------------------------- // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * zlistx_detach_cur (zlistx_t *self) { return zlistx_detach (self, zlistx_cursor (self)); } // -------------------------------------------------------------------------- // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int zlistx_delete (zlistx_t *self, void *handle) { assert (self); void *item = zlistx_detach (self, handle); if (item) { if (self->destructor) self->destructor (&item); return 0; } else return -1; } // -------------------------------------------------------------------------- // Move an item to the start of the list, via its handle. void zlistx_move_start (zlistx_t *self, void *handle) { assert (self); assert (handle); node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); node_t *next = self->head->next; if (node != next) { // Remove node from list, insert before next node s_node_relink (node, node->prev, node->next); s_node_relink (node, next->prev, next); } } // -------------------------------------------------------------------------- // Move an item to the end of the list, via its handle. void zlistx_move_end (zlistx_t *self, void *handle) { assert (self); assert (handle); node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); node_t *prev = self->head->prev; if (node != prev) { // Remove node from list, insert after prev node s_node_relink (node, node->prev, node->next); s_node_relink (node, prev, prev->next); } } // -------------------------------------------------------------------------- // Remove all items from the list, and destroy them if the item destructor // is set. void zlistx_purge (zlistx_t *self) { assert (self); while (zlistx_size (self) > 0) zlistx_delete (self, NULL); } // -------------------------------------------------------------------------- // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void zlistx_sort (zlistx_t *self) { // Uses a comb sort, which is simple and reasonably fast // See http://en.wikipedia.org/wiki/Comb_sort assert (self); size_t gap = self->size; bool swapped = false; while (gap > 1 || swapped) { gap = (size_t) ((double) gap / 1.3); node_t *base = self->head->next; node_t *test = self->head->next; size_t jump = gap; while (jump--) test = test->next; swapped = false; while (base != self->head && test != self->head) { if (self->comparator (base->item, test->item) > 0) { // We don't actually swap nodes, just the items in the nodes. // This is ridiculously simple and confuses the heck out of // me every time I re-read the code, as I expect to see the // nodes being swapped. Hence this comment. -- PH 2014/09/06 void *item = base->item; base->item = test->item; test->item = item; swapped = true; } base = base->next; test = test->next; } } } // -------------------------------------------------------------------------- // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * zlistx_insert (zlistx_t *self, void *item, bool low_value) { assert (self); if (self->duplicator) { item = (self->duplicator)(item); if (!item) return NULL; // Out of memory } node_t *node = s_node_new (item); if (node) { zlistx_reorder (self, node, low_value); self->cursor = self->head; self->size++; } return node; } // -------------------------------------------------------------------------- // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void zlistx_reorder (zlistx_t *self, void *handle, bool low_value) { assert (self); assert (handle); node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); // Remove node from list, if it's attached s_node_relink (node, node->prev, node->next); if (low_value) { node_t *next = self->head->next; while (next != self->head) { if (self->comparator (node->item, next->item) <= 0) break; next = next->next; } // Relink node before next node s_node_relink (node, next->prev, next); } else { node_t *prev = self->head->prev; while (prev != self->head) { if (self->comparator (prev->item, node->item) <= 0) break; prev = prev->prev; } // Relink node after prev node s_node_relink (node, prev, prev->next); } } // -------------------------------------------------------------------------- // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. zlistx_t * zlistx_dup (zlistx_t *self) { if (!self) return NULL; zlistx_t *copy = zlistx_new (); if (copy) { // Copy item handlers copy->destructor = self->destructor; copy->duplicator = self->duplicator; copy->comparator = self->comparator; // Copy nodes node_t *node; for (node = self->head->next; node != self->head; node = node->next) { if (!zlistx_add_end (copy, node->item)) { zlistx_destroy (©); break; } } } return copy; } // -------------------------------------------------------------------------- // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void zlistx_set_destructor (zlistx_t *self, czmq_destructor destructor) { assert (self); self->destructor = destructor; } // -------------------------------------------------------------------------- // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void zlistx_set_duplicator (zlistx_t *self, czmq_duplicator duplicator) { assert (self); self->duplicator = duplicator; } // -------------------------------------------------------------------------- // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void zlistx_set_comparator (zlistx_t *self, czmq_comparator comparator) { assert (self); self->comparator = comparator; } // -------------------------------------------------------------------------- // Runs selftest of class void zlistx_test (int verbose) { printf (" * zlistx: "); // @selftest zlistx_t *list = zlistx_new (); assert (list); assert (zlistx_size (list) == 0); // Test operations on an empty list assert (zlistx_first (list) == NULL); assert (zlistx_last (list) == NULL); assert (zlistx_next (list) == NULL); assert (zlistx_prev (list) == NULL); assert (zlistx_find (list, "hello") == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); zlistx_purge (list); zlistx_sort (list); // Use item handlers zlistx_set_destructor (list, (czmq_destructor *) zstr_free); zlistx_set_duplicator (list, (czmq_duplicator *) strdup); zlistx_set_comparator (list, (czmq_comparator *) strcmp); // Try simple insert/sort/delete/next assert (zlistx_next (list) == NULL); zlistx_add_end (list, "world"); assert (streq ((char *) zlistx_next (list), "world")); zlistx_add_end (list, "hello"); assert (streq ((char *) zlistx_prev (list), "hello")); zlistx_sort (list); assert (zlistx_size (list) == 2); void *handle = zlistx_find (list, "hello"); char *item1 = (char *) zlistx_item (list); char *item2 = (char *) zlistx_handle_item (handle); assert (item1 == item2); assert (streq (item1, "hello")); zlistx_delete (list, handle); assert (zlistx_size (list) == 1); char *string = (char *) zlistx_detach (list, NULL); assert (streq (string, "world")); free (string); assert (zlistx_size (list) == 0); // Check next/back work // Now populate the list with items zlistx_add_start (list, "five"); zlistx_add_end (list, "six"); zlistx_add_start (list, "four"); zlistx_add_end (list, "seven"); zlistx_add_start (list, "three"); zlistx_add_end (list, "eight"); zlistx_add_start (list, "two"); zlistx_add_end (list, "nine"); zlistx_add_start (list, "one"); zlistx_add_end (list, "ten"); // Test our navigation skills assert (zlistx_size (list) == 10); assert (streq ((char *) zlistx_last (list), "ten")); assert (streq ((char *) zlistx_prev (list), "nine")); assert (streq ((char *) zlistx_prev (list), "eight")); assert (streq ((char *) zlistx_prev (list), "seven")); assert (streq ((char *) zlistx_prev (list), "six")); assert (streq ((char *) zlistx_prev (list), "five")); assert (streq ((char *) zlistx_first (list), "one")); assert (streq ((char *) zlistx_next (list), "two")); assert (streq ((char *) zlistx_next (list), "three")); assert (streq ((char *) zlistx_next (list), "four")); // Sort by alphabetical order zlistx_sort (list); assert (streq ((char *) zlistx_first (list), "eight")); assert (streq ((char *) zlistx_last (list), "two")); // Moving items around handle = zlistx_find (list, "six"); zlistx_move_start (list, handle); assert (streq ((char *) zlistx_first (list), "six")); zlistx_move_end (list, handle); assert (streq ((char *) zlistx_last (list), "six")); zlistx_sort (list); assert (streq ((char *) zlistx_last (list), "two")); // Copying a list zlistx_t *copy = zlistx_dup (list); assert (copy); assert (zlistx_size (copy) == 10); assert (streq ((char *) zlistx_first (copy), "eight")); assert (streq ((char *) zlistx_last (copy), "two")); zlistx_destroy (©); // Delete items while iterating string = (char *) zlistx_first (list); assert (streq (string, "eight")); string = (char *) zlistx_next (list); assert (streq (string, "five")); zlistx_delete (list, zlistx_cursor (list)); string = (char *) zlistx_next (list); assert (streq (string, "four")); zlistx_purge (list); zlistx_destroy (&list); // @end printf ("OK\n"); } czmq-3.0.2/src/zarmour.c0000664000175000017500000007325312522736135014242 0ustar00phph00000000000000/* ========================================================================= zarmour - armoured text encoding and decoding Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zarmour - armoured text encoding and decoding @discuss The zarmour class implements encoding and decoding of armoured text data. The following codecs are implemented: * RFC 4648 (http://www.ietf.org/rfc/rfc4648.txt) - base64 - base64url - base32 - base32hex - base16 * Z85 (http://rfc.zeromq.org/spec:32) All RFC4648 base64 and base32 variants support padding the output. The pad character is configurable. Default is padding on, with character '='. Additionally, in some cases (e.g. MIME), splitting the output into lines of a specific length is required. This feature is also supported, though turned off by default. The z85 mode does neither padding nor line breaks; it is merely a wrapping of the corresponding libzmq methods. Encoding will assert if input length is not divisible by 4 and decoding will assert if input length is not divisible by 5. @end */ #include "../include/czmq.h" #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 3, 0)) #define _INCLUDE_Z85 #endif // Structure of our class struct _zarmour_t { zarmour_mode_t mode; // The current mode (std or url) bool pad; // Should output be padded? char pad_char; // The pad character bool line_breaks; // Should output be broken into lines? size_t line_length; // The line length to use char *line_end; }; // Textual names of modes #ifdef _INCLUDE_Z85 const int _NUM_MODES = 6; #else const int _NUM_MODES = 5; #endif static char s_codec_names[][16] = { "base64" , "base64url" , "base32" , "base32hex" , "base16" #ifdef _INCLUDE_Z85 , "z85" #endif }; // -------------------------------------------------------------------------- // Create a new zarmour zarmour_t * zarmour_new () { zarmour_t *self = (zarmour_t *) zmalloc (sizeof (zarmour_t)); if (!self) return NULL; // Setup default as RFC4648 paragraph 4 self->mode = ZARMOUR_MODE_BASE64_STD; self->pad = true; self->pad_char = '='; self->line_breaks = false; self->line_length = 72; self->line_end = strdup ("\n"); if (!self->line_end) { zarmour_destroy (&self); return NULL; } return self; } // -------------------------------------------------------------------------- // Destroy the zarmour void zarmour_destroy (zarmour_t **self_p) { assert (self_p); if (*self_p) { zarmour_t *self = *self_p; // Free class properties free (self->line_end); // Free object itself free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Print properties of object void zarmour_print (zarmour_t *self) { assert (self); zsys_debug ("zarmour:"); zsys_debug (" mode: %s", zarmour_mode_str (self)); zsys_debug (" pad: %s", self->pad? "true": "false"); zsys_debug (" pad_char: '%c'", self->pad_char); zsys_debug (" line_breaks: %s", self->line_breaks? "true": "false"); zsys_debug (" line_length: %d", self->line_length); } // -------------------------------------------------------------------------- // Get printable string for mode const char * zarmour_mode_str (zarmour_t *self) { assert (self); assert ((int) self->mode >= 0 && (int) self->mode < _NUM_MODES); return s_codec_names[(int) self->mode]; } // -------------------------------------------------------------------------- // Helper macros for encoding/decoding #define _NO_CONVERT(c) (c) #define _UPPER_CASE(c) ((c) & ((c) & 0x40? 0xdf: 0xff)) #define _NEXT_CHAR(i,n,c,a,u) \ while ((n) < (c) && !strchr ((a), (u(*(n))))) \ ++(n); \ (i) = (byte) ((n) < (c)? (strchr ((a), (u(*(n)))) - (a)): 0xff); \ ++(n) // --------------------------------------------------------------------------- // RFC 4648 Paragraph 4 (standard base64 alphabet) static char // 0----5----0----5----0----5----0----5----0----5----0----5----0--- s_base64_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // --------------------------------------------------------------------------- // RFC 4648 Paragraph 5 (URL & filename friendly base64 alphabet) static char // 0----5----0----5----0----5----0----5----0----5----0----5----0--- s_base64url_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; static char * s_base64_encode (const byte *data, size_t length, const char *alphabet, bool pad, char pad_char) { size_t extra_chars = ((length % 3)? length % 3 + 1: 0); size_t pad_chars = (pad && extra_chars)? 4 - extra_chars: 0; size_t str_chars = 4 * (length / 3) + extra_chars + pad_chars; char *str = (char *) zmalloc (str_chars + 1); if (!str) return NULL; char *enc = str; const byte *needle = data, *ceiling = data + length; while (needle < ceiling) { *enc++ = alphabet[(*needle) >> 2]; if (needle + 1 < ceiling) { *enc++ = alphabet[((*needle << 4) & 0x30) | (*(needle + 1) >> 4)]; if (needle + 2 < ceiling) { *enc++ = alphabet[((*(needle + 1) << 2) & 0x3c) | (*(needle + 2) >> 6)]; *enc++ = alphabet[*(needle + 2) & 0x3f]; } else *enc++ = alphabet[(*(needle + 1) << 2) & 0x3c]; } else *enc++ = alphabet[(*needle << 4) & 0x30]; needle += 3; } while (pad && enc < str + str_chars) *enc++ = pad_char; *enc = 0; return str; } static byte * s_base64_decode (const char *data, size_t *size, const char *alphabet, size_t linebreakchars) { size_t length = strlen (data); while (length > 0 && !strchr (alphabet, data[length - 1])) --length; const byte *needle = (const byte *) data, *ceiling = (const byte *) (data + length); length -= linebreakchars; *size = 3 * (length / 4) + ((length % 4)? length % 4 - 1 : 0) + 1; byte *bytes = (byte *) zmalloc (*size); if (!bytes) return NULL; byte *dec = bytes; byte i1, i2, i3, i4; while (needle < ceiling) { _NEXT_CHAR(i1,needle,ceiling,alphabet,_NO_CONVERT); _NEXT_CHAR(i2,needle,ceiling,alphabet,_NO_CONVERT); if (i1 != 0xff && i2 != 0xff) *dec++ = i1 << 2 | i2 >> 4; _NEXT_CHAR(i3,needle,ceiling,alphabet,_NO_CONVERT); if (i2 != 0xff && i3 != 0xff) *dec++ = i2 << 4 | i3 >> 2; _NEXT_CHAR(i4,needle,ceiling,alphabet,_NO_CONVERT); if (i3 != 0xff && i4 != 0xff) *dec++ = i3 << 6 | i4; } *dec = 0; return bytes; } // --------------------------------------------------------------------------- // RFC 4648 Paragraph 6 (standard base32 alphabet) static char // 0----5----0----5----0----5----0- s_base32_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; // --------------------------------------------------------------------------- // RFC 4648 Paragraph 7 (base32hex alphabet) static char // 0----5----0----5----0----5----0- s_base32hex_alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"; static char * s_base32_encode (const byte *data, size_t length, const char *alphabet, bool pad, char pad_char) { size_t extra_bytes = length % 5, extra_chars = 0; switch (extra_bytes) { case 1: extra_chars = 2; break; case 2: extra_chars = 4; break; case 3: extra_chars = 5; break; case 4: extra_chars = 7; break; } size_t pad_chars = (pad && extra_chars)? 8 - extra_chars: 0; size_t str_chars = 8 * (length / 5) + extra_chars + pad_chars; char *str = (char *) zmalloc (str_chars + 1); if (!str) return NULL; char *enc = str; const byte *needle = data, *ceiling = data + length; while (needle < ceiling) { *enc++ = alphabet[(*needle) >> 3]; if (needle + 1 < ceiling) { *enc++ = alphabet[((*needle << 2) & 0x1c) | (*(needle + 1) >> 6)]; *enc++ = alphabet[(*(needle + 1) >> 1) & 0x1f]; if (needle + 2 < ceiling) { *enc++ = alphabet[((*(needle + 1) << 4) & 0x10) | (*(needle + 2) >> 4)]; if (needle + 3 < ceiling) { *enc++ = alphabet[((*(needle + 2) << 1) & 0x1e) | (*(needle + 3) >> 7)]; *enc++ = alphabet[(*(needle + 3) >> 2) & 0x1f]; if (needle + 4 < ceiling) { *enc++ = alphabet[((*(needle + 3) << 3) & 0x18) | (*(needle + 4) >> 5)]; *enc++ = alphabet[*(needle + 4) & 0x1f]; } else *enc++ = alphabet[(*(needle + 3) << 3) & 0x18]; } else *enc++ = alphabet[(*(needle + 2) << 1) & 0x1e]; } else *enc++ = alphabet[(*(needle + 1) << 4) & 0x10]; } else *enc++ = alphabet[(*needle << 2) & 0x1c]; needle += 5; } while (enc < str + str_chars) *enc++ = pad_char; *enc = 0; return str; } static byte * s_base32_decode (const char *data, size_t *size, const char *alphabet, size_t linebreakchars) { size_t length = strlen (data); while (length > 0 && !strchr (alphabet, _UPPER_CASE(data[length - 1]))) --length; const byte *needle = (const byte *) data, *ceiling = (const byte *) (data + length); length -= linebreakchars; size_t extra_chars = length % 8, extra_bytes = 0; switch (extra_chars) { case 0: break; case 2: extra_bytes = 1; break; case 4: extra_bytes = 2; break; case 5: extra_bytes = 3; break; case 7: extra_bytes = 4; break; default: assert (false); break; } *size = 5 * (length / 8) + extra_bytes + 1; byte *bytes = (byte *) zmalloc (*size); if (!bytes) return NULL; byte *dec = bytes; byte i1, i2, i3, i4, i5, i6, i7, i8; while (needle < ceiling) { _NEXT_CHAR(i1,needle,ceiling,alphabet,_UPPER_CASE); _NEXT_CHAR(i2,needle,ceiling,alphabet,_UPPER_CASE); if (i1 != 0xff && i2 != 0xff) *dec++ = i1 << 3 | i2 >> 2; _NEXT_CHAR(i3,needle,ceiling,alphabet,_UPPER_CASE); _NEXT_CHAR(i4,needle,ceiling,alphabet,_UPPER_CASE); if (i2 != 0xff && i3 != 0xff && i4 != 0xff) *dec++ = i2 << 6 | i3 << 1 | i4 >> 4; _NEXT_CHAR(i5,needle,ceiling,alphabet,_UPPER_CASE); if (i4 != 0xff && i5 != 0xff) *dec++ = i4 << 4 | i5 >> 1; _NEXT_CHAR(i6,needle,ceiling,alphabet,_UPPER_CASE); _NEXT_CHAR(i7,needle,ceiling,alphabet,_UPPER_CASE); if (i5 != 0xff && i6 != 0xff && i7 != 0xff) *dec++ = i5 << 7 | i6 << 2 | i7 >> 3; _NEXT_CHAR(i8,needle,ceiling,alphabet,_UPPER_CASE); if (i7 != 0xff && i8 != 0xff) *dec++ = i7 << 5 | i8; } *dec = 0; return bytes; } // --------------------------------------------------------------------------- // RFC 4648 Paragraph 8 (standard base16 alphabet) static char // 0----5----0----5 s_base16_alphabet[] = "0123456789ABCDEF"; static char * s_base16_encode (const byte *data, size_t length, const char *alphabet) { char *str = (char *) zmalloc (2 * length + 1); if (!str) return NULL; char *enc = str; const byte *needle = data, *ceiling = data + length; while (needle < ceiling) { *enc++ = alphabet[(*needle) >> 4]; *enc++ = alphabet[(*needle++) & 0x0f]; } *enc = 0; return str; } static byte * s_base16_decode (const char *data, size_t *size, const char *alphabet, size_t linebreakchars) { size_t length = strlen (data); const byte *needle = (const byte *) data, *ceiling = (const byte *) (data + length); length -= linebreakchars; *size = length / 2 + 1; byte *bytes = (byte *) zmalloc (*size); if (!bytes) return NULL; byte *dec = bytes; byte i1, i2; while (needle < ceiling) { _NEXT_CHAR(i1,needle,ceiling,alphabet,_UPPER_CASE); _NEXT_CHAR(i2,needle,ceiling,alphabet,_UPPER_CASE); if (i1 != 0xff && i2 != 0xff) *dec++ = i1 << 4 | i2; } *dec = 0; return bytes; } // --------------------------------------------------------------------------- // z85 #ifdef _INCLUDE_Z85 static char * s_z85_encode (const byte *data, size_t length) { assert (data != NULL); assert (length % 4 == 0); char *str = (char *) zmalloc (5 * length / 4 + 1); char *result = zmq_z85_encode (str, (uint8_t *) data, length); if (result == NULL) { free (str); str = NULL; } return str; } static byte * s_z85_decode (const char *data, size_t *size) { assert (data); assert (size); size_t length = strlen (data); assert (length % 5 == 0); *size = 4 * length / 5 + 1; byte *bytes = (byte *) zmalloc (*size); uint8_t *result = zmq_z85_decode (bytes, (char *) data); if (result == NULL) { free (bytes); bytes = NULL; } return bytes; } #endif // Definition of encode method char * zarmour_encode (zarmour_t *self, const byte *data, size_t data_size) { assert (self); assert (data); char *encoded = NULL; switch (self->mode) { case ZARMOUR_MODE_BASE64_STD: encoded = s_base64_encode (data, data_size, s_base64_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE64_URL: encoded = s_base64_encode (data, data_size, s_base64url_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE32_STD: encoded = s_base32_encode (data, data_size, s_base32_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE32_HEX: encoded = s_base32_encode (data, data_size, s_base32hex_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE16: encoded = s_base16_encode (data, data_size, s_base16_alphabet); break; #ifdef _INCLUDE_Z85 case ZARMOUR_MODE_Z85: encoded = s_z85_encode (data, data_size); break; #endif } if (!encoded) return NULL; #ifdef _INCLUDE_Z85 if (self->mode != ZARMOUR_MODE_Z85 && self->line_breaks && self->line_length > 0 && strlen (encoded) > self->line_length) { #else if (self->line_breaks && self->line_length > 0 && strlen (encoded) > self->line_length) { #endif char *line_end = self->line_end; size_t nbr_lines = strlen (encoded) / self->line_length; size_t new_length = nbr_lines * (self->line_length + strlen (line_end)) + strlen (encoded) % self->line_length; char *src = encoded; char *temp = encoded; encoded = (char *) zmalloc (new_length + 1); char *dest = encoded; while (strlen (src) >= self->line_length) { memcpy (dest, src, self->line_length); src += self->line_length; dest += self->line_length; if (*src) { memcpy (dest, line_end, strlen (line_end)); dest += strlen (line_end); } } if (*src) { memcpy (dest, src, strlen (src)); dest += strlen (src); } free (temp); *dest = 0; } return encoded; } // Definition of decode method byte * zarmour_decode (zarmour_t *self, const char *data, size_t *decode_size) { assert (self); assert (data); assert (decode_size); size_t linebreakchars = 0; char *line_end = self->line_end; const char *pos = data; while ((pos = strstr (pos, line_end))) { linebreakchars += strlen (line_end); pos += strlen (line_end); } switch (self->mode) { case ZARMOUR_MODE_BASE64_STD: return s_base64_decode (data, decode_size, s_base64_alphabet, linebreakchars); case ZARMOUR_MODE_BASE64_URL: return s_base64_decode (data, decode_size, s_base64url_alphabet, linebreakchars); case ZARMOUR_MODE_BASE32_STD: return s_base32_decode (data, decode_size, s_base32_alphabet, linebreakchars); case ZARMOUR_MODE_BASE32_HEX: return s_base32_decode (data, decode_size, s_base32hex_alphabet, linebreakchars); case ZARMOUR_MODE_BASE16: return s_base16_decode (data, decode_size, s_base16_alphabet, linebreakchars); #ifdef _INCLUDE_Z85 case ZARMOUR_MODE_Z85: return s_z85_decode (data, decode_size); #endif } return NULL; } // -------------------------------------------------------------------------- // Get/set the mode property zarmour_mode_t zarmour_mode (zarmour_t *self) { assert (self); return self->mode; } void zarmour_set_mode (zarmour_t *self, zarmour_mode_t mode) { assert (self); self->mode = mode; } // -------------------------------------------------------------------------- // Get/set the pad property bool zarmour_pad (zarmour_t *self) { assert (self); return self->pad; } void zarmour_set_pad (zarmour_t *self, bool pad) { assert (self); self->pad = pad; } // -------------------------------------------------------------------------- // Get/set the pad_char property char zarmour_pad_char (zarmour_t *self) { assert (self); return self->pad_char; } void zarmour_set_pad_char (zarmour_t *self, char pad_char) { assert (self); self->pad_char = pad_char; } // -------------------------------------------------------------------------- // Get/set the line_breaks property bool zarmour_line_breaks (zarmour_t *self) { assert (self); return self->line_breaks; } void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks) { assert (self); self->line_breaks = line_breaks; } // -------------------------------------------------------------------------- // Get/set the line_length property size_t zarmour_line_length (zarmour_t *self) { assert (self); return self->line_length; } void zarmour_set_line_length (zarmour_t *self, size_t line_length) { assert (self); self->line_length = line_length; } // --------------------------------------------------------------------------- // armour test utility static void s_armour_test (zarmour_t *self, const char *test_string, const char *expected_result, bool verbose) { assert (self); assert (test_string); assert (expected_result); char *encoded = zarmour_encode (self, (byte *) test_string, strlen (test_string)); assert (encoded); if (verbose) zsys_debug (" encoded '%s' into '%s'", test_string, encoded); assert (strlen (encoded) == strlen (expected_result)); assert (streq (encoded, expected_result)); size_t size; char *decoded = (char *) zarmour_decode (self, encoded, &size); assert (decoded); if (verbose) zsys_debug (" decoded '%s' into '%s'", encoded, decoded); assert (size == strlen (decoded) + 1); assert (streq (decoded, test_string)); free (encoded); free (decoded); } static void s_armour_decode (zarmour_t *self, const char *test_string, const char *expected_result, bool verbose) { assert (self); assert (test_string); assert (expected_result); size_t size; char *decoded = (char *) zarmour_decode (self, test_string, &size); assert (decoded); if (verbose) zsys_debug (" decoded '%s' into '%s'", test_string, decoded); assert (size == strlen (decoded) + 1); assert (streq (decoded, expected_result)); free (decoded); } static void s_armour_test_long (zarmour_t *self, byte *test_data, size_t length, bool verbose) { if (verbose) zarmour_print (self); char *test_string = zarmour_encode (self, test_data, length); assert (test_string); if (verbose) zsys_debug (" encoded %d bytes array to:\n%s", length, test_string); size_t test_size; byte *test_data2 = zarmour_decode (self, test_string, &test_size); free (test_string); assert (test_data2); assert (test_size == length + 1); unsigned int i; for (i = 0; i < length; ++i) { assert (test_data2[i] == i); } free (test_data2); if (verbose) zsys_debug (" decoded %d bytes, all match", test_size - 1); } // -------------------------------------------------------------------------- // Selftest int zarmour_test (bool verbose) { printf (" * zarmour: "); if (verbose) printf ("\n"); // @selftest zarmour_t *self = zarmour_new (); assert (self); zarmour_mode_t mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_STD); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_URL); assert (zarmour_pad (self)); zarmour_set_pad (self, false); assert (!zarmour_pad (self)); assert (zarmour_pad_char (self) == '='); zarmour_set_pad_char (self, '!'); assert (zarmour_pad_char (self) == '!'); zarmour_set_pad_char (self, '='); assert (zarmour_pad_char (self) == '='); assert (!zarmour_line_breaks (self)); zarmour_set_line_breaks (self, true); assert (zarmour_line_breaks (self)); assert (zarmour_line_length (self) == 72); zarmour_set_line_length (self, 64); assert (zarmour_line_length (self) == 64); // Test against test vectors from RFC4648. zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY", verbose); s_armour_test (self, "fo", "MZXQ", verbose); s_armour_test (self, "foo", "MZXW6", verbose); s_armour_test (self, "foob", "MZXW6YQ", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI", verbose); s_armour_decode (self, "my", "f", verbose); s_armour_decode (self, "mzxq", "fo", verbose); s_armour_decode (self, "mzxw6", "foo", verbose); s_armour_decode (self, "mzxw6yq", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY======", verbose); s_armour_test (self, "fo", "MZXQ====", verbose); s_armour_test (self, "foo", "MZXW6===", verbose); s_armour_test (self, "foob", "MZXW6YQ=", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI======", verbose); s_armour_decode (self, "my======", "f", verbose); s_armour_decode (self, "mzxq====", "fo", verbose); s_armour_decode (self, "mzxw6===", "foo", verbose); s_armour_decode (self, "mzxw6yq=", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi======", "foobar", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO", verbose); s_armour_test (self, "fo", "CPNG", verbose); s_armour_test (self, "foo", "CPNMU", verbose); s_armour_test (self, "foob", "CPNMUOG", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8", verbose); s_armour_decode (self, "co", "f", verbose); s_armour_decode (self, "cpng", "fo", verbose); s_armour_decode (self, "cpnmu", "foo", verbose); s_armour_decode (self, "cpnmuog", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO======", verbose); s_armour_test (self, "fo", "CPNG====", verbose); s_armour_test (self, "foo", "CPNMU===", verbose); s_armour_test (self, "foob", "CPNMUOG=", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8======", verbose); s_armour_decode (self, "co======", "f", verbose); s_armour_decode (self, "cpng====", "fo", verbose); s_armour_decode (self, "cpnmu===", "foo", verbose); s_armour_decode (self, "cpnmuog=", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8======", "foobar", verbose); zarmour_set_pad (self, true); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "66", verbose); s_armour_test (self, "fo", "666F", verbose); s_armour_test (self, "foo", "666F6F", verbose); s_armour_test (self, "foob", "666F6F62", verbose); s_armour_test (self, "fooba", "666F6F6261", verbose); s_armour_test (self, "foobar", "666F6F626172", verbose); s_armour_decode (self, "666f", "fo", verbose); s_armour_decode (self, "666f6f", "foo", verbose); s_armour_decode (self, "666f6f62", "foob", verbose); s_armour_decode (self, "666f6f6261", "fooba", verbose); s_armour_decode (self, "666f6f626172", "foobar", verbose); #ifdef _INCLUDE_Z85 // Z85 test is homemade; using 0, 4 and 8 bytes, with precalculated // test vectors created with a libzmq test. // ---------------------------------------------------------------- // Make a fake curve key from hex (base16) string, making sure // there are no null bytes inside, so we can use our test utility zarmour_set_mode (self, ZARMOUR_MODE_BASE16); zarmour_set_line_breaks (self, false); size_t key_len; byte *key_data = zarmour_decode (self, "4E6F87E2FB6EB22A1EF5E257B75D79124949565F0B8B36A878A4F03111C96E0B", &key_len); zarmour_set_mode (self, ZARMOUR_MODE_Z85); // Z85 mode does not support padding or line breaks zarmour_set_pad (self, false); // so these two are superfluous; zarmour_set_line_breaks (self, false); // just for consistency if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "foob", "w]zP%", verbose); s_armour_test (self, "foobar!!", "w]zP%vr9Im", verbose); s_armour_test (self, (char *) key_data, "ph+{E}!&X?9}!I]W{sm(nL8@&3Yu{wC+<*-5Y[[#", verbose); free (key_data); #endif // Armouring longer byte array to test line breaks zarmour_set_pad (self, true); zarmour_set_line_breaks (self, true); byte test_data[256]; int i; for (i = 0; i < 256; ++i) { test_data[i] = i; } zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); s_armour_test_long (self, test_data, 256, verbose); #ifdef _INCLUDE_Z85 zarmour_set_mode (self, ZARMOUR_MODE_Z85); s_armour_test_long (self, test_data, 256, verbose); #endif zarmour_destroy (&self); // @end printf ("OK\n"); return 0; } #ifdef _INCLUDE_Z85 #undef _INCLUDE_Z85 #endif czmq-3.0.2/src/zsocket.c0000664000175000017500000002257212505070716014220 0ustar00phph00000000000000/* ========================================================================= zsocket - working with 0MQ sockets (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsocket class provides helper functions for 0MQ sockets. It doesn't wrap the 0MQ socket type, to avoid breaking all libzmq socket-related calls. @discuss @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // Create a new socket within our CZMQ context, replaces zmq_socket. // Use this to get automatic management of the socket at shutdown. // Note: SUB sockets do not automatically subscribe to everything; you // must set filters explicitly. void * zsocket_new (zctx_t *ctx, int type) { void *self = zctx__socket_new (ctx, type); return self; } // -------------------------------------------------------------------------- // Destroy the socket. You must use this for any socket created via the // zsocket_new method. If socket is null, does nothing. void zsocket_destroy (zctx_t *ctx, void *self) { if (self) zctx__socket_destroy (ctx, self); } // -------------------------------------------------------------------------- // Bind a socket to a formatted endpoint. If the port is specified as // '*', binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO // and returns the actual port number used. Always returns the // port number if successful. Note that if a previous process or thread // used the same port, peers may connect to the caller thinking it was // the previous process/thread. int zsocket_bind (void *self, const char *format, ...) { // Ephemeral port needs 4 additional characters char endpoint [256 + 4]; va_list argptr; va_start (argptr, format); int endpoint_size = vsnprintf (endpoint, 256, format, argptr); va_end (argptr); // Port must be at end of endpoint if (endpoint [endpoint_size - 2] == ':' && endpoint [endpoint_size - 1] == '*') { int port = ZSOCKET_DYNFROM; while (port <= ZSOCKET_DYNTO) { // Try to bind on the next plausible port sprintf (endpoint + endpoint_size - 1, "%d", port); if (zmq_bind (self, endpoint) == 0) return port; port++; } return -1; } else { // Return actual port used for binding int port = zmq_bind (self, endpoint); if (port == 0) port = atoi (strrchr (endpoint, ':') + 1); else port = -1; return port; } } // -------------------------------------------------------------------------- // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsocket_unbind (void *self, const char *format, ...) { #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) char endpoint [256]; va_list argptr; va_start (argptr, format); vsnprintf (endpoint, 256, format, argptr); va_end (argptr); return zmq_unbind (self, endpoint); #else return -1; #endif } // -------------------------------------------------------------------------- // Connect a socket to a formatted endpoint // Returns 0 if the endpoint is valid, -1 if the connect failed. int zsocket_connect (void *self, const char *format, ...) { char endpoint [256]; va_list argptr; va_start (argptr, format); vsnprintf (endpoint, 256, format, argptr); va_end (argptr); return zmq_connect (self, endpoint); } // -------------------------------------------------------------------------- // Disconnect a socket from a formatted endpoint // Returns 0 if disconnection is complete -1 if the disconnection failed. int zsocket_disconnect (void *self, const char *format, ...) { #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) char endpoint [256]; va_list argptr; va_start (argptr, format); vsnprintf (endpoint, 256, format, argptr); va_end (argptr); return zmq_disconnect (self, endpoint); #else return -1; #endif } // -------------------------------------------------------------------------- // Poll for input events on the socket. Returns true if there is input // ready on the socket, else false. bool zsocket_poll (void *self, int msecs) { zmq_pollitem_t items [] = { { self, 0, ZMQ_POLLIN, 0 } }; int rc = zmq_poll (items, 1, msecs); return rc != -1 && (items [0].revents & ZMQ_POLLIN) != 0; } // -------------------------------------------------------------------------- // Returns socket type as printable constant string const char * zsocket_type_str (void *self) { assert (self); return zsys_sockname (zsocket_type (self)); } // -------------------------------------------------------------------------- // Send data over a socket as a single message frame. // Accepts these flags: ZFRAME_MORE and ZFRAME_DONTWAIT. int zsocket_sendmem (void *self, const void *data, size_t size, int flags) { assert (self); assert (size == 0 || data); int snd_flags = (flags & ZFRAME_MORE) ? ZMQ_SNDMORE : 0; snd_flags |= (flags & ZFRAME_DONTWAIT) ? ZMQ_DONTWAIT : 0; zmq_msg_t msg; zmq_msg_init_size (&msg, size); memcpy (zmq_msg_data (&msg), data, size); if (zmq_sendmsg (self, &msg, snd_flags) == -1) { zmq_msg_close (&msg); return -1; } else return 0; } // -------------------------------------------------------------------------- // Send a signal over a socket. A signal is a zero-byte message. // Signals are used primarily between threads, over pipe sockets. // Returns -1 if there was an error sending the signal. int zsocket_signal (void *self) { assert (self); return zstr_send (self, ""); } // -------------------------------------------------------------------------- // Wait on a signal. Use this to coordinate between threads, over // pipe pairs. Blocks until the signal is received. Returns -1 on error, // 0 on success. int zsocket_wait (void *self) { assert (self); char *message = zstr_recv (self); if (message) { free (message); return 0; } else return -1; } #if (ZMQ_VERSION_MAJOR > 2) // -------------------------------------------------------------------------- // Set socket high-water mark, emulating 2.x API void zsocket_set_hwm (void *self, int hwm) { zsocket_set_sndhwm (self, hwm); zsocket_set_rcvhwm (self, hwm); } #endif // -------------------------------------------------------------------------- // Selftest void zsocket_test (bool verbose) { printf (" * zsocket (deprecated): "); // @selftest zctx_t *ctx = zctx_new (); assert (ctx); // Create a detached thread, let it run char *interf = "127.0.0.1"; char *domain = "localhost"; int service = 5560; void *writer = zsocket_new (ctx, ZMQ_PUSH); assert (writer); void *reader = zsocket_new (ctx, ZMQ_PULL); assert (reader); assert (streq (zsocket_type_str (writer), "PUSH")); assert (streq (zsocket_type_str (reader), "PULL")); int rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsocket_unbind (writer, "tcp://%s:%d", interf, service); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #endif rc = zsocket_connect (reader, "tcp://%s:%d", domain, service); assert (rc == 0); zstr_send (writer, "HELLO"); char *message = zstr_recv (reader); assert (message); assert (streq (message, "HELLO")); free (message); // Test binding to ports int port = zsocket_bind (writer, "tcp://%s:*", interf); assert (port >= ZSOCKET_DYNFROM && port <= ZSOCKET_DYNTO); assert (zsocket_poll (writer, 100) == false); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsocket_connect (reader, "txp://%s:%d", domain, service); assert (rc == -1); // Test sending frames to socket rc = zsocket_sendmem (writer, "ABC", 3, ZFRAME_MORE); assert (rc == 0); rc = zsocket_sendmem (writer, "DEFG", 4, 0); assert (rc == 0); zframe_t *frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "ABC")); assert (zframe_more (frame)); zframe_destroy (&frame); frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "DEFG")); assert (!zframe_more (frame)); zframe_destroy (&frame); rc = zsocket_signal (writer); assert (rc == 0); rc = zsocket_wait (reader); assert (rc == 0); zsocket_destroy (ctx, reader); zsocket_destroy (ctx, writer); zctx_destroy (&ctx); // @end printf ("OK\n"); } czmq-3.0.2/src/zmonitor_v2.c0000664000175000017500000002577712505070716015040 0ustar00phph00000000000000/* ========================================================================= zmonitor_v2 - socket event monitor (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zmonitor class provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Currently this class requires libzmq v4.0 or later and is empty on older versions of libzmq. @discuss This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zmonitor interface, based on zactor, together with the zsock class for sockets. @end */ #include "../include/czmq.h" // This code needs backporting to work with ZMQ v3.2 #if (ZMQ_VERSION_MAJOR == 4) // Structure of our class struct _zmonitor_t { void *socket; // Socket being monitored void *pipe; // Pipe through to backend agent }; // Background task does the real I/O static void s_agent_task (void *args, zctx_t *ctx, void *pipe); // -------------------------------------------------------------------------- // Create a new socket monitor zmonitor_t * zmonitor_new (zctx_t *ctx, void *socket, int events) { zmonitor_t *self = (zmonitor_t *) zmalloc (sizeof (zmonitor_t)); if (!self) return NULL; // Start background agent to connect to the inproc monitor socket assert (ctx); self->pipe = zthread_fork (ctx, s_agent_task, NULL); if (self->pipe) { self->socket = socket; // Register a monitor endpoint on the socket char *monitor_endpoint = (char *) zmalloc (100); sprintf (monitor_endpoint, "inproc://zmonitor-%p", self->socket); int rc = zmq_socket_monitor (self->socket, monitor_endpoint, events); assert (rc == 0); // Configure backend agent with monitor endpoint zstr_sendf (self->pipe, "%s", monitor_endpoint); free (monitor_endpoint); char *status = zstr_recv (self->pipe); if (strneq (status, "OK")) zmonitor_destroy (&self); zstr_free (&status); } else zmonitor_destroy (&self); return self; } // -------------------------------------------------------------------------- // Destroy a socket monitor void zmonitor_destroy (zmonitor_t **self_p) { assert (self_p); if (*self_p) { zmonitor_t *self = *self_p; // Deregister monitor endpoint if (self->socket) zmq_socket_monitor (self->socket, NULL, 0); if (self->pipe) { zstr_send (self->pipe, "TERMINATE"); char *reply = zstr_recv (self->pipe); zstr_free (&reply); } free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Receive a status message from the monitor; if no message arrives within // 500 msec, or the call was interrupted, returns NULL. zmsg_t * zmonitor_recv (zmonitor_t *self) { zsocket_set_rcvtimeo (self->pipe, 500); return zmsg_recv (self->pipe); } // -------------------------------------------------------------------------- // Get the ZeroMQ socket, for polling void * zmonitor_socket (zmonitor_t *self) { assert (self); return self->pipe; } // -------------------------------------------------------------------------- // Enable verbose tracing of commands and activity void zmonitor_set_verbose (zmonitor_t *self, bool verbose) { assert (self); zstr_sendm (self->pipe, "VERBOSE"); zstr_sendf (self->pipe, "%d", verbose); } // -------------------------------------------------------------------------- // Backend agent implementation // Agent instance typedef struct { zctx_t *ctx; void *pipe; // Socket back to application void *socket; // Monitored socket char *endpoint; // Monitored endpoint bool verbose; // Trace activity to stdout bool terminated; } agent_t; // Prototypes for local functions we use in the agent static agent_t * s_agent_new (zctx_t *ctx, void *pipe, char *endpoint); static void s_api_command (agent_t *self); static void s_socket_event (agent_t *self); static void s_agent_destroy (agent_t **self_p); // This is the background task that monitors socket events static void s_agent_task (void *args, zctx_t *ctx, void *pipe) { char *endpoint = zstr_recv (pipe); assert (endpoint); agent_t *self = s_agent_new (ctx, pipe, endpoint); if (!self) return; zpoller_t *poller = zpoller_new (self->pipe, self->socket, NULL); if (poller) while (!self->terminated) { // Poll on API pipe and on monitor socket void *result = zpoller_wait (poller, -1); if (result == NULL) break; // Interrupted else if (result == self->pipe) s_api_command (self); else if (result == self->socket) s_socket_event (self); } zpoller_destroy (&poller); s_agent_destroy (&self); } // -------------------------------------------------------------------------- // Destroy agent instance static void s_agent_destroy (agent_t **self_p) { assert (self_p); if (*self_p) { agent_t *self = *self_p; free (self->endpoint); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Create and initialize new agent instance static agent_t * s_agent_new (zctx_t *ctx, void *pipe, char *endpoint) { agent_t *self = (agent_t *) zmalloc (sizeof (agent_t)); if (!self) return NULL; self->ctx = ctx; self->pipe = pipe; self->endpoint = endpoint; // connect to the socket monitor inproc endpoint self->socket = zsocket_new (self->ctx, ZMQ_PAIR); if (self->socket) { if (zsocket_connect (self->socket, "%s", self->endpoint) == 0) zstr_send (self->pipe, "OK"); else zstr_send (self->pipe, "ERROR"); } else s_agent_destroy (&self); return self; } // -------------------------------------------------------------------------- // Handle command from API static void s_api_command (agent_t *self) { char *command = zstr_recv (self->pipe); if (streq (command, "TERMINATE")) { self->terminated = true; zstr_send (self->pipe, "OK"); } else if (streq (command, "VERBOSE")) { char *verbose = zstr_recv (self->pipe); self->verbose = *verbose == '1'; free (verbose); } else zsys_error ("zmonitor unexpected API command '%s'", command); free (command); } // -------------------------------------------------------------------------- // Handle event from socket monitor static void s_socket_event (agent_t *self) { // First frame is event number and value zframe_t *frame = zframe_recv (self->socket); int event = *(uint16_t *) (zframe_data (frame)); int value = *(uint32_t *) (zframe_data (frame) + 2); zframe_destroy (&frame); // Second frame is address char *address = zstr_recv (self->socket); char *description = "Unknown"; switch (event) { case ZMQ_EVENT_ACCEPTED: description = "Accepted"; break; case ZMQ_EVENT_ACCEPT_FAILED: description = "Accept failed"; break; case ZMQ_EVENT_BIND_FAILED: description = "Bind failed"; break; case ZMQ_EVENT_CLOSED: description = "Closed"; break; case ZMQ_EVENT_CLOSE_FAILED: description = "Close failed"; break; case ZMQ_EVENT_DISCONNECTED: description = "Disconnected"; break; case ZMQ_EVENT_CONNECTED: description = "Connected"; break; case ZMQ_EVENT_CONNECT_DELAYED: description = "Connect delayed"; break; case ZMQ_EVENT_CONNECT_RETRIED: description = "Connect retried"; break; case ZMQ_EVENT_LISTENING: description = "Listening"; break; case ZMQ_EVENT_MONITOR_STOPPED: description = "Monitor stopped"; break; default: zsys_error ("illegal socket monitor event: %d", event); break; } if (self->verbose) zsys_info ("zmonitor: %s - %s", description, address); zstr_sendfm (self->pipe, "%d", event); zstr_sendfm (self->pipe, "%d", value); zstr_sendm (self->pipe, address); zstr_send (self->pipe, description); free (address); } // -------------------------------------------------------------------------- // Selftest of this class static bool s_check_event (zmonitor_t *self, int expected_event) { zmsg_t *msg = zmonitor_recv (self); assert (msg); char *string = zmsg_popstr (msg); int event = atoi (string); zstr_free (&string); zmsg_destroy (&msg); return event == expected_event; } #endif // ZeroMQ 4.0 or later void zmonitor_v2_test (bool verbose) { printf (" * zmonitor (deprecated): "); if (verbose) printf ("\n"); #if (ZMQ_VERSION_MAJOR == 4) // @selftest zctx_t *ctx = zctx_new (); assert (ctx); bool result; void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); zmonitor_t *sinkmon = zmonitor_new (ctx, sink, ZMQ_EVENT_LISTENING | ZMQ_EVENT_ACCEPTED); assert (sinkmon); zmonitor_set_verbose (sinkmon, verbose); // Check sink is now listening int port_nbr = zsocket_bind (sink, "tcp://127.0.0.1:*"); assert (port_nbr != -1); result = s_check_event (sinkmon, ZMQ_EVENT_LISTENING); assert (result); void *source = zsocket_new (ctx, ZMQ_PUSH); assert (source); zmonitor_t *sourcemon = zmonitor_new (ctx, source, ZMQ_EVENT_CONNECTED | ZMQ_EVENT_DISCONNECTED); assert (sourcemon); zmonitor_set_verbose (sourcemon, verbose); zsocket_connect (source, "tcp://127.0.0.1:%d", port_nbr); // Check source connected to sink result = s_check_event (sourcemon, ZMQ_EVENT_CONNECTED); assert (result); // Check sink accepted connection result = s_check_event (sinkmon, ZMQ_EVENT_ACCEPTED); assert (result); zmonitor_destroy (&sinkmon); zmonitor_destroy (&sourcemon); zctx_destroy (&ctx); // @end #endif // ZeroMQ 4.0 or later printf ("OK\n"); } czmq-3.0.2/src/zsys.c0000664000175000017500000014536412531101147013543 0ustar00phph00000000000000/* ========================================================================= zsys - system-level methods Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsys class provides a portable wrapper for system calls. We collect them here to reduce the number of weird #ifdefs in other classes. As far as possible, the bulk of CZMQ classes are fully portable. @discuss @end */ #include "platform.h" #include "../include/czmq.h" // -------------------------------------------------------------------------- // Signal handling // These are global variables accessible to CZMQ application code volatile int zsys_interrupted = 0; // Current name volatile int zctx_interrupted = 0; // Deprecated name volatile uint64_t zsys_allocs = 0; static void s_signal_handler (int signal_value); // We use these variables for signal handling static bool s_first_time = true; #if defined (__UNIX__) static struct sigaction sigint_default; static struct sigaction sigterm_default; #elif defined (__WINDOWS__) static zsys_handler_fn *installed_handler_fn; static BOOL WINAPI s_handler_fn_shim (DWORD ctrltype) { // Return TRUE for events that we handle if (ctrltype == CTRL_C_EVENT && installed_handler_fn != NULL) { installed_handler_fn (ctrltype); return TRUE; } else return FALSE; } #endif // -------------------------------------------------------------------------- // Global context handling // ZeroMQ context for this process static void *s_process_ctx = NULL; static bool s_initialized = false; // Default globals for new sockets and other joys; these can all be set // from the environment, or via the zsys_set_xxx API. static size_t s_io_threads = 1; // ZSYS_IO_THREADS=1 static size_t s_max_sockets = 1024; // ZSYS_MAX_SOCKETS=1024 static size_t s_linger = 0; // ZSYS_LINGER=0 static size_t s_sndhwm = 1000; // ZSYS_SNDHWM=1000 static size_t s_rcvhwm = 1000; // ZSYS_RCVHWM=1000 static size_t s_pipehwm = 1000; // ZSYS_PIPEHWM=1000 static int s_ipv6 = 0; // ZSYS_IPV6=0 static char *s_interface = NULL; // ZSYS_INTERFACE= static char *s_logident = NULL; // ZSYS_LOGIDENT= static FILE *s_logstream = NULL; // ZSYS_LOGSTREAM=stdout/stderr static bool s_logsystem = false; // ZSYS_LOGSYSTEM=true/false static zsock_t *s_logsender = NULL; // ZSYS_LOGSENDER= // Track number of open sockets so we can zmq_term() safely static size_t s_open_sockets = 0; // We keep a list of open sockets to report leaks to developers static zlist_t *s_sockref_list = NULL; // This defines a single zsocket_new() caller instance typedef struct { void *handle; int type; const char *filename; size_t line_nbr; } s_sockref_t; // Mutex macros #if defined (__UNIX__) typedef pthread_mutex_t zsys_mutex_t; # define ZMUTEX_INIT(m) pthread_mutex_init (&m, NULL); # define ZMUTEX_LOCK(m) pthread_mutex_lock (&m); # define ZMUTEX_UNLOCK(m) pthread_mutex_unlock (&m); # define ZMUTEX_DESTROY(m) pthread_mutex_destroy (&m); #elif defined (__WINDOWS__) typedef CRITICAL_SECTION zsys_mutex_t; # define ZMUTEX_INIT(m) InitializeCriticalSection (&m); # define ZMUTEX_LOCK(m) EnterCriticalSection (&m); # define ZMUTEX_UNLOCK(m) LeaveCriticalSection (&m); # define ZMUTEX_DESTROY(m) DeleteCriticalSection (&m); #endif // Mutex to guard socket counter static zsys_mutex_t s_mutex; // -------------------------------------------------------------------------- // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void * zsys_init (void) { if (s_initialized) { assert (s_process_ctx); return s_process_ctx; } // Pull process defaults from environment if (getenv ("ZSYS_IO_THREADS")) s_io_threads = atoi (getenv ("ZSYS_IO_THREADS")); if (getenv ("ZSYS_MAX_SOCKETS")) s_max_sockets = atoi (getenv ("ZSYS_MAX_SOCKETS")); if (getenv ("ZSYS_LINGER")) s_linger = atoi (getenv ("ZSYS_LINGER")); if (getenv ("ZSYS_SNDHWM")) s_sndhwm = atoi (getenv ("ZSYS_SNDHWM")); if (getenv ("ZSYS_RCVHWM")) s_rcvhwm = atoi (getenv ("ZSYS_RCVHWM")); if (getenv ("ZSYS_PIPEHWM")) s_pipehwm = atoi (getenv ("ZSYS_PIPEHWM")); if (getenv ("ZSYS_IPV6")) s_ipv6 = atoi (getenv ("ZSYS_IPV6")); if (getenv ("ZSYS_LOGSTREAM")) { if (streq (getenv ("ZSYS_LOGSTREAM"), "stdout")) s_logstream = stdout; else if (streq (getenv ("ZSYS_LOGSTREAM"), "stderr")) s_logstream = stderr; } else s_logstream = stdout; if (getenv ("ZSYS_LOGSYSTEM")) { if (streq (getenv ("ZSYS_LOGSYSTEM"), "true")) s_logsystem = true; else if (streq (getenv ("ZSYS_LOGSYSTEM"), "false")) s_logsystem = false; } // Catch SIGINT and SIGTERM unless ZSYS_SIGHANDLER=false if ((getenv ("ZSYS_SIGHANDLER") == NULL || strneq (getenv ("ZSYS_SIGHANDLER"), "false")) && s_first_time) zsys_catch_interrupts (); ZMUTEX_INIT (s_mutex); s_sockref_list = zlist_new (); if (!s_sockref_list) { zsys_shutdown (); return NULL; } srandom ((unsigned) time (NULL)); atexit (zsys_shutdown); assert (!s_process_ctx); // We use zmq_init/zmq_term to keep compatibility back to ZMQ v2 s_process_ctx = zmq_init ((int) s_io_threads); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // TODO: this causes TravisCI to break; libzmq does not return a // valid socket on zmq_socket(), after this... zmq_ctx_set (s_process_ctx, ZMQ_MAX_SOCKETS, (int) s_max_sockets); #endif s_initialized = true; // The following functions call zsys_init(), so they MUST be called after // s_initialized is set in order to avoid an infinite recursion if (getenv ("ZSYS_INTERFACE")) zsys_set_interface (getenv ("ZSYS_INTERFACE")); if (getenv ("ZSYS_LOGIDENT")) zsys_set_logident (getenv ("ZSYS_LOGIDENT")); if (getenv ("ZSYS_LOGSENDER")) zsys_set_logsender (getenv ("ZSYS_LOGSENDER")); return s_process_ctx; } // atexit or manual termination for the process void zsys_shutdown (void) { if (!s_initialized) return; s_initialized = false; // The atexit handler is called when the main function exits; // however we may have zactor threads shutting down and still // trying to close their sockets. So if we suspect there are // actors busy (s_open_sockets > 0), then we sleep for a few // hundred milliseconds to allow the actors, if any, to get in // and close their sockets. ZMUTEX_LOCK (s_mutex); size_t busy = s_open_sockets; ZMUTEX_UNLOCK (s_mutex); if (busy) zclock_sleep (200); // Close logsender socket if opened (don't do this in critical section) if (s_logsender) { zsock_destroy (&s_logsender); } // No matter, we are now going to shut down // Print the source reference for any sockets the app did not // destroy properly. ZMUTEX_LOCK (s_mutex); s_sockref_t *sockref = (s_sockref_t *) zlist_pop (s_sockref_list); while (sockref) { assert (sockref->filename); zsys_error ("dangling '%s' socket created at %s:%d", zsys_sockname (sockref->type), sockref->filename, (int) sockref->line_nbr); zmq_close (sockref->handle); free (sockref); sockref = (s_sockref_t *) zlist_pop (s_sockref_list); } zlist_destroy (&s_sockref_list); ZMUTEX_UNLOCK (s_mutex); if (s_open_sockets == 0) zmq_term (s_process_ctx); else zsys_error ("dangling sockets: cannot terminate ZMQ safely"); ZMUTEX_DESTROY (s_mutex); // Free dynamically allocated properties free (s_interface); free (s_logident); #if defined (__UNIX__) closelog (); // Just to be pedantic #endif } // -------------------------------------------------------------------------- // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. This is for system // use only, really. void * zsys_socket (int type, const char *filename, size_t line_nbr) { // First time initialization; if the application is mixing // its own threading calls with zsock, this may fail if two // threads try to create sockets at the same time. In such // apps, they MUST create a socket in the main program before // starting any threads. If the app uses zactor for its threads // then we can guarantee this to always be safe. zsys_init (); ZMUTEX_LOCK (s_mutex); void *handle = zmq_socket (s_process_ctx, type); if (handle) { // Configure socket with process defaults zsock_set_linger (handle, (int) s_linger); #if (ZMQ_VERSION_MAJOR == 2) // For ZeroMQ/2.x we use sndhwm for both send and receive zsock_set_hwm (handle, s_sndhwm); #else // For later versions we use separate SNDHWM and RCVHWM zsock_set_sndhwm (handle, (int) s_sndhwm); zsock_set_rcvhwm (handle, (int) s_rcvhwm); # if defined (ZMQ_IPV6) zsock_set_ipv6 (handle, s_ipv6); # else zsock_set_ipv4only (handle, s_ipv6? 0: 1); # endif #endif // Add socket to reference tracker so we can report leaks; this is // done only when the caller passes a filename/line_nbr if (filename) { s_sockref_t *sockref = (s_sockref_t *) zmalloc (sizeof (s_sockref_t)); if (sockref) { sockref->handle = handle; sockref->type = type; sockref->filename = filename; sockref->line_nbr = line_nbr; zlist_append (s_sockref_list, sockref); } else { zmq_close (handle); ZMUTEX_UNLOCK (s_mutex); return NULL; } } s_open_sockets++; } ZMUTEX_UNLOCK (s_mutex); return handle; } // -------------------------------------------------------------------------- // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). int zsys_close (void *handle, const char *filename, size_t line_nbr) { ZMUTEX_LOCK (s_mutex); // It's possible atexit() has already happened if we're running under // a debugger that redirects the main thread exit. if (s_sockref_list) { s_sockref_t *sockref = (s_sockref_t *) zlist_first (s_sockref_list); while (sockref) { if (sockref->handle == handle) { zlist_remove (s_sockref_list, sockref); free (sockref); break; } sockref = (s_sockref_t *) zlist_next (s_sockref_list); } } s_open_sockets--; zmq_close (handle); ZMUTEX_UNLOCK (s_mutex); return 0; } // -------------------------------------------------------------------------- // Return ZMQ socket name for socket type char * zsys_sockname (int socktype) { char *type_names [] = { "PAIR", "PUB", "SUB", "REQ", "REP", "DEALER", "ROUTER", "PULL", "PUSH", "XPUB", "XSUB", "STREAM" }; // This array matches ZMQ_XXX type definitions assert (ZMQ_PAIR == 0); #if defined (ZMQ_STREAM) assert (socktype >= 0 && socktype <= ZMQ_STREAM); #else assert (socktype >= 0 && socktype <= ZMQ_XSUB); #endif return type_names [socktype]; } // -------------------------------------------------------------------------- // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. zsock_t * zsys_create_pipe (zsock_t **backend_p) { zsock_t *frontend = zsock_new (ZMQ_PAIR); zsock_t *backend = zsock_new (ZMQ_PAIR); if (!frontend || !backend) { zsock_destroy (&frontend); zsock_destroy (&backend); return frontend; } #if (ZMQ_VERSION_MAJOR == 2) zsock_set_hwm (frontend, zsys_pipehwm ()); zsock_set_hwm (backend, zsys_pipehwm ()); #else zsock_set_sndhwm (frontend, (int) zsys_pipehwm ()); zsock_set_sndhwm (backend, (int) zsys_pipehwm ()); #endif // Now bind and connect pipe ends char endpoint [32]; while (true) { sprintf (endpoint, "inproc://pipe-%04x-%04x", randof (0x10000), randof (0x10000)); if (zsock_bind (frontend, "%s", endpoint) == 0) break; } int rc = zsock_connect (backend, "%s", endpoint); assert (rc != -1); // Connect cannot fail // Return frontend and backend sockets *backend_p = backend; return frontend; } // -------------------------------------------------------------------------- // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void zsys_handler_set (zsys_handler_fn *handler_fn) { if (!handler_fn) { // Disable existing or future signal handling zsys_handler_reset (); s_first_time = false; } else { #if defined (__UNIX__) if (s_first_time) { // If first time, save default handlers sigaction (SIGINT, NULL, &sigint_default); sigaction (SIGTERM, NULL, &sigterm_default); s_first_time = false; } // Install signal handler for SIGINT and SIGTERM struct sigaction action; action.sa_handler = handler_fn; action.sa_flags = 0; sigemptyset (&action.sa_mask); sigaction (SIGINT, &action, NULL); sigaction (SIGTERM, &action, NULL); #elif defined (__WINDOWS__) installed_handler_fn = handler_fn; if (s_first_time) { SetConsoleCtrlHandler (s_handler_fn_shim, TRUE); s_first_time = false; } #else # error "No signal handling defined for this platform" #endif } } // -------------------------------------------------------------------------- // Reset interrupt handler, call this at exit if needed // Idempotent; safe to call multiple times void zsys_handler_reset (void) { #if defined (__UNIX__) // Restore default handlers if not already done if (!s_first_time) { sigaction (SIGINT, &sigint_default, NULL); sigaction (SIGTERM, &sigterm_default, NULL); sigint_default.sa_handler = NULL; sigterm_default.sa_handler = NULL; s_first_time = true; } #elif defined (__WINDOWS__) if (!s_first_time) { SetConsoleCtrlHandler (s_handler_fn_shim, FALSE); installed_handler_fn = NULL; s_first_time = true; } #endif } // -------------------------------------------------------------------------- // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. void zsys_catch_interrupts (void) { zsys_handler_set (s_signal_handler); } // Default internal signal handler static void s_signal_handler (int signal_value) { zctx_interrupted = 1; zsys_interrupted = 1; } // -------------------------------------------------------------------------- // Return true if file exists, else zero bool zsys_file_exists (const char *filename) { assert (filename); return zsys_file_mode (filename) != -1; } // -------------------------------------------------------------------------- // Return size of file, or -1 if not found ssize_t zsys_file_size (const char *filename) { struct stat stat_buf; assert (filename); if (stat ((char *) filename, &stat_buf) == 0) return stat_buf.st_size; else return -1; } // -------------------------------------------------------------------------- // Return file modification time. Returns 0 if the file does not exist. time_t zsys_file_modified (const char *filename) { struct stat stat_buf; if (stat (filename, &stat_buf) == 0) return stat_buf.st_mtime; else return 0; } // -------------------------------------------------------------------------- // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int zsys_file_mode (const char *filename) { #if (defined (__WINDOWS__)) DWORD dwfa = GetFileAttributesA (filename); if (dwfa == 0xffffffff) return -1; dbyte mode = 0; if (dwfa & FILE_ATTRIBUTE_DIRECTORY) mode |= S_IFDIR; else mode |= S_IFREG; if (!(dwfa & FILE_ATTRIBUTE_HIDDEN)) mode |= S_IRUSR; if (!(dwfa & FILE_ATTRIBUTE_READONLY)) mode |= S_IWUSR; return mode; #else struct stat stat_buf; if (stat ((char *) filename, &stat_buf) == 0) return stat_buf.st_mode; else return -1; #endif } // -------------------------------------------------------------------------- // Delete file, return 0 if OK, -1 if not possible. int zsys_file_delete (const char *filename) { assert (filename); #if (defined (__WINDOWS__)) return DeleteFileA (filename)? 0: -1; #else return unlink (filename); #endif } // -------------------------------------------------------------------------- // Check if file is 'stable' bool zsys_file_stable (const char *filename) { struct stat stat_buf; if (stat (filename, &stat_buf) == 0) { // File is 'stable' if more than 1 second old #if (defined (WIN32)) # define EPOCH_DIFFERENCE 11644473600LL long age = (long) (zclock_time () - EPOCH_DIFFERENCE * 1000 - (stat_buf.st_mtime * 1000)); #else long age = (long) (zclock_time () - (stat_buf.st_mtime * 1000)); #endif return (age > 1000); } else return false; // File doesn't exist, so not stable } // -------------------------------------------------------------------------- // Create a file path if it doesn't exist. The file path is treated as a // printf format. int zsys_dir_create (const char *pathname, ...) { va_list argptr; va_start (argptr, pathname); char *formatted = zsys_vprintf (pathname, argptr); va_end (argptr); if (!formatted) return -1; // Create parent directory levels if needed char *slash = strchr (formatted + 1, '/'); while (true) { if (slash) *slash = 0; // Cut at slash int mode = zsys_file_mode (formatted); if (mode == -1) { // Does not exist, try to create it #if (defined (__WINDOWS__)) if (!CreateDirectoryA (formatted, NULL)) { #else if (mkdir (formatted, 0775)) { #endif free (formatted); return -1; // Failed } } else if ((mode & S_IFDIR) == 0) { // Not a directory, abort } if (!slash) // End if last segment break; *slash = '/'; slash = strchr (slash + 1, '/'); } free (formatted); return 0; } // -------------------------------------------------------------------------- // Remove a file path if empty; the pathname is treated as printf format. int zsys_dir_delete (const char *pathname, ...) { va_list argptr; va_start (argptr, pathname); char *formatted = zsys_vprintf (pathname, argptr); va_end (argptr); if (!formatted) return -1; #if (defined (__WINDOWS__)) int rc = RemoveDirectoryA (formatted)? 0: -1; #else int rc = rmdir (formatted); #endif free (formatted); return rc; } // -------------------------------------------------------------------------- // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int zsys_dir_change (const char *pathname) { assert (pathname); #if (defined (__UNIX__)) return chdir (pathname); #elif (defined (__WINDOWS__)) return !SetCurrentDirectoryA (pathname); #endif return -1; // Not implemented } // -------------------------------------------------------------------------- // Set private file creation mode; all files created from here will be // readable/writable by the owner only. #if !defined (__WINDOWS__) static mode_t s_old_mask = 0; #endif void zsys_file_mode_private (void) { #if !defined (__WINDOWS__) s_old_mask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH); #endif } // -------------------------------------------------------------------------- // Reset default file creation mode; all files created from here will use // process file mode defaults. void zsys_file_mode_default (void) { // Reset process file create mask #if !defined (__WINDOWS__) if (s_old_mask) umask (s_old_mask); #endif } // -------------------------------------------------------------------------- // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. void zsys_version (int *major, int *minor, int *patch) { if (major) *major = CZMQ_VERSION_MAJOR; if (minor) *minor = CZMQ_VERSION_MINOR; if (patch) *patch = CZMQ_VERSION_PATCH; } // -------------------------------------------------------------------------- // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_sprintf (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); return (string); } // -------------------------------------------------------------------------- // Format a string with variable arguments, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_vprintf (const char *format, va_list argptr) { int size = 256; char *string = (char *) malloc (size); if (!string) return NULL; // Using argptr is destructive, so we take a copy each time we need it // We define va_copy for Windows in czmq_prelude.h va_list my_argptr; va_copy (my_argptr, argptr); int required = vsnprintf (string, size, format, my_argptr); va_end (my_argptr); #ifdef __WINDOWS__ if (required < 0 || required >= size) { va_copy (my_argptr, argptr); #ifdef _MSC_VER required = _vscprintf (format, argptr); #else required = vsnprintf (NULL, 0, format, argptr); #endif va_end (my_argptr); } #endif // If formatted string cannot fit into small string, reallocate a // larger buffer for it. if (required >= size) { size = required + 1; free (string); string = (char *) malloc (size); if (string) { va_copy (my_argptr, argptr); vsnprintf (string, size, format, my_argptr); va_end (my_argptr); } } return string; } // -------------------------------------------------------------------------- // Create a UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. SOCKET zsys_udp_new (bool routable) { // We haven't implemented multicast yet assert (!routable); SOCKET udpsock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (udpsock == INVALID_SOCKET) { zsys_socket_error ("socket"); return INVALID_SOCKET; } // Ask operating system for broadcast permissions on socket int on = 1; if (setsockopt (udpsock, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof (on)) == SOCKET_ERROR) zsys_socket_error ("setsockopt (SO_BROADCAST)"); // Allow multiple owners to bind to socket; incoming // messages will replicate to each owner if (setsockopt (udpsock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) == SOCKET_ERROR) zsys_socket_error ("setsockopt (SO_REUSEADDR)"); #if defined (SO_REUSEPORT) // On some platforms we have to ask to reuse the port if (setsockopt (udpsock, SOL_SOCKET, SO_REUSEPORT, (char *) &on, sizeof (on)) == SOCKET_ERROR) zsys_socket_error ("setsockopt (SO_REUSEPORT)"); #endif return udpsock; } // -------------------------------------------------------------------------- // Close a UDP socket int zsys_udp_close (SOCKET handle) { #if (defined (__WINDOWS__)) return closesocket (handle); #else return close (handle); #endif } // -------------------------------------------------------------------------- // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address) { assert (frame); assert (address); if (sendto (udpsock, (char *) zframe_data (frame), (int) zframe_size (frame), 0, // Flags (struct sockaddr *) address, (int) sizeof (inaddr_t)) == -1) { zsys_debug ("zsys_udp_send: failed, reason=%s", strerror (errno)); return -1; // UDP broadcast not possible } else return 0; } // -------------------------------------------------------------------------- // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array. zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername) { char buffer [UDP_FRAME_MAX]; inaddr_t address; socklen_t address_len = sizeof (inaddr_t); ssize_t size = recvfrom ( udpsock, buffer, UDP_FRAME_MAX, 0, // Flags (struct sockaddr *) &address, &address_len); if (size == SOCKET_ERROR) zsys_socket_error ("recvfrom"); // Get sender address as printable string #if (defined (__WINDOWS__)) getnameinfo ((struct sockaddr *) &address, address_len, peername, INET_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); #else inet_ntop (AF_INET, &address.sin_addr, peername, address_len); #endif return zframe_new (buffer, size); } // -------------------------------------------------------------------------- // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. void zsys_socket_error (const char *reason) { #if defined (__WINDOWS__) switch (WSAGetLastError ()) { case WSAEINTR: errno = EINTR; break; case WSAEBADF: errno = EBADF; break; case WSAEWOULDBLOCK: errno = EAGAIN; break; case WSAEINPROGRESS: errno = EAGAIN; break; case WSAENETDOWN: errno = ENETDOWN; break; case WSAECONNRESET: errno = ECONNRESET; break; case WSAECONNABORTED: errno = EPIPE; break; case WSAESHUTDOWN: errno = ECONNRESET; break; case WSAEINVAL: errno = EPIPE; break; default: errno = GetLastError (); } #endif if (errno == EAGAIN || errno == ENETDOWN || errno == EHOSTUNREACH || errno == ENETUNREACH || errno == EINTR || errno == EPIPE || errno == ECONNRESET #if defined (ENOPROTOOPT) || errno == ENOPROTOOPT #endif #if defined (EHOSTDOWN) || errno == EHOSTDOWN #endif #if defined (EOPNOTSUPP) || errno == EOPNOTSUPP #endif #if defined (EWOULDBLOCK) || errno == EWOULDBLOCK #endif #if defined (EPROTO) || errno == EPROTO #endif #if defined (ENONET) || errno == ENONET #endif ) return; // Ignore error and try again else { zsys_error ("(UDP) error '%s' on %s", strerror (errno), reason); assert (false); } } // -------------------------------------------------------------------------- // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. char * zsys_hostname (void) { char hostname [NI_MAXHOST]; gethostname (hostname, NI_MAXHOST); hostname [NI_MAXHOST - 1] = 0; struct hostent *host = gethostbyname (hostname); if (host && host->h_name) return strdup (host->h_name); else return NULL; } // -------------------------------------------------------------------------- // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int zsys_daemonize (const char *workdir) { #if (defined (__UNIX__)) // Defines umask for new files this process will create mode_t file_mask = 027; // Complement of 0750 // Recreate our process as a child of init int fork_result = fork (); if (fork_result < 0) // < 0 is an error return -1; // Could not fork else if (fork_result > 0) // > 0 is the parent process exit (0); // End parent process // Move to a safe and known directory, which is supplied as an // argument to this function (or not, if workdir is NULL or empty). if (workdir && zsys_dir_change (workdir)) { zsys_error ("cannot chdir to '%s'", workdir); return -1; } // Close all open file descriptors inherited from the parent // process, to reduce the resources we use int file_handle = sysconf (_SC_OPEN_MAX); while (file_handle) close (file_handle--); // Ignore any errors // Set the umask for new files we might create umask (file_mask); // Set standard input and output to the null device so that any // code that assumes that these files are open will work file_handle = open ("/dev/null", O_RDWR); int fh_stdout = dup (file_handle); int fh_stderr = dup (file_handle); assert (fh_stdout); assert (fh_stderr); // Ignore any hangup signal from the controlling console signal (SIGHUP, SIG_IGN); #endif return 0; } // -------------------------------------------------------------------------- // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int zsys_run_as (const char *lockfile, const char *group, const char *user) { #if (defined (__UNIX__)) // Switch to effective user ID (who owns executable); for // system services this should be root, so that we can write // the PID file into e.g. /var/run/ if (seteuid (geteuid ())) { zsys_error ("cannot set effective user id: %s", strerror (errno)); return -1; } if (lockfile) { // We enforce a lock on the lockfile, if specified, so that // only one copy of the process can run at once. int handle = open (lockfile, O_RDWR | O_CREAT, 0640); if (handle < 0) { zsys_error ("cannot open lockfile '%s': %s", lockfile, strerror (errno)); return -1; } else { struct flock filelock; filelock.l_type = F_WRLCK; // F_RDLCK, F_WRLCK, F_UNLCK filelock.l_whence = SEEK_SET; // SEEK_SET, SEEK_CUR, SEEK_END filelock.l_start = 0; // Offset from l_whence filelock.l_len = 0; // length, 0 = to EOF filelock.l_pid = getpid (); if (fcntl (handle, F_SETLK, &filelock)) { zsys_error ("cannot get lock: %s", strerror (errno)); return -1; } } // We record the current process id in the lock file char pid_buffer [10]; snprintf (pid_buffer, sizeof (pid_buffer), "%6d\n", getpid ()); if (write (handle, pid_buffer, strlen (pid_buffer)) != strlen (pid_buffer)) { zsys_error ("cannot write to lockfile: %s", strerror (errno)); close (handle); return -1; } } if (group) { zsys_info ("running under group '%s'", group); struct group *grpbuf = NULL; grpbuf = getgrnam (group); if (grpbuf == NULL || setgid (grpbuf->gr_gid)) { zsys_error ("could not switch group: %s", strerror (errno)); return -1; } } if (user) { zsys_info ("running under user '%s'", user); struct passwd *pwdbuf = NULL; pwdbuf = getpwnam (user); if (pwdbuf == NULL || setuid (pwdbuf->pw_uid)) { zsys_error ("could not switch user: %s", strerror (errno)); return -1; } } else { // Switch back to real user ID (who started process) if (setuid (getuid ())) { zsys_error ("cannot set real user id: %s", strerror (errno)); return -1; } } return 0; #else // This is not yet ported to Windows and should not succeed there. return -1; #endif } // -------------------------------------------------------------------------- // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool zsys_has_curve (void) { #if defined (ZMQ_CURVE_SERVER) # if defined (ZMQ_HAS_CAPABILITIES) // This is the most modern way of probing libzmq capabilities return zmq_has ("curve") != 0; # else // However trying the zmq_setsockopt will also work int rc = -1; // assume we fail void *ctx = zmq_ctx_new (); if (ctx) { void *pub = zmq_socket (ctx, ZMQ_PUB); if (pub) { int as_server = 1; rc = zmq_setsockopt (pub, ZMQ_CURVE_SERVER, &as_server, sizeof (int)); zmq_close (pub); } zmq_term (ctx); } return rc != -1; # endif #else return false; #endif } // -------------------------------------------------------------------------- // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_io_threads (size_t io_threads) { zsys_init (); ZMUTEX_LOCK (s_mutex); if (s_open_sockets) zsys_error ("zsys_io_threads() is not valid after creating sockets"); assert (s_open_sockets == 0); zmq_term (s_process_ctx); s_io_threads = io_threads; s_process_ctx = zmq_init ((int) s_io_threads); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // TODO: this causes TravisCI to break; libzmq does not return a // valid socket on zmq_socket(), after this... zmq_ctx_set (s_process_ctx, ZMQ_MAX_SOCKETS, (int) s_max_sockets); #endif ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zsys_set_max_sockets (size_t max_sockets) { zsys_init (); ZMUTEX_LOCK (s_mutex); // If the app is misusing this method, burn it with fire if (s_open_sockets) zsys_error ("zsys_max_sockets() is not valid after creating sockets"); assert (s_open_sockets == 0); s_max_sockets = max_sockets? max_sockets: zsys_socket_limit (); ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return maximum number of ZeroMQ sockets that the system will support. size_t zsys_socket_limit (void) { size_t socket_limit; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) if (s_process_ctx) socket_limit = (size_t) zmq_ctx_get (s_process_ctx, ZMQ_SOCKET_LIMIT); else { void *ctx = zmq_init (1); socket_limit = (size_t) zmq_ctx_get (ctx, ZMQ_SOCKET_LIMIT); zmq_term (ctx); } // ZeroMQ used to report a nonsense value (2^31) which if used would // on zmq_ctx_set (ZMQ_MAX_SOCKETS) cause an out-of-memory error. So // if we're running on an older library, enforce a sane limit. if (socket_limit > 65535) socket_limit = 65535; #else socket_limit = 1024; #endif return socket_limit; } // -------------------------------------------------------------------------- // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void zsys_set_linger (size_t linger) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_linger = linger; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_sndhwm (size_t sndhwm) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_sndhwm = sndhwm; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_rcvhwm (size_t rcvhwm) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_rcvhwm = rcvhwm; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void zsys_set_pipehwm (size_t pipehwm) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_pipehwm = pipehwm; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return the HWM for zactor internal pipes. size_t zsys_pipehwm (void) { return s_pipehwm; } // -------------------------------------------------------------------------- // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void zsys_set_ipv6 (int ipv6) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_ipv6 = ipv6; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all interfaces". void zsys_set_interface (const char *value) { zsys_init (); free (s_interface); s_interface = strdup (value); assert (s_interface); } // -------------------------------------------------------------------------- // Return network interface to use for broadcasts, or "" if none was set. const char * zsys_interface (void) { return s_interface? s_interface: ""; } // -------------------------------------------------------------------------- // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zsys_set_logident (const char *value) { zsys_init (); free (s_logident); s_logident = strdup (value); #if defined (__UNIX__) if (s_logsystem) openlog (s_logident, LOG_PID, LOG_USER); #elif defined (__WINDOWS__) // TODO: hook in Windows event log for Windows #endif assert (s_logident); } // -------------------------------------------------------------------------- // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void zsys_set_logstream (FILE *stream) { zsys_init (); s_logstream = stream; } // -------------------------------------------------------------------------- // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zsys_set_logsender (const char *endpoint) { zsys_init (); if (endpoint) { // Create log sender if needed if (!s_logsender) { s_logsender = zsock_new_pub(NULL); assert (s_logsender); } // Bind/connect to specified endpoint(s) using zsock_attach() syntax int rc = zsock_attach (s_logsender, endpoint, true); assert (rc == 0); } else if (s_logsender) { zsock_destroy (&s_logsender); } } // -------------------------------------------------------------------------- // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zsys_set_logsystem (bool logsystem) { zsys_init (); s_logsystem = logsystem; #if defined (__UNIX__) if (s_logsystem) openlog (s_logident, LOG_PID, LOG_USER); #elif defined (__WINDOWS__) // TODO: hook into Windows event log #endif } static void s_log (char loglevel, char *string) { #if defined (__UNIX__) # if defined (__UTYPE_ANDROID) int priority = ANDROID_LOG_INFO; if (loglevel == 'E') priority = ANDROID_LOG_ERROR; else if (loglevel == 'W') priority = ANDROID_LOG_WARN; else if (loglevel == 'N') priority = ANDROID_LOG_INFO; else if (loglevel == 'I') priority = ANDROID_LOG_INFO; else if (loglevel == 'D') priority = ANDROID_LOG_DEBUG; __android_log_print(priority, "zsys", "%s", string); # else if (s_logsystem) { int priority = LOG_INFO; if (loglevel == 'E') priority = LOG_ERR; else if (loglevel == 'W') priority = LOG_WARNING; else if (loglevel == 'N') priority = LOG_NOTICE; else if (loglevel == 'I') priority = LOG_INFO; else if (loglevel == 'D') priority = LOG_DEBUG; syslog (priority, "%s", string); } else # endif #endif // Set s_logstream to stdout by default, unless we're using s_logsystem if (!s_logstream) s_logstream = stdout; if (s_logstream || s_logsender) { time_t curtime = time (NULL); struct tm *loctime = localtime (&curtime); char date [20]; strftime (date, 20, "%y-%m-%d %H:%M:%S", loctime); char log_text [1024]; if (s_logident) snprintf (log_text, 1024, "%c: (%s) %s %s", loglevel, s_logident, date, string); else snprintf (log_text, 1024, "%c: %s %s", loglevel, date, string); if (s_logstream) { fprintf (s_logstream, "%s\n", log_text); fflush (s_logstream); } if (s_logsender) zstr_send (s_logsender, log_text); } } // -------------------------------------------------------------------------- // Log error condition - highest priority void zsys_error (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('E', string); free (string); } // -------------------------------------------------------------------------- // Log warning condition - high priority void zsys_warning (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('W', string); free (string); } // -------------------------------------------------------------------------- // Log normal, but significant, condition - normal priority void zsys_notice (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('N', string); free (string); } // -------------------------------------------------------------------------- // Log informational message - low priority void zsys_info (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('I', string); free (string); } // -------------------------------------------------------------------------- // Log debug-level message - lowest priority void zsys_debug (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('D', string); free (string); } // -------------------------------------------------------------------------- // Selftest void zsys_test (bool verbose) { printf (" * zsys: "); if (verbose) printf ("\n"); // @selftest zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); free (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_io_threads (1); zsys_set_max_sockets (0); zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); // Test pipe creation zsock_t *pipe_back; zsock_t *pipe_front = zsys_create_pipe (&pipe_back); zstr_send (pipe_front, "Hello"); char *string = zstr_recv (pipe_back); assert (streq (string, "Hello")); free (string); zsock_destroy (&pipe_back); zsock_destroy (&pipe_front); // Test file manipulation rc = zsys_file_delete ("nosuchfile"); assert (rc == -1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == -1); time_t when = zsys_file_modified ("."); assert (when > 0); int mode = zsys_file_mode ("."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); zsys_file_mode_private (); rc = zsys_dir_create ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); when = zsys_file_modified ("./.testsys/subdir"); assert (when > 0); assert (!zsys_file_stable ("./.testsys/subdir")); rc = zsys_dir_delete ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", ".", ".testsys"); assert (rc == 0); zsys_file_mode_default (); assert (zsys_dir_change (".") == 0); int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); free (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zmq_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); // @end printf ("OK\n"); } czmq-3.0.2/src/makecert.c0000664000175000017500000000316712505070716014330 0ustar00phph00000000000000/* makecert Certificate generator for ZeroMQ CURVE security. Produces two files: * mycert.txt - public certificate * mycert.txt_secret - secret certificate Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include // Get and store one header in certificate static int s_get_meta (zcert_t *cert, char *prompt, char *name) { printf ("%s ", prompt); char value [256]; if (fgets (value, 256, stdin) == NULL) return -1; if (strlen (value) && value [strlen (value) - 1] == '\n') value [strlen (value) - 1] = 0; if (*value) zcert_set_meta (cert, name, value); return 0; } int main (void) { puts ("Creating new CURVE certificate"); zcert_t *cert = zcert_new (); if (s_get_meta (cert, "Enter your full name:", "name") || s_get_meta (cert, "Enter your email address:", "email") || s_get_meta (cert, "Enter your organization:", "organization")) return -1; char *timestr = zclock_timestr (); zcert_set_meta (cert, "created-by", "CZMQ makecert"); zcert_set_meta (cert, "date-created", timestr); free (timestr); zcert_dump (cert); zcert_save (cert, "mycert.txt"); puts ("I: CURVE certificate created in mycert.txt and mycert.txt_secret"); zcert_destroy (&cert); return 0; } czmq-3.0.2/src/zctx.c0000664000175000017500000002660212505070716013524 0ustar00phph00000000000000/* ========================================================================= zctx - working with 0MQ contexts (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header 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 (interrupt) handling for the process. The zctx class has these main features: * Tracks all open sockets and automatically closes them before calling zmq_term(). This avoids an infinite wait on open sockets. * Automatically configures sockets with a ZMQ_LINGER timeout you can define, and which defaults to zero. The default behavior of zctx is therefore like 0MQ/2.0, immediate termination with loss of any pending messages. You can set any linger timeout you like by calling the zctx_set_linger() method. * Moves the iothreads configuration to a separate method, so that default usage is 1 I/O thread. Lets you configure this value. * Sets up signal (SIGINT and SIGTERM) handling so that blocking calls such as zmq_recv() and zmq_poll() will return when the user presses Ctrl-C. @discuss NOTE: this class is deprecated in favor of zsock, which does not expose contexts in the API at all. All zsock instances use the same global context. @end */ #include "../include/czmq.h" // Structure of our class struct _zctx_t { void *context; // Our 0MQ context zlist_t *sockets; // Sockets held by this thread zmutex_t* mutex; // Make zctx threadsafe bool shadow; // True if this is a shadow context int iothreads; // Number of IO threads, default 1 int linger; // Linger timeout, default 0 int pipehwm; // Send/receive HWM for pipes int sndhwm; // ZMQ_SNDHWM for normal sockets int rcvhwm; // ZMQ_RCVHWM for normal sockets }; // -------------------------------------------------------------------------- // Constructor zctx_t * zctx_new (void) { zctx_t *self = (zctx_t *) zmalloc (sizeof (zctx_t)); if (!self) return NULL; self->sockets = zlist_new (); self->mutex = zmutex_new (); if (!self->sockets || !self->mutex) { zctx_destroy (&self); return NULL; } self->iothreads = 1; self->pipehwm = 1000; self->sndhwm = 1000; self->rcvhwm = 1000; // Catch SIGINT and SIGTERM unless ZSYS_SIGHANDLER=false if (getenv ("ZSYS_SIGHANDLER") == NULL || strneq (getenv ("ZSYS_SIGHANDLER"), "false")) zsys_catch_interrupts (); return self; } // -------------------------------------------------------------------------- // Destructor void zctx_destroy (zctx_t **self_p) { assert (self_p); if (*self_p) { zctx_t *self = *self_p; // Destroy all sockets if (self->sockets) while (zlist_size (self->sockets)) zctx__socket_destroy (self, zlist_first (self->sockets)); zlist_destroy (&self->sockets); zmutex_destroy (&self->mutex); // ZMQ context may not yet be instantiated if (self->context && !self->shadow) zmq_term (self->context); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Create new shadow context, returns context object. Returns NULL if there // wasn't sufficient memory available. zctx_t * zctx_shadow (zctx_t *ctx) { assert (ctx); // Initialize the original context now if necessary if (!ctx->context) { zctx__initialize_underlying (ctx); if (!ctx->context) return NULL; } zctx_t *self = zctx_shadow_zmq_ctx (ctx->context); if (self) { // copy high water marks and linger from old context self->pipehwm = ctx->pipehwm; self->sndhwm = ctx->sndhwm; self->rcvhwm = ctx->rcvhwm; self->linger = ctx->linger; } return self; } // -------------------------------------------------------------------------- // Create new context that shadows the given ZMQ context zctx_t * zctx_shadow_zmq_ctx (void *zmqctx) { assert (zmqctx); // Shares same 0MQ context but has its own list of sockets so that // we create, use, and destroy sockets only within a single thread. zctx_t *self = (zctx_t *) zmalloc (sizeof (zctx_t)); if (!self) return NULL; self->shadow = true; // This is a shadow context self->sockets = zlist_new (); self->mutex = zmutex_new (); if (!self->sockets || !self->mutex) { zctx_destroy (&self); return NULL; } self->context = zmqctx; self->pipehwm = 1000; self->sndhwm = 1000; self->rcvhwm = 1000; return self; } // -------------------------------------------------------------------------- // Configure number of I/O threads in context, only has effect if called // before creating first socket, or calling zctx_shadow. Default I/O // threads is 1, sufficient for all except very high volume applications. void zctx_set_iothreads (zctx_t *self, int iothreads) { assert (self); zmutex_lock (self->mutex); self->iothreads = iothreads; zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Configure linger timeout in msecs. Call this before destroying sockets or // context. Default is no linger, i.e. any pending messages or connects will // be lost. void zctx_set_linger (zctx_t *self, int linger) { assert (self); zmutex_lock (self->mutex); self->linger = linger; zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Set initial high-water mark for inter-thread pipe sockets. Note that // this setting is separate from the default for normal sockets. You // should change the default for pipe sockets *with care*. Too low values // will cause blocked threads, and an infinite setting can cause memory // exhaustion. The default, no matter the underlying ZeroMQ version, is // 1,000. void zctx_set_pipehwm (zctx_t *self, int pipehwm) { assert (self); zmutex_lock (self->mutex); self->pipehwm = pipehwm; zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Set initial send HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. void zctx_set_sndhwm (zctx_t *self, int sndhwm) { assert (self); zmutex_lock (self->mutex); self->sndhwm = sndhwm; zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Set initial receive HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. void zctx_set_rcvhwm (zctx_t *self, int rcvhwm) { assert (self); zmutex_lock (self->mutex); self->rcvhwm = rcvhwm; zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Return low-level 0MQ context object void * zctx_underlying (zctx_t *self) { assert (self); return self->context; } // -------------------------------------------------------------------------- // Initialize the low-level 0MQ context object void zctx__initialize_underlying (zctx_t *self) { assert (self); zmutex_lock (self->mutex); if (!self->context) self->context = zmq_init (self->iothreads); zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Create socket within this context, for CZMQ use only void * zctx__socket_new (zctx_t *self, int type) { // Initialize context now if necessary assert (self); if (!self->context) { zctx__initialize_underlying (self); if (!self->context) return NULL; } // Create and register socket void *zocket = zmq_socket (self->context, type); if (!zocket) return NULL; #if (ZMQ_VERSION_MAJOR == 2) // For ZeroMQ/2.x we use sndhwm for both send and receive zsocket_set_hwm (zocket, self->sndhwm); #else // For later versions we use separate SNDHWM and RCVHWM zsocket_set_sndhwm (zocket, self->sndhwm); zsocket_set_rcvhwm (zocket, self->rcvhwm); #endif zmutex_lock (self->mutex); if (zlist_push (self->sockets, zocket)) { zmutex_unlock (self->mutex); zmq_close (zocket); return NULL; } zmutex_unlock (self->mutex); return zocket; } // -------------------------------------------------------------------------- // Create pipe socket within this context, for CZMQ use only void * zctx__socket_pipe (zctx_t *self) { assert (self); void *pipe = zctx__socket_new (self, ZMQ_PAIR); if (pipe) zsocket_set_hwm (pipe, self->pipehwm); return pipe; } // -------------------------------------------------------------------------- // Destroy socket within this context, for CZMQ use only void zctx__socket_destroy (zctx_t *self, void *zocket) { assert (self); assert (zocket); zsocket_set_linger (zocket, self->linger); zmq_close (zocket); zmutex_lock (self->mutex); zlist_remove (self->sockets, zocket); zmutex_unlock (self->mutex); } // -------------------------------------------------------------------------- // Selftest void zctx_test (bool verbose) { printf (" * zctx (deprecated): "); // @selftest // Create and destroy a context without using it zctx_t *ctx = zctx_new (); assert (ctx); zctx_destroy (&ctx); assert (ctx == NULL); // Create a context with many busy sockets, destroy it ctx = zctx_new (); assert (ctx); zctx_set_iothreads (ctx, 1); zctx_set_linger (ctx, 5); // 5 msecs void *s1 = zctx__socket_new (ctx, ZMQ_PAIR); assert (s1); void *s2 = zctx__socket_new (ctx, ZMQ_XREQ); assert (s2); void *s3 = zctx__socket_new (ctx, ZMQ_REQ); assert (s3); void *s4 = zctx__socket_new (ctx, ZMQ_REP); assert (s4); void *s5 = zctx__socket_new (ctx, ZMQ_PUB); assert (s5); void *s6 = zctx__socket_new (ctx, ZMQ_SUB); assert (s6); int rc = zsocket_connect (s1, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s2, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s3, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s4, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s5, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s6, "tcp://127.0.0.1:5555"); assert (rc == 0); assert (zctx_underlying (ctx)); zctx_destroy (&ctx); // @end printf ("OK\n"); } czmq-3.0.2/src/libczmq.pc.in0000775000175000017500000000155712535241705014770 0ustar00phph00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libczmq Description: The high-level C binding for 0MQ Version: @VERSION@ Requires:libzmq Libs: -L${libdir} -lczmq Cflags: -I${includedir} ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/src/test_zgossip.c0000664000175000017500000001425112505070716015266 0ustar00phph00000000000000#include "../include/czmq.h" void assert_status (zactor_t *actor, int count) { zstr_sendx (actor, "STATUS", NULL); // Get STATUS reply and check it bool ready = false; while (!ready) { char *command, *status; zstr_recvx (actor, &command, &status, NULL); if (streq (command, "STATUS")) { assert (atoi (status) == count); ready = true; } free (command); free (status); } } // Argument, if any, is number of nodes in swarm test int main (int argn, char *argv []) { // Raise theoretical limit on how many ZeroMQ sockets we can create, // though real limit will be set by the process file handle limit. zsys_set_max_sockets (65535); // Test case 1: two servers, bunch of clients. printf ("Starting small test case: "); fflush (stdout); zactor_t *server1 = zactor_new (zgossip, "server1"); assert (server1); zstr_sendx (server1, "SET", "server/animate", "0", NULL); zstr_sendx (server1, "BIND", "inproc://server1", NULL); zactor_t *server2 = zactor_new (zgossip, "server2"); assert (server2); zstr_sendx (server2, "SET", "server/animate", "0", NULL); zstr_sendx (server2, "BIND", "inproc://server2", NULL); zstr_sendx (server2, "CONNECT", "inproc://server1", NULL); zactor_t *client1 = zactor_new (zgossip, "client1"); assert (client1); zstr_sendx (client1, "BIND", "inproc://client1", NULL); zstr_sendx (client1, "PUBLISH", "client1-00", "0000", NULL); zstr_sendx (client1, "PUBLISH", "client1-11", "1111", NULL); zstr_sendx (client1, "PUBLISH", "client1-22", "2222", NULL); zstr_sendx (client1, "CONNECT", "inproc://server1", NULL); zactor_t *client2 = zactor_new (zgossip, "client2"); assert (client2); zstr_sendx (client2, "BIND", "inproc://client2", NULL); zstr_sendx (client2, "CONNECT", "inproc://server1", NULL); zstr_sendx (client2, "PUBLISH", "client2-00", "0000", NULL); zstr_sendx (client2, "PUBLISH", "client2-11", "1111", NULL); zstr_sendx (client2, "PUBLISH", "client2-22", "2222", NULL); zactor_t *client3 = zactor_new (zgossip, "client3"); assert (client3); zstr_sendx (client3, "CONNECT", "inproc://server2", NULL); zactor_t *client4 = zactor_new (zgossip, "client4"); assert (client4); zstr_sendx (client4, "CONNECT", "inproc://server2", NULL); zclock_sleep (100); assert_status (server1, 6); assert_status (server2, 6); assert_status (client1, 6); assert_status (client2, 6); assert_status (client3, 6); assert_status (client4, 6); zactor_destroy (&server1); zactor_destroy (&server2); zactor_destroy (&client1); zactor_destroy (&client2); zactor_destroy (&client3); zactor_destroy (&client4); printf ("OK\n"); // Test case 2: swarm of peers printf ("Starting swarm test case: "); fflush (stdout); // Default limit on file handles is 1024 (POSIX), and fixed setup // costs 8 handles (3 standard I/O plus 5 for CZMQ/libzmq). So the // most nodes we can test by default is (1024 - 8) / 4 = 254. To // test more, run "ulimit -n xxx" beforehand and pass swarm size // as argument to this program. With e.g. Ubuntu, ceiling is 4K // file handles per process, so the largest swarm I've tested is // 1022 nodes. int swarm_size = 254; if (argn >= 2) swarm_size = atoi (argv [1]); printf ("swarm_size=%d ", swarm_size); // The set size defines the total number of properties we spread // across the swarm. By default this is the swarm_size * 5. You can // specify a different set size as second command line argument. int set_size = swarm_size * 5; if (argn >= 3) set_size = atoi (argv [2]); printf ("set_size=%d ", set_size); // Swarm is an array of actors zactor_t *nodes [swarm_size]; // We'll poll all actors for activity (actors act like sockets) zpoller_t *poller = zpoller_new (NULL); assert (poller); // Create swarm uint node_nbr; for (node_nbr = 0; node_nbr < swarm_size; node_nbr++) { nodes [node_nbr] = zactor_new (zgossip, NULL); assert (nodes [node_nbr]); zpoller_add (poller, nodes [node_nbr]); } printf ("."); fflush (stdout); // Interconnect swarm; ever node connects to one arbitrary node to // create a directed graph, then oldest node connects to youngest // node to create a loop, to test we're robust against cycles. for (node_nbr = 0; node_nbr < swarm_size; node_nbr++) { zstr_sendm (nodes [node_nbr], "BIND"); zstr_sendf (nodes [node_nbr], "inproc://swarm-%d", node_nbr); if (node_nbr > 0) { zstr_sendm (nodes [node_nbr], "CONNECT"); zstr_sendf (nodes [node_nbr], "inproc://swarm-%d", randof (node_nbr)); } } zstr_sendm (nodes [0], "CONNECT"); zstr_sendf (nodes [0], "inproc://swarm-%d", node_nbr - 1); printf ("."); fflush (stdout); // Publish the data set randomly across the swarm int item_nbr; for (item_nbr = 0; item_nbr < set_size; item_nbr++) { node_nbr = randof (swarm_size); zstr_sendm (nodes [node_nbr], "PUBLISH"); zstr_sendfm (nodes [node_nbr], "key-%d", item_nbr); zstr_send (nodes [node_nbr], "value"); } printf (". "); fflush (stdout); // Each actor will deliver us tuples; count these until we're done int total = set_size * swarm_size; int pending = total; int64_t ticker = zclock_mono () + 2000; while (pending) { zsock_t *which = (zsock_t *) zpoller_wait (poller, 100); if (!which) { puts (" - stuck test, aborting"); break; } char *command; zstr_recvx (which, &command, NULL); assert (streq (command, "DELIVER")); pending--; free (command); if (zclock_mono () > ticker) { printf ("(%d%%)", (int) ((100 * (total - pending)) / total)); fflush (stdout); ticker = zclock_mono () + 2000; } } // Destroy swarm for (node_nbr = 0; node_nbr < swarm_size; node_nbr++) zactor_destroy (&nodes [node_nbr]); printf ("(100%%) OK\n"); return 0; } czmq-3.0.2/src/zhash_primes.inc0000664000175000017500000002440012505070716015551 0ustar00phph00000000000000/* ========================================================================= zhash_primes.h - 5 largest primes less than 2^n for n = 4...63 Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZHASH_PRIMES_H_INCLUDED__ #define __ZHASH_PRIMES_H_INCLUDED__ #ifdef _MSC_VER # define PORTABLE_LLU(number) number##ULL #else # define PORTABLE_LLU(number) number##LLU #endif static size_t primes [] = { PORTABLE_LLU(3), PORTABLE_LLU(5), PORTABLE_LLU(7), PORTABLE_LLU(11), PORTABLE_LLU(13), // 2^4 PORTABLE_LLU(17), PORTABLE_LLU(19), PORTABLE_LLU(23), PORTABLE_LLU(29), PORTABLE_LLU(31), // 2^5 PORTABLE_LLU(43), PORTABLE_LLU(47), PORTABLE_LLU(53), PORTABLE_LLU(59), PORTABLE_LLU(61), // 2^6 PORTABLE_LLU(103), PORTABLE_LLU(107), PORTABLE_LLU(109), PORTABLE_LLU(113), PORTABLE_LLU(127), // 2^7 PORTABLE_LLU(229), PORTABLE_LLU(233), PORTABLE_LLU(239), PORTABLE_LLU(241), PORTABLE_LLU(251), // 2^8 PORTABLE_LLU(487), PORTABLE_LLU(491), PORTABLE_LLU(499), PORTABLE_LLU(503), PORTABLE_LLU(509), // 2^9 PORTABLE_LLU(997), PORTABLE_LLU(1009), PORTABLE_LLU(1013), PORTABLE_LLU(1019), PORTABLE_LLU(1021), // 2^10 PORTABLE_LLU(2011), PORTABLE_LLU(2017), PORTABLE_LLU(2027), PORTABLE_LLU(2029), PORTABLE_LLU(2039), // 2^11 PORTABLE_LLU(4057), PORTABLE_LLU(4073), PORTABLE_LLU(4079), PORTABLE_LLU(4091), PORTABLE_LLU(4093), // 2^12 PORTABLE_LLU(8161), PORTABLE_LLU(8167), PORTABLE_LLU(8171), PORTABLE_LLU(8179), PORTABLE_LLU(8191), // 2^13 PORTABLE_LLU(16349), PORTABLE_LLU(16361), PORTABLE_LLU(16363), PORTABLE_LLU(16369), PORTABLE_LLU(16381), // 2^14 PORTABLE_LLU(32707), PORTABLE_LLU(32713), PORTABLE_LLU(32717), PORTABLE_LLU(32719), PORTABLE_LLU(32749), // 2^15 PORTABLE_LLU(65449), PORTABLE_LLU(65479), PORTABLE_LLU(65497), PORTABLE_LLU(65519), PORTABLE_LLU(65521), // 2^16 PORTABLE_LLU(131023), PORTABLE_LLU(131041), PORTABLE_LLU(131059), PORTABLE_LLU(131063), PORTABLE_LLU(131071), // 2^17 PORTABLE_LLU(262111), PORTABLE_LLU(262121), PORTABLE_LLU(262127), PORTABLE_LLU(262133), PORTABLE_LLU(262139), // 2^18 PORTABLE_LLU(524243), PORTABLE_LLU(524257), PORTABLE_LLU(524261), PORTABLE_LLU(524269), PORTABLE_LLU(524287), // 2^19 PORTABLE_LLU(1048517), PORTABLE_LLU(1048549), PORTABLE_LLU(1048559), PORTABLE_LLU(1048571), PORTABLE_LLU(1048573), // 2^20 PORTABLE_LLU(2097091), PORTABLE_LLU(2097097), PORTABLE_LLU(2097131), PORTABLE_LLU(2097133), PORTABLE_LLU(2097143), // 2^21 PORTABLE_LLU(4194247), PORTABLE_LLU(4194271), PORTABLE_LLU(4194277), PORTABLE_LLU(4194287), PORTABLE_LLU(4194301), // 2^22 PORTABLE_LLU(8388547), PORTABLE_LLU(8388571), PORTABLE_LLU(8388581), PORTABLE_LLU(8388587), PORTABLE_LLU(8388593), // 2^23 PORTABLE_LLU(16777141), PORTABLE_LLU(16777153), PORTABLE_LLU(16777183), PORTABLE_LLU(16777199), PORTABLE_LLU(16777213), // 2^24 PORTABLE_LLU(33554341), PORTABLE_LLU(33554347), PORTABLE_LLU(33554371), PORTABLE_LLU(33554383), PORTABLE_LLU(33554393), // 2^25 PORTABLE_LLU(67108763), PORTABLE_LLU(67108777), PORTABLE_LLU(67108819), PORTABLE_LLU(67108837), PORTABLE_LLU(67108859), // 2^26 PORTABLE_LLU(134217593), PORTABLE_LLU(134217613), PORTABLE_LLU(134217617), PORTABLE_LLU(134217649), PORTABLE_LLU(134217689), // 2^27 PORTABLE_LLU(268435331), PORTABLE_LLU(268435337), PORTABLE_LLU(268435361), PORTABLE_LLU(268435367), PORTABLE_LLU(268435399), // 2^28 PORTABLE_LLU(536870839), PORTABLE_LLU(536870849), PORTABLE_LLU(536870869), PORTABLE_LLU(536870879), PORTABLE_LLU(536870909), // 2^29 PORTABLE_LLU(1073741719), PORTABLE_LLU(1073741723), PORTABLE_LLU(1073741741), PORTABLE_LLU(1073741783), PORTABLE_LLU(1073741789), // 2^30 PORTABLE_LLU(2147483563), PORTABLE_LLU(2147483579), PORTABLE_LLU(2147483587), PORTABLE_LLU(2147483629), PORTABLE_LLU(2147483647), // 2^31 PORTABLE_LLU(4294967197), PORTABLE_LLU(4294967231), PORTABLE_LLU(4294967279), PORTABLE_LLU(4294967291), PORTABLE_LLU(4294967295), // 2^32 #if __WORDSIZE == 64 PORTABLE_LLU(8589934581), PORTABLE_LLU(8589934585), PORTABLE_LLU(8589934587), PORTABLE_LLU(8589934589), PORTABLE_LLU(8589934591), // 2^33 PORTABLE_LLU(17179869175), PORTABLE_LLU(17179869177), PORTABLE_LLU(17179869179), PORTABLE_LLU(17179869181), PORTABLE_LLU(17179869183), // 2^34 PORTABLE_LLU(34359738359), PORTABLE_LLU(34359738361), PORTABLE_LLU(34359738363), PORTABLE_LLU(34359738365), PORTABLE_LLU(34359738367), // 2^35 PORTABLE_LLU(68719476725), PORTABLE_LLU(68719476727), PORTABLE_LLU(68719476729), PORTABLE_LLU(68719476733), PORTABLE_LLU(68719476735), // 2^36 PORTABLE_LLU(137438953463), PORTABLE_LLU(137438953465), PORTABLE_LLU(137438953467), PORTABLE_LLU(137438953469), PORTABLE_LLU(137438953471), // 2^37 PORTABLE_LLU(274877906935), PORTABLE_LLU(274877906937), PORTABLE_LLU(274877906939), PORTABLE_LLU(274877906941), PORTABLE_LLU(274877906943), // 2^38 PORTABLE_LLU(549755813877), PORTABLE_LLU(549755813879), PORTABLE_LLU(549755813883), PORTABLE_LLU(549755813885), PORTABLE_LLU(549755813887), // 2^39 PORTABLE_LLU(1099511627767), PORTABLE_LLU(1099511627769), PORTABLE_LLU(1099511627771), PORTABLE_LLU(1099511627773), PORTABLE_LLU(1099511627775), // 2^40 PORTABLE_LLU(2199023255543), PORTABLE_LLU(2199023255545), PORTABLE_LLU(2199023255547), PORTABLE_LLU(2199023255549), PORTABLE_LLU(2199023255551), // 2^41 PORTABLE_LLU(4398046511095), PORTABLE_LLU(4398046511097), PORTABLE_LLU(4398046511099), PORTABLE_LLU(4398046511101), PORTABLE_LLU(4398046511103), // 2^42 PORTABLE_LLU(8796093022199), PORTABLE_LLU(8796093022201), PORTABLE_LLU(8796093022203), PORTABLE_LLU(8796093022205), PORTABLE_LLU(8796093022207), // 2^43 PORTABLE_LLU(17592186044407), PORTABLE_LLU(17592186044409), PORTABLE_LLU(17592186044411), PORTABLE_LLU(17592186044413), PORTABLE_LLU(17592186044415), // 2^44 PORTABLE_LLU(35184372088823), PORTABLE_LLU(35184372088825), PORTABLE_LLU(35184372088827), PORTABLE_LLU(35184372088829), PORTABLE_LLU(35184372088831), // 2^45 PORTABLE_LLU(70368744177655), PORTABLE_LLU(70368744177657), PORTABLE_LLU(70368744177659), PORTABLE_LLU(70368744177661), PORTABLE_LLU(70368744177663), // 2^46 PORTABLE_LLU(140737488355319), PORTABLE_LLU(140737488355321), PORTABLE_LLU(140737488355323), PORTABLE_LLU(140737488355325), PORTABLE_LLU(140737488355327), // 2^47 PORTABLE_LLU(281474976710647), PORTABLE_LLU(281474976710649), PORTABLE_LLU(281474976710651), PORTABLE_LLU(281474976710653), PORTABLE_LLU(281474976710655), // 2^48 PORTABLE_LLU(562949953421303), PORTABLE_LLU(562949953421305), PORTABLE_LLU(562949953421307), PORTABLE_LLU(562949953421309), PORTABLE_LLU(562949953421311), // 2^49 PORTABLE_LLU(1125899906842615), PORTABLE_LLU(1125899906842617), PORTABLE_LLU(1125899906842619), PORTABLE_LLU(1125899906842621), PORTABLE_LLU(1125899906842623), // 2^50 PORTABLE_LLU(2251799813685239), PORTABLE_LLU(2251799813685241), PORTABLE_LLU(2251799813685243), PORTABLE_LLU(2251799813685245), PORTABLE_LLU(2251799813685247), // 2^51 PORTABLE_LLU(4503599627370487), PORTABLE_LLU(4503599627370489), PORTABLE_LLU(4503599627370491), PORTABLE_LLU(4503599627370493), PORTABLE_LLU(4503599627370495), // 2^52 PORTABLE_LLU(9007199254740983), PORTABLE_LLU(9007199254740985), PORTABLE_LLU(9007199254740987), PORTABLE_LLU(9007199254740989), PORTABLE_LLU(9007199254740991), // 2^53 PORTABLE_LLU(18014398509481975), PORTABLE_LLU(18014398509481977), PORTABLE_LLU(18014398509481979), PORTABLE_LLU(18014398509481981), PORTABLE_LLU(18014398509481983), // 2^54 PORTABLE_LLU(36028797018963959), PORTABLE_LLU(36028797018963961), PORTABLE_LLU(36028797018963963), PORTABLE_LLU(36028797018963965), PORTABLE_LLU(36028797018963967), // 2^55 PORTABLE_LLU(72057594037927925), PORTABLE_LLU(72057594037927927), PORTABLE_LLU(72057594037927929), PORTABLE_LLU(72057594037927933), PORTABLE_LLU(72057594037927935), // 2^56 PORTABLE_LLU(144115188075855863), PORTABLE_LLU(144115188075855865), PORTABLE_LLU(144115188075855867), PORTABLE_LLU(144115188075855869), PORTABLE_LLU(144115188075855871), // 2^57 PORTABLE_LLU(288230376151711735), PORTABLE_LLU(288230376151711737), PORTABLE_LLU(288230376151711739), PORTABLE_LLU(288230376151711741), PORTABLE_LLU(288230376151711743), // 2^58 PORTABLE_LLU(576460752303423479), PORTABLE_LLU(576460752303423481), PORTABLE_LLU(576460752303423483), PORTABLE_LLU(576460752303423485), PORTABLE_LLU(576460752303423487), // 2^59 PORTABLE_LLU(1152921504606846967), PORTABLE_LLU(1152921504606846969), PORTABLE_LLU(1152921504606846971), PORTABLE_LLU(1152921504606846973), PORTABLE_LLU(1152921504606846975), // 2^60 PORTABLE_LLU(2305843009213693941), PORTABLE_LLU(2305843009213693943), PORTABLE_LLU(2305843009213693945), PORTABLE_LLU(2305843009213693947), PORTABLE_LLU(2305843009213693949), // 2^61 PORTABLE_LLU(4611686018427387895), PORTABLE_LLU(4611686018427387897), PORTABLE_LLU(4611686018427387899), PORTABLE_LLU(4611686018427387901), PORTABLE_LLU(4611686018427387903), // 2^62 PORTABLE_LLU(9223372036854775799), PORTABLE_LLU(9223372036854775801), PORTABLE_LLU(9223372036854775803), PORTABLE_LLU(9223372036854775805), PORTABLE_LLU(9223372036854775807) // 2^63 #endif }; #endif czmq-3.0.2/src/Makemodule-local.am0000664000175000017500000000040412512255240016045 0ustar00phph00000000000000# Project-local changes to auto-generated content # Android-qt requires this special link dependency if ON_ANDROID src_libczmq_la_LIBADD += -llog endif check-py: src/libczmq.la $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py czmq-3.0.2/src/zgossip.c0000664000175000017500000004013412505070716014226 0ustar00phph00000000000000/* ========================================================================= zgossip - decentralized configuration management Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Implements a gossip protocol for decentralized configuration management. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples. Each node re-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state. The current design does not expire tuples. Provides these commands (sent as multipart strings to the actor): * BIND endpoint -- binds the gossip service to specified endpoint * PORT -- returns the last TCP port, if any, used for binding * LOAD configfile -- load configuration from specified file * SET configpath value -- set configuration path = value * SAVE configfile -- save configuration to specified file * CONNECT endpoint -- connect the gossip service to the specified peer * PUBLISH key value -- publish a key/value pair to the gossip cluster * STATUS -- return number of key/value pairs held by gossip service Returns these messages: * PORT number -- reply to PORT command * STATUS number -- reply to STATUS command * DELIVER key value -- new tuple delivered from network @discuss The gossip protocol distributes information around a loosely-connected network of gossip services. The information consists of name/value pairs published by applications at any point in the network. The goal of the gossip protocol is to create eventual consistency between all the using applications. The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery. When used for discovery, the gossip protocol works as an alternative to e.g. UDP beaconing. The gossip network consists of a set of loosely-coupled nodes that exchange tuples. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time. Each node runs the same stack, which is a server-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): http://zguide.zeromq.org/page:all#True-Peer-Connectivity-Harmony-Pattern Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command. The state machine for these connections is in zgossip.xml, and the generated code is in zgossip_engine.inc. Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote. The messages between client and server are defined in zgossip_msg.xml. We built this stack using the zeromq/zproto toolkit. To join the gossip network, a node connects to one or more peers. Each peer acts as a forwarder. This loosely-coupled network can scale to thousands of nodes. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network. The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to. When a node gets a duplicate tuple, it throws it away. When a node gets a new tuple, it stores it, and fowards it as just described. At any point the application can access the node's set of tuples. At present there is no way to expire tuples from the network. The assumptions in this design are: * The data set is slow-changing. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic. @end */ #include "../include/czmq.h" #include "zgossip_msg.h" // --------------------------------------------------------------------- // Forward declarations for the two main classes we use here typedef struct _server_t server_t; typedef struct _client_t client_t; typedef struct _tuple_t tuple_t; // --------------------------------------------------------------------- // This structure defines the context for each running server. Store // whatever properties and structures you need for the server. struct _server_t { // These properties must always be present in the server_t // and are set by the generated engine; do not modify them! zsock_t *pipe; // Actor pipe back to caller zconfig_t *config; // Current loaded configuration // Add any properties you need here zlistx_t *remotes; // Parents, as zsock_t instances zhashx_t *tuples; // Tuples, indexed by key tuple_t *cur_tuple; // Holds current tuple to publish zgossip_msg_t *message; // Message to broadcast }; // --------------------------------------------------------------------- // This structure defines the state for each client connection. It will // be passed to each action in the 'self' argument. struct _client_t { // These properties must always be present in the client_t // and are set by the generated engine; do not modify them! server_t *server; // Reference to parent server zgossip_msg_t *message; // Message in and out }; // --------------------------------------------------------------------- // This structure defines one tuple that we track struct _tuple_t { zhashx_t *container; // Hash table that holds this item char *key; // Tuple key char *value; // Tuple value }; // Callback when we remove a tuple from its container static void tuple_free (void *argument) { tuple_t *self = (tuple_t *) argument; free (self->key); free (self->value); free (self); } // Handle traffic from remotes static int remote_handler (zloop_t *loop, zsock_t *remote, void *argument); // --------------------------------------------------------------------- // Include the generated server engine #include "zgossip_engine.inc" // Allocate properties and structures for a new server instance. // Return 0 if OK, or -1 if there was an error. static int server_initialize (server_t *self) { // Default timeout for clients is one second; the caller can // override this with a SET message. engine_configure (self, "server/timeout", "1000"); self->message = zgossip_msg_new (); self->remotes = zlistx_new (); assert (self->remotes); zlistx_set_destructor (self->remotes, (czmq_destructor *) zsock_destroy); self->tuples = zhashx_new (); assert (self->tuples); return 0; } // Free properties and structures for a server instance static void server_terminate (server_t *self) { zgossip_msg_destroy (&self->message); zlistx_destroy (&self->remotes); zhashx_destroy (&self->tuples); } // Connect to a remote server static void server_connect (server_t *self, const char *endpoint) { zsock_t *remote = zsock_new (ZMQ_DEALER); assert (remote); // No recovery if exhausted // Never block on sending; we use an infinite HWM and buffer as many // messages as needed in outgoing pipes. Note that the maximum number // is the overall tuple set size. zsock_set_unbounded (remote); if (zsock_connect (remote, "%s", endpoint)) { zsys_warning ("bad zgossip endpoint '%s'", endpoint); zsock_destroy (&remote); return; } // Send HELLO and then PUBLISH for each tuple we have zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_set_id (gossip, ZGOSSIP_MSG_HELLO); zgossip_msg_send (gossip, remote); tuple_t *tuple = (tuple_t *) zhashx_first (self->tuples); while (tuple) { zgossip_msg_set_id (gossip, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_key (gossip, tuple->key); zgossip_msg_set_value (gossip, tuple->value); zgossip_msg_send (gossip, remote); tuple = (tuple_t *) zhashx_next (self->tuples); } // Now monitor this remote for incoming messages zgossip_msg_destroy (&gossip); engine_handle_socket (self, remote, remote_handler); zlistx_add_end (self->remotes, remote); } // Process an incoming tuple on this server. static void server_accept (server_t *self, const char *key, const char *value) { tuple_t *tuple = (tuple_t *) zhashx_lookup (self->tuples, key); if (tuple && streq (tuple->value, value)) return; // Duplicate tuple, do nothing // Create new tuple tuple = (tuple_t *) zmalloc (sizeof (tuple_t)); assert (tuple); tuple->container = self->tuples; tuple->key = strdup (key); tuple->value = strdup (value); // Store new tuple zhashx_update (tuple->container, key, tuple); zhashx_freefn (tuple->container, key, tuple_free); // Deliver to calling application zstr_sendx (self->pipe, "DELIVER", key, value, NULL); // Hold in server context so we can broadcast to all clients self->cur_tuple = tuple; engine_broadcast_event (self, NULL, forward_event); // Copy new tuple announcement to all remotes zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_set_id (gossip, ZGOSSIP_MSG_PUBLISH); zsock_t *remote = (zsock_t *) zlistx_first (self->remotes); while (remote) { zgossip_msg_set_key (gossip, tuple->key); zgossip_msg_set_value (gossip, tuple->value); zgossip_msg_send (gossip, remote); remote = (zsock_t *) zlistx_next (self->remotes); } zgossip_msg_destroy (&gossip); } // Process server API method, return reply message if any static zmsg_t * server_method (server_t *self, const char *method, zmsg_t *msg) { // Connect to a remote zmsg_t *reply = NULL; if (streq (method, "CONNECT")) { char *endpoint = zmsg_popstr (msg); assert (endpoint); server_connect (self, endpoint); zstr_free (&endpoint); } else if (streq (method, "PUBLISH")) { char *key = zmsg_popstr (msg); char *value = zmsg_popstr (msg); server_accept (self, key, value); zstr_free (&key); zstr_free (&value); } else if (streq (method, "STATUS")) { // Return number of tuples we have stored reply = zmsg_new (); assert (reply); zmsg_addstr (reply, "STATUS"); zmsg_addstrf (reply, "%d", (int) zhashx_size (self->tuples)); } else zsys_error ("unknown zgossip method '%s'", method); return reply; } // Allocate properties and structures for a new client connection and // optionally engine_set_next_event (). Return 0 if OK, or -1 on error. static int client_initialize (client_t *self) { // Construct properties here return 0; } // Free properties and structures for a client connection static void client_terminate (client_t *self) { // Destroy properties here } // -------------------------------------------------------------------------- // get_first_tuple // static void get_first_tuple (client_t *self) { tuple_t *tuple = (tuple_t *) zhashx_first (self->server->tuples); if (tuple) { zgossip_msg_set_key (self->message, tuple->key); zgossip_msg_set_value (self->message, tuple->value); engine_set_next_event (self, ok_event); } else engine_set_next_event (self, finished_event); } // -------------------------------------------------------------------------- // get_next_tuple // static void get_next_tuple (client_t *self) { tuple_t *tuple = (tuple_t *) zhashx_next (self->server->tuples); if (tuple) { zgossip_msg_set_key (self->message, tuple->key); zgossip_msg_set_value (self->message, tuple->value); engine_set_next_event (self, ok_event); } else engine_set_next_event (self, finished_event); } // -------------------------------------------------------------------------- // store_tuple_if_new // static void store_tuple_if_new (client_t *self) { server_accept (self->server, zgossip_msg_key (self->message), zgossip_msg_value (self->message)); } // -------------------------------------------------------------------------- // get_tuple_to_forward // static void get_tuple_to_forward (client_t *self) { // Hold this in server->cur_tuple so it's available to all // clients; the whole broadcast operation happens in one thread // so there's no risk of confusion here. tuple_t *tuple = self->server->cur_tuple; zgossip_msg_set_key (self->message, tuple->key); zgossip_msg_set_value (self->message, tuple->value); } // -------------------------------------------------------------------------- // Handle messages coming from remotes static int remote_handler (zloop_t *loop, zsock_t *remote, void *argument) { server_t *self = (server_t *) argument; if (zgossip_msg_recv (self->message, remote)) return -1; // Interrupted if (zgossip_msg_id (self->message) == ZGOSSIP_MSG_PUBLISH) server_accept (self, zgossip_msg_key (self->message), zgossip_msg_value (self->message)); else if (zgossip_msg_id (self->message) == ZGOSSIP_MSG_INVALID) { // Connection was reset, so send HELLO again zgossip_msg_set_id (self->message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (self->message, remote); } else if (zgossip_msg_id (self->message) == ZGOSSIP_MSG_PONG) assert (true); // Do nothing with PONGs return 0; } // -------------------------------------------------------------------------- // Selftest void zgossip_test (bool verbose) { printf (" * zgossip: "); if (verbose) printf ("\n"); // @selftest // Test basic client-to-server operation of the protocol zactor_t *server = zactor_new (zgossip, "server"); assert (server); if (verbose) zstr_send (server, "VERBOSE"); zstr_sendx (server, "BIND", "inproc://zgossip", NULL); zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zsock_set_rcvtimeo (client, 2000); int rc = zsock_connect (client, "inproc://zgossip"); assert (rc == 0); // Send HELLO, which gets no message zgossip_msg_t *message = zgossip_msg_new (); zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (message, client); // Send PING, expect PONG back zgossip_msg_set_id (message, ZGOSSIP_MSG_PING); zgossip_msg_send (message, client); zgossip_msg_recv (message, client); assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG); zgossip_msg_destroy (&message); zactor_destroy (&server); zsock_destroy (&client); // Test peer-to-peer operations zactor_t *base = zactor_new (zgossip, "base"); assert (base); if (verbose) zstr_send (base, "VERBOSE"); // Set a 100msec timeout on clients so we can test expiry zstr_sendx (base, "SET", "server/timeout", "100", NULL); zstr_sendx (base, "BIND", "inproc://base", NULL); zactor_t *alpha = zactor_new (zgossip, "alpha"); assert (alpha); zstr_sendx (alpha, "CONNECT", "inproc://base", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-1", "service1", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-2", "service2", NULL); zactor_t *beta = zactor_new (zgossip, "beta"); assert (beta); zstr_sendx (beta, "CONNECT", "inproc://base", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-1", "service1", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-2", "service2", NULL); // got nothing zclock_sleep (200); zactor_destroy (&base); zactor_destroy (&alpha); zactor_destroy (&beta); // @end printf ("OK\n"); } czmq-3.0.2/src/zclass_example.xml0000664000175000017500000002327512505070716016127 0ustar00phph00000000000000 czmq-3.0.2/src/zrex.c0000664000175000017500000002334412533666571013537 0ustar00phph00000000000000/* ========================================================================= zrex - work with regular expressions Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Wraps a very simple regular expression library (SLRE) as a CZMQ class. Supports this syntax: ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ @discuss @end */ #include "../include/czmq.h" #include "foreign/slre/slre.inc_c" #define MAX_HITS 100 // Should be enough for anyone :) // Structure of our class struct _zrex_t { struct slre slre; // Compiled regular expression bool valid; // Is expression valid or not? const char *strerror; // Error message if any uint hits; // Number of hits matched size_t hit_set_len; // Length of hit set char *hit_set; // Captured hits as single string char *hit [MAX_HITS]; // Pointers into hit_set struct cap caps [MAX_HITS]; // Position/length for each hit }; // -------------------------------------------------------------------------- // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. zrex_t * zrex_new (const char *expression) { zrex_t *self = (zrex_t *) zmalloc (sizeof (zrex_t)); if (self) { self->strerror = "No error"; if (expression) { // Returns 1 on success, 0 on failure self->valid = (slre_compile (&self->slre, expression) == 1); if (!self->valid) self->strerror = self->slre.err_str; assert (self->slre.num_caps < MAX_HITS); } } return self; } // -------------------------------------------------------------------------- // Destructor void zrex_destroy (zrex_t **self_p) { assert (self_p); if (*self_p) { zrex_t *self = *self_p; zstr_free (&self->hit_set); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return true if the expression was valid and compiled without errors. bool zrex_valid (zrex_t *self) { assert (self); return self->valid; } // -------------------------------------------------------------------------- // Return the error message generated during compilation of the expression. const char * zrex_strerror (zrex_t *self) { assert (self); return self->strerror; } // -------------------------------------------------------------------------- // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. bool zrex_matches (zrex_t *self, const char *text) { assert (self); assert (text); // Free any previously-allocated hits self->hits = 0; bool matches = slre_match (&self->slre, text, strlen (text), self->caps) != 0; if (matches) { // Count number of captures plus whole string self->hits = self->slre.num_caps + 1; if (self->hits > MAX_HITS) self->hits = MAX_HITS; // Collect hits and prepare hit array, which is a single block of // memory holding all hits as null-terminated strings uint index; // First count total length of hit strings size_t hit_set_len = 0; for (index = 0; index < self->hits; index++) hit_set_len += self->caps [index].len + 1; if (hit_set_len > self->hit_set_len) { zstr_free (&self->hit_set); self->hit_set = (char *) zmalloc (hit_set_len); self->hit_set_len = hit_set_len; } // FIXME: no way to return an error assert (self->hit_set); // Now prepare hit strings for access by caller char *hit_set_ptr = self->hit_set; for (index = 0; index < self->hits; index++) { memcpy (hit_set_ptr, self->caps [index].ptr, self->caps [index].len); self->hit [index] = hit_set_ptr; hit_set_ptr += self->caps [index].len + 1; } } return matches; } // -------------------------------------------------------------------------- // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. bool zrex_eq (zrex_t *self, const char *text, const char *expression) { assert (self); assert (text); assert (expression); // Compile the new expression self->valid = (slre_compile (&self->slre, expression) == 1); if (!self->valid) self->strerror = self->slre.err_str; assert (self->slre.num_caps < MAX_HITS); // zrex_matches takes care of the rest for us if (self->valid) return zrex_matches (self, text); else return false; } // -------------------------------------------------------------------------- // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). int zrex_hits (zrex_t *self) { assert (self); return self->hits; } // -------------------------------------------------------------------------- // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. const char * zrex_hit (zrex_t *self, uint index) { assert (self); if (index < self->hits) return self->hit [index]; else return NULL; } // -------------------------------------------------------------------------- // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. int zrex_fetch (zrex_t *self, const char **string_p, ...) { assert (self); va_list args; va_start (args, string_p); uint index = 0; while (string_p) { *string_p = zrex_hit (self, ++index); string_p = va_arg (args, const char **); } va_end (args); return index; } // -------------------------------------------------------------------------- // Selftest void zrex_test (bool verbose) { printf (" * zrex: "); // @selftest // This shows the pattern of matching many lines to a single pattern zrex_t *rex = zrex_new ("\\d+-\\d+-\\d+"); assert (rex); assert (zrex_valid (rex)); bool matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 1); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (zrex_hit (rex, 1) == NULL); zrex_destroy (&rex); // Here we pick out hits using capture groups rex = zrex_new ("(\\d+)-(\\d+)-(\\d+)"); assert (rex); assert (zrex_valid (rex)); matches = zrex_matches (rex, "123-456-ABC"); assert (!matches); matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 4); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (streq (zrex_hit (rex, 1), "123")); assert (streq (zrex_hit (rex, 2), "456")); assert (streq (zrex_hit (rex, 3), "789")); zrex_destroy (&rex); // This shows the pattern of matching one line against many // patterns and then handling the case when it hits rex = zrex_new (NULL); // No initial pattern assert (rex); char *input = "Mechanism: CURVE"; matches = zrex_eq (rex, input, "Version: (.+)"); assert (!matches); assert (zrex_hits (rex) == 0); matches = zrex_eq (rex, input, "Mechanism: (.+)"); assert (matches); assert (zrex_hits (rex) == 2); const char *mechanism; zrex_fetch (rex, &mechanism, NULL); assert (streq (zrex_hit (rex, 1), "CURVE")); assert (streq (mechanism, "CURVE")); zrex_destroy (&rex); // @end printf ("OK\n"); } czmq-3.0.2/src/zproxy_v2.c0000664000175000017500000002312312505070716014511 0ustar00phph00000000000000/* ========================================================================= zproxy_v2 - run a steerable proxy in the background (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zproxy class provides an equivalent to the ZMQ steerable proxy, on all versions of ZeroMQ. @discuss This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zproxy interface, based on zactor, together with the zsock class for sockets. @end */ #include "platform.h" #include "../include/czmq.h" // The proxy runs in a background thread static void s_proxy_task (void *args, zctx_t *ctx, void *pipe); // Structure of our class; note that this structure is shared between // the API thread and the proxy task. struct _zproxy_t { zctx_t *ctx; // Context, allows inproc capture void *pipe; // Pipe used by API thread void *frontend; // Frontend socket for proxy switching void *backend; // Backend socket for proxy switching }; // -------------------------------------------------------------------------- // Constructor // Create a new zproxy object. You must create the frontend and backend // sockets, configure them, and connect or bind them, before you pass them // to the constructor. Do NOT use the sockets again, after passing them to // this method. zproxy_t * zproxy_new (zctx_t *ctx, void *frontend, void *backend) { assert (ctx); zproxy_t *self = (zproxy_t *) zmalloc (sizeof (zproxy_t)); if (self) { self->ctx = ctx; self->frontend = frontend; self->backend = backend; self->pipe = zthread_fork (ctx, s_proxy_task, self); if (self->pipe) zsocket_wait (self->pipe); else { // If we ran out of sockets, signal failure to caller zproxy_destroy (&self); } } return self; } // -------------------------------------------------------------------------- // Destroy a zproxy object; note this first stops the proxy. void zproxy_destroy (zproxy_t **self_p) { assert (self_p); if (*self_p) { zproxy_t *self = *self_p; if (self->pipe) { zstr_send (self->pipe, "STOP"); zsocket_wait (self->pipe); } free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Copy all proxied messages to specified endpoint; if this is NULL, any // in-progress capturing will be stopped. You must already have bound the // endpoint to a PULL socket. void zproxy_capture (zproxy_t *self, const char *endpoint) { assert (self); zstr_sendm (self->pipe, "CAPTURE"); zstr_send (self->pipe, endpoint); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Pauses a zproxy object; a paused proxy will cease processing messages, // causing them to be queued up and potentially hit the high-water mark on // the frontend socket, causing messages to be dropped, or writing // applications to block. void zproxy_pause (zproxy_t *self) { assert (self); zstr_send (self->pipe, "PAUSE"); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Resume a zproxy object void zproxy_resume (zproxy_t *self) { assert (self); zstr_send (self->pipe, "RESUME"); zsocket_wait (self->pipe); } // -------------------------------------------------------------------------- // Backend proxy task static void s_proxy_task (void *args, zctx_t *ctx, void *command_pipe) { // Confirm to API that we've started up zsocket_signal (command_pipe); zproxy_t *self = (zproxy_t *) args; // Capture socket, if not NULL, receives all data void *capture = NULL; // Create poller to work on all three sockets zpoller_t *poller = zpoller_new (self->frontend, self->backend, command_pipe, NULL); assert (poller); bool stopped = false; while (!stopped) { // Wait for activity on any polled socket, and read incoming message void *which = zpoller_wait (poller, -1); zmq_msg_t msg; zmq_msg_init (&msg); int send_flags; // Flags for outgoing message if (which && zmq_recvmsg (which, &msg, 0) != -1) { send_flags = zsocket_rcvmore (which) ? ZMQ_SNDMORE : 0; if (which == self->frontend || which == self->backend) { void *output = which == self->frontend ? self->backend : self->frontend; // Loop on all waiting messages, since polling adds a // non-trivial cost per message, especially on OS/X while (true) { if (capture) { zmq_msg_t dup; zmq_msg_init (&dup); zmq_msg_copy (&dup, &msg); if (zmq_sendmsg (capture, &dup, send_flags) == -1) zmq_msg_close (&dup); } if (zmq_sendmsg (output, &msg, send_flags) == -1) { zmq_msg_close (&msg); break; } if (zmq_recvmsg (which, &msg, ZMQ_DONTWAIT) == -1) break; // Presumably EAGAIN send_flags = zsocket_rcvmore (which) ? ZMQ_SNDMORE : 0; } } else if (which == command_pipe) { char command [10] = { 0 }; assert (zmq_msg_size (&msg) < 10); memcpy (command, zmq_msg_data (&msg), zmq_msg_size (&msg)); // Execute API command if (streq (command, "PAUSE")) { zpoller_destroy (&poller); poller = zpoller_new (command_pipe, NULL); assert (poller); } else if (streq (command, "RESUME")) { zpoller_destroy (&poller); poller = zpoller_new (self->frontend, self->backend, command_pipe, NULL); assert (poller); } else if (streq (command, "CAPTURE")) { // Capture flow is always PUSH-to-PULL capture = zsocket_new (self->ctx, ZMQ_PUSH); char *endpoint = zstr_recv (command_pipe); assert (endpoint); if (capture) { int rc = zsocket_connect (capture, "%s", endpoint); assert (rc == 0); } zstr_free (&endpoint); } else if (streq (command, "STOP")) stopped = true; else assert (0); // Cannot happen, so die // Signal to caller that we processed the command zsocket_signal (command_pipe); } else assert (0); // Cannot happen, so die } else break; // Interrupted } zpoller_destroy (&poller); } // -------------------------------------------------------------------------- // Selftest void zproxy_v2_test (bool verbose) { printf (" * zproxy (deprecated): "); if (verbose) printf ("\n"); // @selftest zctx_t *ctx = zctx_new (); assert (ctx); void *frontend = zsocket_new (ctx, ZMQ_PULL); assert (frontend); int rc = zsocket_bind (frontend, "inproc://frontend"); assert (rc == 0); void *backend = zsocket_new (ctx, ZMQ_PUSH); assert (backend); rc = zsocket_bind (backend, "inproc://backend"); assert (rc == 0); zproxy_t *proxy = zproxy_new (ctx, frontend, backend); assert (proxy); // Connect application sockets to proxy void *faucet = zsocket_new (ctx, ZMQ_PUSH); assert (faucet); rc = zsocket_connect (faucet, "inproc://frontend"); assert (rc == 0); void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); rc = zsocket_connect (sink, "inproc://backend"); assert (rc == 0); // Send some messages and check they arrived zstr_send (faucet, "Hello"); char *string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); // Check pause/resume functionality zproxy_pause (proxy); zstr_send (faucet, "World"); zproxy_resume (proxy); string = zstr_recv (sink); assert (streq (string, "World")); zstr_free (&string); // Create capture socket, must be a PULL socket void *capture = zsocket_new (ctx, ZMQ_PULL); assert (capture); rc = zsocket_bind (capture, "inproc://capture"); assert (rc == 0); // Switch on capturing, check that it works zproxy_capture (proxy, "inproc://capture"); zstr_send (faucet, "Hello"); string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); string = zstr_recv (capture); assert (streq (string, "Hello")); zstr_free (&string); zproxy_destroy (&proxy); zctx_destroy (&ctx); // @end printf ("OK\n"); } czmq-3.0.2/src/zframe.c0000664000175000017500000003515512531076025014021 0ustar00phph00000000000000/* ========================================================================= zframe - working with single message frames Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zframe class provides methods to send and receive single message frames across 0MQ sockets. A 'frame' corresponds to one zmq_msg_t. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times. Frames are binary, and this class has no special support for text data. @discuss @end */ #include "../include/czmq.h" // zframe_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZFRAME_TAG 0x0002cafe // Structure of our class struct _zframe_t { uint32_t tag; // Object tag for runtime detection zmq_msg_t zmsg; // zmq_msg_t blob for frame int more; // More flag, from last read }; // -------------------------------------------------------------------------- // Constructor; if size is >0, allocates frame with that size, and if data // is not null, copies data into frame. zframe_t * zframe_new (const void *data, size_t size) { zframe_t *self = (zframe_t *) zmalloc (sizeof (zframe_t)); if (self) { self->tag = ZFRAME_TAG; if (size) { zmq_msg_init_size (&self->zmsg, size); if (data) memcpy (zmq_msg_data (&self->zmsg), data, size); } else zmq_msg_init (&self->zmsg); } return self; } // -------------------------------------------------------------------------- // Create an empty (zero-sized) frame. The caller is responsible for // destroying the return value when finished with it. zframe_t * zframe_new_empty (void) { zframe_t *self = (zframe_t *) zmalloc (sizeof (zframe_t)); if (self) { self->tag = ZFRAME_TAG; zmq_msg_init (&self->zmsg); } return self; } // -------------------------------------------------------------------------- // Destructor void zframe_destroy (zframe_t **self_p) { assert (self_p); if (*self_p) { zframe_t *self = *self_p; assert (zframe_is (self)); zmq_msg_close (&self->zmsg); self->tag = 0xDeadBeef; free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Create a frame with a specified string content. // The caller is responsible for destroying the return value when finished with it. zframe_t * zframe_from (const char *string) { return zframe_new (string, strlen (string)); } // -------------------------------------------------------------------------- // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. zframe_t * zframe_recv (void *source) { assert (source); void *handle = zsock_resolve (source); zframe_t *self = zframe_new (NULL, 0); if (self) { if (zmq_recvmsg (handle, &self->zmsg, 0) < 0) { zframe_destroy (&self); return NULL; // Interrupted or terminated } self->more = zsock_rcvmore (handle); } return self; } // -------------------------------------------------------------------------- // Send frame to socket, destroy after sending unless ZFRAME_REUSE is // set or the attempt to send the message errors out. int zframe_send (zframe_t **self_p, void *dest, int flags) { assert (dest); assert (self_p); void *handle = zsock_resolve (dest); if (*self_p) { zframe_t *self = *self_p; assert (zframe_is (self)); int send_flags = (flags & ZFRAME_MORE)? ZMQ_SNDMORE: 0; send_flags |= (flags & ZFRAME_DONTWAIT)? ZMQ_DONTWAIT: 0; if (flags & ZFRAME_REUSE) { zmq_msg_t copy; zmq_msg_init (©); if (zmq_msg_copy (©, &self->zmsg)) return -1; if (zmq_sendmsg (handle, ©, send_flags) == -1) { zmq_msg_close (©); return -1; } } else { if (zmq_sendmsg (handle, &self->zmsg, send_flags) >= 0) zframe_destroy (self_p); else return -1; } } return 0; } // -------------------------------------------------------------------------- // Return size of frame. size_t zframe_size (zframe_t *self) { assert (self); assert (zframe_is (self)); return zmq_msg_size (&self->zmsg); } // -------------------------------------------------------------------------- // Return pointer to frame data. byte * zframe_data (zframe_t *self) { assert (self); assert (zframe_is (self)); return (byte *) zmq_msg_data (&self->zmsg); } // -------------------------------------------------------------------------- // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. zframe_t * zframe_dup (zframe_t *self) { if (self) { assert (zframe_is (self)); return zframe_new (zframe_data (self), zframe_size (self)); } else return NULL; } // -------------------------------------------------------------------------- // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. char * zframe_strhex (zframe_t *self) { assert (self); assert (zframe_is (self)); static const char hex_char [] = "0123456789ABCDEF"; size_t size = zframe_size (self); byte *data = zframe_data (self); char *hex_str = (char *) zmalloc (size * 2 + 1); if (!hex_str) return NULL; uint byte_nbr; for (byte_nbr = 0; byte_nbr < size; byte_nbr++) { hex_str [byte_nbr * 2 + 0] = hex_char [data [byte_nbr] >> 4]; hex_str [byte_nbr * 2 + 1] = hex_char [data [byte_nbr] & 15]; } hex_str [size * 2] = 0; return hex_str; } // -------------------------------------------------------------------------- // Return frame data copied into freshly allocated string // Caller must free string when finished with it. char * zframe_strdup (zframe_t *self) { assert (self); assert (zframe_is (self)); size_t size = zframe_size (self); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zframe_data (self), size); string [size] = 0; } return string; } // -------------------------------------------------------------------------- // Return true if frame body is equal to string, excluding terminator bool zframe_streq (zframe_t *self, const char *string) { assert (self); assert (zframe_is (self)); if (zframe_size (self) == strlen (string) && memcmp (zframe_data (self), string, strlen (string)) == 0) return true; else return false; } // -------------------------------------------------------------------------- // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method. int zframe_more (zframe_t *self) { assert (self); assert (zframe_is (self)); return self->more; } // -------------------------------------------------------------------------- // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void zframe_set_more (zframe_t *self, int more) { assert (self); assert (zframe_is (self)); assert (more == 0 || more == 1); self->more = more; } // -------------------------------------------------------------------------- // Return true if two frames have identical size and data bool zframe_eq (zframe_t *self, zframe_t *other) { if (!self || !other) return false; // Tolerate null references here else { assert (zframe_is (self)); assert (zframe_is (other)); if (zframe_size (self) == zframe_size (other) && memcmp (zframe_data (self), zframe_data (other), zframe_size (self)) == 0) return true; else return false; } } // -------------------------------------------------------------------------- // Set new contents for frame void zframe_reset (zframe_t *self, const void *data, size_t size) { assert (self); assert (zframe_is (self)); assert (data); zmq_msg_close (&self->zmsg); zmq_msg_init_size (&self->zmsg, size); memcpy (zmq_msg_data (&self->zmsg), data, size); } // -------------------------------------------------------------------------- // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void zframe_print (zframe_t *self, const char *prefix) { assert (self); assert (zframe_is (self)); byte *data = zframe_data (self); size_t size = zframe_size (self); // Probe data to check if it looks like unprintable binary int is_bin = 0; uint char_nbr; for (char_nbr = 0; char_nbr < size; char_nbr++) if (data [char_nbr] < 9 || data [char_nbr] > 127) is_bin = 1; char buffer [256] = ""; snprintf (buffer, 30, "%s[%03d] ", prefix? prefix: "", (int) size); size_t max_size = is_bin? 35: 70; const char *ellipsis = ""; if (size > max_size) { size = max_size; ellipsis = "..."; } for (char_nbr = 0; char_nbr < size; char_nbr++) { if (is_bin) sprintf (buffer + strlen (buffer), "%02X", (unsigned char) data [char_nbr]); else sprintf (buffer + strlen (buffer), "%c", data [char_nbr]); } strcat (buffer, ellipsis); zsys_debug (buffer); } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zframe_t. bool zframe_is (void *self) { assert (self); return ((zframe_t *) self)->tag == ZFRAME_TAG; } // -------------------------------------------------------------------------- // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive a new frame off the socket. Returns newly allocated frame, or // NULL if there was no input waiting, or if the read was interrupted. zframe_t * zframe_recv_nowait (void *source) { assert (source); void *handle = zsock_resolve (source); zframe_t *self = zframe_new (NULL, 0); if (self) { if (zmq_recvmsg (handle, &self->zmsg, ZMQ_DONTWAIT) < 0) { zframe_destroy (&self); return NULL; // Interrupted or terminated } self->more = zsock_rcvmore (handle); } return self; } // -------------------------------------------------------------------------- // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Print contents of frame to FILE stream, prefix is ignored if null. void zframe_fprint (zframe_t *self, const char *prefix, FILE *file) { assert (self); assert (zframe_is (self)); if (prefix) fprintf (file, "%s", prefix); byte *data = zframe_data (self); size_t size = zframe_size (self); int is_bin = 0; uint char_nbr; for (char_nbr = 0; char_nbr < size; char_nbr++) if (data [char_nbr] < 9 || data [char_nbr] > 127) is_bin = 1; fprintf (file, "[%03d] ", (int) size); size_t max_size = is_bin? 35: 70; const char *ellipsis = ""; if (size > max_size) { size = max_size; ellipsis = "..."; } for (char_nbr = 0; char_nbr < size; char_nbr++) { if (is_bin) fprintf (file, "%02X", (unsigned char) data [char_nbr]); else fprintf (file, "%c", data [char_nbr]); } fprintf (file, "%s\n", ellipsis); } // -------------------------------------------------------------------------- // Selftest void zframe_test (bool verbose) { printf (" * zframe: "); int rc; zframe_t* frame; // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zframe.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zframe.test"); assert (input); // Send five different frames, test ZFRAME_MORE int frame_nbr; for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, ZFRAME_MORE); assert (rc == 0); } // Send same frame five times, test ZFRAME_REUSE frame = zframe_new ("Hello", 5); assert (frame); for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE); assert (rc == 0); } assert (frame); zframe_t *copy = zframe_dup (frame); assert (zframe_eq (frame, copy)); zframe_destroy (&frame); assert (!zframe_eq (frame, copy)); assert (zframe_size (copy) == 5); zframe_destroy (©); assert (!zframe_eq (frame, copy)); // Test zframe_new_empty frame = zframe_new_empty (); assert (frame); assert (zframe_size (frame) == 0); zframe_destroy (&frame); // Send END frame frame = zframe_new ("NOT", 3); assert (frame); zframe_reset (frame, "END", 3); char *string = zframe_strhex (frame); assert (streq (string, "454E44")); free (string); string = zframe_strdup (frame); assert (streq (string, "END")); free (string); rc = zframe_send (&frame, output, 0); assert (rc == 0); // Read and count until we receive END frame_nbr = 0; for (frame_nbr = 0;; frame_nbr++) { zframe_t *frame = zframe_recv (input); if (zframe_streq (frame, "END")) { zframe_destroy (&frame); break; } assert (zframe_more (frame)); zframe_set_more (frame, 0); assert (zframe_more (frame) == 0); zframe_destroy (&frame); } assert (frame_nbr == 10); zsock_destroy (&input); zsock_destroy (&output); // @end printf ("OK\n"); } czmq-3.0.2/src/platform.h0000664000175000017500000001362012535241743014364 0ustar00phph00000000000000/* src/platform.h. Generated from platform.h.in by configure. */ /* src/platform.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ /* Have AIX OS */ /* #undef CZMQ_HAVE_AIX */ /* Have Android OS */ /* #undef CZMQ_HAVE_ANDROID */ /* Have Cygwin */ /* #undef CZMQ_HAVE_CYGWIN */ /* Have FreeBSD OS */ /* #undef CZMQ_HAVE_FREEBSD */ /* Have HPUX OS */ /* #undef CZMQ_HAVE_HPUX */ /* Have Linux OS */ #define CZMQ_HAVE_LINUX 1 /* Have MinGW32 */ /* #undef CZMQ_HAVE_MINGW32 */ /* Have NetBSD OS */ /* #undef CZMQ_HAVE_NETBSD */ /* Have OpenBSD OS */ /* #undef CZMQ_HAVE_OPENBSD */ /* Have DarwinOSX OS */ /* #undef CZMQ_HAVE_OSX */ /* Have QNX Neutrino OS */ /* #undef CZMQ_HAVE_QNXNTO */ /* Have Solaris OS */ /* #undef CZMQ_HAVE_SOLARIS */ /* Have Windows OS */ /* #undef CZMQ_HAVE_WINDOWS */ /* Define to 1 if you have the header file. */ #define HAVE_ARPA_INET_H 1 /* Define to 1 if you have the header file. */ #define HAVE_DLFCN_H 1 /* Define to 1 if you have the header file. */ #define HAVE_ERRNO_H 1 /* Define to 1 if you have the `getifaddrs' function. */ #define HAVE_GETIFADDRS 1 /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the header file. */ #define HAVE_IFADDRS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LINUX_WIRELESS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ /* #undef HAVE_MEMSET */ /* Define to 1 if you have the header file. */ #define HAVE_NETINET_IN_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NETINET_TCP_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NET_IF_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_NET_IF_MEDIA_H */ /* Define to 1 if you have the `perror' function. */ #define HAVE_PERROR 1 /* Define to 1 if stdbool.h conforms to C99. */ #define HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDDEF_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_WINDOWS_H */ /* Define to 1 if the system has the type `_Bool'. */ #define HAVE__BOOL 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* #undef NO_MINUS_C_MINUS_O */ /* Name of package */ #define PACKAGE "czmq" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "zeromq-dev@lists.zeromq.org" /* Define to the full name of this package. */ #define PACKAGE_NAME "czmq" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "czmq 3.0.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "czmq" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "3.0.2" /* CZMQ major version */ #define PACKAGE_VERSION_MAJOR 3 /* CZMQ minor version */ #define PACKAGE_VERSION_MINOR 0 /* CZMQ patchlevel */ #define PACKAGE_VERSION_PATCH 2 /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ #define VERSION "3.0.2" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN /* # undef WORDS_BIGENDIAN */ # endif #endif /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ /* #undef _UINT32_T */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus /* #undef inline */ #endif /* Define to `unsigned int' if does not define. */ /* #undef size_t */ /* Define to `int' if does not define. */ /* #undef ssize_t */ /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ /* #undef uint32_t */ /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ /* #undef volatile */ czmq-3.0.2/src/ziflist.c0000664000175000017500000003064512512255240014215 0ustar00phph00000000000000/* ========================================================================= ziflist - List of network interfaces available on system Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices). The caller can then access the network interface information using an iterator that works like zlistx. Only stores those interfaces with broadcast capability, and ignores the loopback interface. @discuss @end */ #include "platform.h" #include "../include/czmq.h" // Structure of an interface typedef struct { char *name; char *address; char *netmask; char *broadcast; } interface_t; // -------------------------------------------------------------------------- // interface destructor static void s_interface_destroy (interface_t **self_p) { assert (self_p); interface_t *self = *self_p; if (self) { free (self->name); free (self->address); free (self->netmask); free (self->broadcast); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // interface constructor static interface_t * s_interface_new (char *name, inaddr_t address, inaddr_t netmask, inaddr_t broadcast) { interface_t *self = (interface_t *) zmalloc (sizeof (interface_t)); if (!self) return NULL; self->name = strdup (name); if (self->name) self->address = strdup (inet_ntoa (address.sin_addr)); if (self->address) self->netmask = strdup (inet_ntoa (netmask.sin_addr)); if (self->netmask) self->broadcast = strdup (inet_ntoa (broadcast.sin_addr)); if (!self->broadcast) s_interface_destroy (&self); return self; } // Structure of our class struct _ziflist_t; // -------------------------------------------------------------------------- // Get a list of network interfaces currently defined on the system ziflist_t * ziflist_new (void) { zlistx_t *list = zlistx_new (); ziflist_t *self = (ziflist_t *) list; if (self) { zlistx_set_destructor (list, (czmq_destructor *) s_interface_destroy); ziflist_reload (self); } return self; } // Print properties of the ziflist object. // -------------------------------------------------------------------------- CZMQ_EXPORT void ziflist_print (ziflist_t *self) { for (interface_t *iface = (interface_t *) zlistx_first ((zlistx_t *) self) ; iface != NULL ; iface = (interface_t *) zlistx_next ((zlistx_t *) self)) { zsys_info (" - interface name : %s", iface->name); zsys_info (" - interface address : %s", iface->address); zsys_info (" - interface netmask : %s", iface->netmask); zsys_info (" - interface broadcast : %s", iface->broadcast); } } // -------------------------------------------------------------------------- // Destroy a ziflist instance void ziflist_destroy (ziflist_t **self_p) { zlistx_destroy ((zlistx_t **) self_p); } #ifdef __UNIX__ // -------------------------------------------------------------------------- // Helper function to verify if one interface's flags are what we want. static bool s_valid_flags (short flags) { return (flags & IFF_UP) // Only use interfaces that are running && !(flags & IFF_LOOPBACK) // Ignore loopback interface && (flags & IFF_BROADCAST) // Only use interfaces that have BROADCAST # if defined (IFF_SLAVE) && !(flags & IFF_SLAVE) // Ignore devices that are bonding slaves. # endif && !(flags & IFF_POINTOPOINT); // Ignore point to point interfaces. } #endif // -------------------------------------------------------------------------- // Reload network interfaces from system void ziflist_reload (ziflist_t *self) { assert (self); zlistx_t *list = (zlistx_t *) self; zlistx_purge (list); #if defined (HAVE_GETIFADDRS) struct ifaddrs *interfaces; if (getifaddrs (&interfaces) == 0) { struct ifaddrs *interface = interfaces; while (interface) { // On Solaris, loopback interfaces have a NULL in ifa_broadaddr if (interface->ifa_broadaddr && interface->ifa_addr && interface->ifa_addr->sa_family == AF_INET && s_valid_flags (interface->ifa_flags)) { inaddr_t address = *(inaddr_t *) interface->ifa_addr; inaddr_t netmask = *(inaddr_t *) interface->ifa_netmask; inaddr_t broadcast = *(inaddr_t *) interface->ifa_broadaddr; // If the returned broadcast address is the same as source // address, build the broadcast address from the source // address and netmask. if (address.sin_addr.s_addr == broadcast.sin_addr.s_addr) broadcast.sin_addr.s_addr |= ~(netmask.sin_addr.s_addr); interface_t *item = s_interface_new (interface->ifa_name, address, netmask, broadcast); if (item) zlistx_add_end (list, item); } interface = interface->ifa_next; } } freeifaddrs (interfaces); # elif defined (__UNIX__) int sock = socket (AF_INET, SOCK_DGRAM, 0); if (sock != -1) { int num_interfaces = 0; struct ifconf ifconfig = { 0 }; // First ioctl call gets us length of buffer; second call gets us contents if (!ioctl (sock, SIOCGIFCONF, (caddr_t) &ifconfig, sizeof (struct ifconf))) { ifconfig.ifc_buf = (char *) zmalloc (ifconfig.ifc_len); if (!ioctl (sock, SIOCGIFCONF, (caddr_t) &ifconfig, sizeof (struct ifconf))) num_interfaces = ifconfig.ifc_len / sizeof (struct ifreq); } int index; for (index = 0; index < num_interfaces; index++) { struct ifreq *ifr = &ifconfig.ifc_req [index]; // Check interface flags bool is_valid = false; if (!ioctl (sock, SIOCGIFFLAGS, (caddr_t) ifr, sizeof (struct ifreq))) is_valid = s_valid_flags (ifr->ifr_flags); // Get interface properties inaddr_t address = { 0 }; if (!ioctl (sock, SIOCGIFADDR, (caddr_t) ifr, sizeof (struct ifreq))) address = *((inaddr_t *) &ifr->ifr_addr); else is_valid = false; inaddr_t broadcast = { 0 }; if (!ioctl (sock, SIOCGIFBRDADDR, (caddr_t) ifr, sizeof (struct ifreq))) broadcast = *((inaddr_t *) &ifr->ifr_addr); else is_valid = false; inaddr_t netmask = { 0 }; if (!ioctl (sock, SIOCGIFNETMASK, (caddr_t) ifr, sizeof (struct ifreq))) netmask = *((inaddr_t *) &ifr->ifr_addr); else is_valid = false; if (is_valid) { interface_t *item = s_interface_new (ifr->ifr_name, address, netmask, broadcast); if (item) zlistx_add_end (list, item); } } free (ifconfig.ifc_buf); close (sock); } # elif defined (__WINDOWS__) ULONG addr_size = 0; DWORD rc = GetAdaptersAddresses (AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, NULL, &addr_size); assert (rc == ERROR_BUFFER_OVERFLOW); PIP_ADAPTER_ADDRESSES pip_addresses = (PIP_ADAPTER_ADDRESSES) zmalloc (addr_size); rc = GetAdaptersAddresses (AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, pip_addresses, &addr_size); assert (rc == NO_ERROR); PIP_ADAPTER_ADDRESSES cur_address = pip_addresses; while (cur_address) { PIP_ADAPTER_UNICAST_ADDRESS pUnicast = cur_address->FirstUnicastAddress; PIP_ADAPTER_PREFIX pPrefix = cur_address->FirstPrefix; PWCHAR friendlyName = cur_address->FriendlyName; size_t asciiSize = wcstombs (0, friendlyName, 0) + 1; char *asciiFriendlyName = (char *) zmalloc (asciiSize); wcstombs (asciiFriendlyName, friendlyName, asciiSize); bool valid = (cur_address->OperStatus == IfOperStatusUp) && (pUnicast && pPrefix) && (pUnicast->Address.lpSockaddr->sa_family == AF_INET) && (pPrefix->PrefixLength <= 32); if (valid) { inaddr_t address = *(inaddr_t *) pUnicast->Address.lpSockaddr; inaddr_t netmask; netmask.sin_addr.s_addr = htonl ((0xffffffffU) << (32 - pPrefix->PrefixLength)); inaddr_t broadcast = address; broadcast.sin_addr.s_addr |= ~(netmask.sin_addr.s_addr); interface_t *item = s_interface_new (asciiFriendlyName, address, netmask, broadcast); if (item) zlistx_add_end (list, item); } free (asciiFriendlyName); cur_address = cur_address->Next; } free (pip_addresses); # else # error "Interface detection TBD on this operating system" # endif } // -------------------------------------------------------------------------- // Return the number of network interfaces on system size_t ziflist_size (ziflist_t *self) { assert (self); return zlistx_size ((zlistx_t *) self); } // -------------------------------------------------------------------------- // Get first network interface, return NULL if there are none const char * ziflist_first (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_first ((zlistx_t *) self); if (iface) return iface->name; else return NULL; } // -------------------------------------------------------------------------- // Get next network interface, return NULL if we hit the last one const char * ziflist_next (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_next ((zlistx_t *) self); if (iface) return iface->name; else return NULL; } // -------------------------------------------------------------------------- // Return the current interface IP address as a printable string const char * ziflist_address (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); if (iface) return iface->address; else return NULL; } // -------------------------------------------------------------------------- // Return the current interface broadcast address as a printable string const char * ziflist_broadcast (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); if (iface) return iface->broadcast; else return NULL; } // -------------------------------------------------------------------------- // Return the current interface network mask as a printable string const char * ziflist_netmask (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); if (iface) return iface->netmask; else return NULL; } // -------------------------------------------------------------------------- // Selftest for this class void ziflist_test (bool verbose) { printf (" * ziflist: "); if (verbose) printf ("\n"); // @selftest ziflist_t *iflist = ziflist_new (); assert (iflist); size_t items = ziflist_size (iflist); if (verbose) { // printf ("ziflist: interfaces=%zu\n", ziflist_size (iflist)); const char *name = ziflist_first (iflist); while (name) { printf (" - name=%s address=%s netmask=%s broadcast=%s\n", name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist)); name = ziflist_next (iflist); } } ziflist_reload (iflist); assert (items == ziflist_size (iflist)); ziflist_destroy (&iflist); // @end printf ("OK\n"); } czmq-3.0.2/src/zgossip_msg.c0000664000175000017500000004653612533132116015102 0ustar00phph00000000000000/* ========================================================================= zgossip_msg - ZeroMQ Gossip Protocol Codec class for zgossip_msg. ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip_msg.xml, or * The code generation script that built this file: zproto_codec_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zgossip_msg - ZeroMQ Gossip Protocol @discuss @end */ #include "../include/czmq.h" #include "./zgossip_msg.h" // Structure of our class struct _zgossip_msg_t { zframe_t *routing_id; // Routing_id from ROUTER, if any int id; // zgossip_msg message ID byte *needle; // Read/write pointer for serialization byte *ceiling; // Valid upper limit for read pointer char key [256]; // Tuple key, globally unique char *value; // Tuple value, as printable string uint32_t ttl; // Time to live, msecs }; // -------------------------------------------------------------------------- // Network data encoding macros // Put a block of octets to the frame #define PUT_OCTETS(host,size) { \ memcpy (self->needle, (host), size); \ self->needle += size; \ } // Get a block of octets from the frame #define GET_OCTETS(host,size) { \ if (self->needle + size > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_OCTETS failed"); \ goto malformed; \ } \ memcpy ((host), self->needle, size); \ self->needle += size; \ } // Put a 1-byte number to the frame #define PUT_NUMBER1(host) { \ *(byte *) self->needle = (host); \ self->needle++; \ } // Put a 2-byte number to the frame #define PUT_NUMBER2(host) { \ self->needle [0] = (byte) (((host) >> 8) & 255); \ self->needle [1] = (byte) (((host)) & 255); \ self->needle += 2; \ } // Put a 4-byte number to the frame #define PUT_NUMBER4(host) { \ self->needle [0] = (byte) (((host) >> 24) & 255); \ self->needle [1] = (byte) (((host) >> 16) & 255); \ self->needle [2] = (byte) (((host) >> 8) & 255); \ self->needle [3] = (byte) (((host)) & 255); \ self->needle += 4; \ } // Put a 8-byte number to the frame #define PUT_NUMBER8(host) { \ self->needle [0] = (byte) (((host) >> 56) & 255); \ self->needle [1] = (byte) (((host) >> 48) & 255); \ self->needle [2] = (byte) (((host) >> 40) & 255); \ self->needle [3] = (byte) (((host) >> 32) & 255); \ self->needle [4] = (byte) (((host) >> 24) & 255); \ self->needle [5] = (byte) (((host) >> 16) & 255); \ self->needle [6] = (byte) (((host) >> 8) & 255); \ self->needle [7] = (byte) (((host)) & 255); \ self->needle += 8; \ } // Get a 1-byte number from the frame #define GET_NUMBER1(host) { \ if (self->needle + 1 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER1 failed"); \ goto malformed; \ } \ (host) = *(byte *) self->needle; \ self->needle++; \ } // Get a 2-byte number from the frame #define GET_NUMBER2(host) { \ if (self->needle + 2 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER2 failed"); \ goto malformed; \ } \ (host) = ((uint16_t) (self->needle [0]) << 8) \ + (uint16_t) (self->needle [1]); \ self->needle += 2; \ } // Get a 4-byte number from the frame #define GET_NUMBER4(host) { \ if (self->needle + 4 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER4 failed"); \ goto malformed; \ } \ (host) = ((uint32_t) (self->needle [0]) << 24) \ + ((uint32_t) (self->needle [1]) << 16) \ + ((uint32_t) (self->needle [2]) << 8) \ + (uint32_t) (self->needle [3]); \ self->needle += 4; \ } // Get a 8-byte number from the frame #define GET_NUMBER8(host) { \ if (self->needle + 8 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER8 failed"); \ goto malformed; \ } \ (host) = ((uint64_t) (self->needle [0]) << 56) \ + ((uint64_t) (self->needle [1]) << 48) \ + ((uint64_t) (self->needle [2]) << 40) \ + ((uint64_t) (self->needle [3]) << 32) \ + ((uint64_t) (self->needle [4]) << 24) \ + ((uint64_t) (self->needle [5]) << 16) \ + ((uint64_t) (self->needle [6]) << 8) \ + (uint64_t) (self->needle [7]); \ self->needle += 8; \ } // Put a string to the frame #define PUT_STRING(host) { \ size_t string_size = strlen (host); \ PUT_NUMBER1 (string_size); \ memcpy (self->needle, (host), string_size); \ self->needle += string_size; \ } // Get a string from the frame #define GET_STRING(host) { \ size_t string_size; \ GET_NUMBER1 (string_size); \ if (self->needle + string_size > (self->ceiling)) { \ zsys_warning ("zgossip_msg: GET_STRING failed"); \ goto malformed; \ } \ memcpy ((host), self->needle, string_size); \ (host) [string_size] = 0; \ self->needle += string_size; \ } // Put a long string to the frame #define PUT_LONGSTR(host) { \ size_t string_size = strlen (host); \ PUT_NUMBER4 (string_size); \ memcpy (self->needle, (host), string_size); \ self->needle += string_size; \ } // Get a long string from the frame #define GET_LONGSTR(host) { \ size_t string_size; \ GET_NUMBER4 (string_size); \ if (self->needle + string_size > (self->ceiling)) { \ zsys_warning ("zgossip_msg: GET_LONGSTR failed"); \ goto malformed; \ } \ free ((host)); \ (host) = (char *) malloc (string_size + 1); \ memcpy ((host), self->needle, string_size); \ (host) [string_size] = 0; \ self->needle += string_size; \ } // -------------------------------------------------------------------------- // Create a new zgossip_msg zgossip_msg_t * zgossip_msg_new (void) { zgossip_msg_t *self = (zgossip_msg_t *) zmalloc (sizeof (zgossip_msg_t)); return self; } // -------------------------------------------------------------------------- // Destroy the zgossip_msg void zgossip_msg_destroy (zgossip_msg_t **self_p) { assert (self_p); if (*self_p) { zgossip_msg_t *self = *self_p; // Free class properties zframe_destroy (&self->routing_id); free (self->value); // Free object itself free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Receive a zgossip_msg from the socket. Returns 0 if OK, -1 if // there was an error. Blocks if there is no message waiting. int zgossip_msg_recv (zgossip_msg_t *self, zsock_t *input) { assert (input); if (zsock_type (input) == ZMQ_ROUTER) { zframe_destroy (&self->routing_id); self->routing_id = zframe_recv (input); if (!self->routing_id || !zsock_rcvmore (input)) { zsys_warning ("zgossip_msg: no routing ID"); return -1; // Interrupted or malformed } } zmq_msg_t frame; zmq_msg_init (&frame); int size = zmq_msg_recv (&frame, zsock_resolve (input), 0); if (size == -1) { zsys_warning ("zgossip_msg: interrupted"); goto malformed; // Interrupted } // Get and check protocol signature self->needle = (byte *) zmq_msg_data (&frame); self->ceiling = self->needle + zmq_msg_size (&frame); uint16_t signature; GET_NUMBER2 (signature); if (signature != (0xAAA0 | 0)) { zsys_warning ("zgossip_msg: invalid signature"); // TODO: discard invalid messages and loop, and return // -1 only on interrupt goto malformed; // Interrupted } // Get message id and parse per message type GET_NUMBER1 (self->id); switch (self->id) { case ZGOSSIP_MSG_HELLO: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; case ZGOSSIP_MSG_PUBLISH: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } GET_STRING (self->key); GET_LONGSTR (self->value); GET_NUMBER4 (self->ttl); break; case ZGOSSIP_MSG_PING: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; case ZGOSSIP_MSG_PONG: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; case ZGOSSIP_MSG_INVALID: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; default: zsys_warning ("zgossip_msg: bad message ID"); goto malformed; } // Successful return zmq_msg_close (&frame); return 0; // Error returns malformed: zsys_warning ("zgossip_msg: zgossip_msg malformed message, fail"); zmq_msg_close (&frame); return -1; // Invalid message } // -------------------------------------------------------------------------- // Send the zgossip_msg to the socket. Does not destroy it. Returns 0 if // OK, else -1. int zgossip_msg_send (zgossip_msg_t *self, zsock_t *output) { assert (self); assert (output); if (zsock_type (output) == ZMQ_ROUTER) zframe_send (&self->routing_id, output, ZFRAME_MORE + ZFRAME_REUSE); size_t frame_size = 2 + 1; // Signature and message ID switch (self->id) { case ZGOSSIP_MSG_HELLO: frame_size += 1; // version break; case ZGOSSIP_MSG_PUBLISH: frame_size += 1; // version frame_size += 1 + strlen (self->key); frame_size += 4; if (self->value) frame_size += strlen (self->value); frame_size += 4; // ttl break; case ZGOSSIP_MSG_PING: frame_size += 1; // version break; case ZGOSSIP_MSG_PONG: frame_size += 1; // version break; case ZGOSSIP_MSG_INVALID: frame_size += 1; // version break; } // Now serialize message into the frame zmq_msg_t frame; zmq_msg_init_size (&frame, frame_size); self->needle = (byte *) zmq_msg_data (&frame); PUT_NUMBER2 (0xAAA0 | 0); PUT_NUMBER1 (self->id); size_t nbr_frames = 1; // Total number of frames to send switch (self->id) { case ZGOSSIP_MSG_HELLO: PUT_NUMBER1 (1); break; case ZGOSSIP_MSG_PUBLISH: PUT_NUMBER1 (1); PUT_STRING (self->key); if (self->value) { PUT_LONGSTR (self->value); } else PUT_NUMBER4 (0); // Empty string PUT_NUMBER4 (self->ttl); break; case ZGOSSIP_MSG_PING: PUT_NUMBER1 (1); break; case ZGOSSIP_MSG_PONG: PUT_NUMBER1 (1); break; case ZGOSSIP_MSG_INVALID: PUT_NUMBER1 (1); break; } // Now send the data frame zmq_msg_send (&frame, zsock_resolve (output), --nbr_frames? ZMQ_SNDMORE: 0); return 0; } // -------------------------------------------------------------------------- // Print contents of message to stdout void zgossip_msg_print (zgossip_msg_t *self) { assert (self); switch (self->id) { case ZGOSSIP_MSG_HELLO: zsys_debug ("ZGOSSIP_MSG_HELLO:"); zsys_debug (" version=1"); break; case ZGOSSIP_MSG_PUBLISH: zsys_debug ("ZGOSSIP_MSG_PUBLISH:"); zsys_debug (" version=1"); zsys_debug (" key='%s'", self->key); if (self->value) zsys_debug (" value='%s'", self->value); else zsys_debug (" value="); zsys_debug (" ttl=%ld", (long) self->ttl); break; case ZGOSSIP_MSG_PING: zsys_debug ("ZGOSSIP_MSG_PING:"); zsys_debug (" version=1"); break; case ZGOSSIP_MSG_PONG: zsys_debug ("ZGOSSIP_MSG_PONG:"); zsys_debug (" version=1"); break; case ZGOSSIP_MSG_INVALID: zsys_debug ("ZGOSSIP_MSG_INVALID:"); zsys_debug (" version=1"); break; } } // -------------------------------------------------------------------------- // Get/set the message routing_id zframe_t * zgossip_msg_routing_id (zgossip_msg_t *self) { assert (self); return self->routing_id; } void zgossip_msg_set_routing_id (zgossip_msg_t *self, zframe_t *routing_id) { if (self->routing_id) zframe_destroy (&self->routing_id); self->routing_id = zframe_dup (routing_id); } // -------------------------------------------------------------------------- // Get/set the zgossip_msg id int zgossip_msg_id (zgossip_msg_t *self) { assert (self); return self->id; } void zgossip_msg_set_id (zgossip_msg_t *self, int id) { self->id = id; } // -------------------------------------------------------------------------- // Return a printable command string const char * zgossip_msg_command (zgossip_msg_t *self) { assert (self); switch (self->id) { case ZGOSSIP_MSG_HELLO: return ("HELLO"); break; case ZGOSSIP_MSG_PUBLISH: return ("PUBLISH"); break; case ZGOSSIP_MSG_PING: return ("PING"); break; case ZGOSSIP_MSG_PONG: return ("PONG"); break; case ZGOSSIP_MSG_INVALID: return ("INVALID"); break; } return "?"; } // -------------------------------------------------------------------------- // Get/set the key field const char * zgossip_msg_key (zgossip_msg_t *self) { assert (self); return self->key; } void zgossip_msg_set_key (zgossip_msg_t *self, const char *value) { assert (self); assert (value); if (value == self->key) return; strncpy (self->key, value, 255); self->key [255] = 0; } // -------------------------------------------------------------------------- // Get/set the value field const char * zgossip_msg_value (zgossip_msg_t *self) { assert (self); return self->value; } void zgossip_msg_set_value (zgossip_msg_t *self, const char *value) { assert (self); assert (value); free (self->value); self->value = strdup (value); } // -------------------------------------------------------------------------- // Get/set the ttl field uint32_t zgossip_msg_ttl (zgossip_msg_t *self) { assert (self); return self->ttl; } void zgossip_msg_set_ttl (zgossip_msg_t *self, uint32_t ttl) { assert (self); self->ttl = ttl; } // -------------------------------------------------------------------------- // Selftest int zgossip_msg_test (bool verbose) { printf (" * zgossip_msg:"); // Silence an "unused" warning by "using" the verbose variable if (verbose) {;} // @selftest // Simple create/destroy test zgossip_msg_t *self = zgossip_msg_new (); assert (self); zgossip_msg_destroy (&self); // Create pair of sockets we can send through // We must bind before connect if we wish to remain compatible with ZeroMQ < v4 zsock_t *output = zsock_new (ZMQ_DEALER); assert (output); int rc = zsock_bind (output, "inproc://selftest-zgossip_msg"); assert (rc == 0); zsock_t *input = zsock_new (ZMQ_ROUTER); assert (input); rc = zsock_connect (input, "inproc://selftest-zgossip_msg"); assert (rc == 0); // Encode/send/decode and verify each message type int instance; self = zgossip_msg_new (); zgossip_msg_set_id (self, ZGOSSIP_MSG_HELLO); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_set_id (self, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_key (self, "Life is short but Now lasts for ever"); zgossip_msg_set_value (self, "Life is short but Now lasts for ever"); zgossip_msg_set_ttl (self, 123); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); assert (streq (zgossip_msg_key (self), "Life is short but Now lasts for ever")); assert (streq (zgossip_msg_value (self), "Life is short but Now lasts for ever")); assert (zgossip_msg_ttl (self) == 123); } zgossip_msg_set_id (self, ZGOSSIP_MSG_PING); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_set_id (self, ZGOSSIP_MSG_PONG); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_set_id (self, ZGOSSIP_MSG_INVALID); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_destroy (&self); zsock_destroy (&input); zsock_destroy (&output); // @end printf ("OK\n"); return 0; } czmq-3.0.2/src/zsockopt.c0000664000175000017500000036642412533132116014413 0ustar00phph00000000000000/* ========================================================================= zsockopt - get/set 0MQ socket options (deprecated) **************************************************** * GENERATED SOURCE CODE, DO NOT EDIT!! * * TO CHANGE THIS, EDIT scripts/sockopts.gsl * * AND RUN ./generate in models/. * **************************************************** Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsockopt class provides access to the 0MQ getsockopt/setsockopt API. @discuss This class is generated, using the GSL code generator. See the sockopts XML file, which provides the metadata, and the zsockopt.gsl template, which does the work. @end */ #include "../include/czmq.h" #if (ZMQ_VERSION_MAJOR == 4) // -------------------------------------------------------------------------- // Set socket ZMQ_TOS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tos (void *zocket, int tos) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tos () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TOS) int rc = zmq_setsockopt (zocket, ZMQ_TOS, &tos, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TOS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tos (void *zocket) { # if defined (ZMQ_TOS) int tos; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TOS, &tos, &option_len); return tos; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_HANDOVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_router_handover (void *zocket, int router_handover) { if (zsock_is (zocket)) { printf ("Please use zsock_set_router_handover () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_ROUTER_HANDOVER) if (zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_HANDOVER is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_HANDOVER, &router_handover, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_MANDATORY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_router_mandatory (void *zocket, int router_mandatory) { if (zsock_is (zocket)) { printf ("Please use zsock_set_router_mandatory () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_ROUTER_MANDATORY) if (zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_MANDATORY is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_MANDATORY, &router_mandatory, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PROBE_ROUTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_probe_router (void *zocket, int probe_router) { if (zsock_is (zocket)) { printf ("Please use zsock_set_probe_router () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_PROBE_ROUTER) if (zsocket_type (zocket) != ZMQ_ROUTER && zsocket_type (zocket) != ZMQ_DEALER && zsocket_type (zocket) != ZMQ_REQ) { printf ("ZMQ_PROBE_ROUTER is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_PROBE_ROUTER, &probe_router, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_REQ_RELAXED value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_req_relaxed (void *zocket, int req_relaxed) { if (zsock_is (zocket)) { printf ("Please use zsock_set_req_relaxed () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_REQ_RELAXED) if (zsocket_type (zocket) != ZMQ_REQ) { printf ("ZMQ_REQ_RELAXED is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_REQ_RELAXED, &req_relaxed, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_REQ_CORRELATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_req_correlate (void *zocket, int req_correlate) { if (zsock_is (zocket)) { printf ("Please use zsock_set_req_correlate () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_REQ_CORRELATE) if (zsocket_type (zocket) != ZMQ_REQ) { printf ("ZMQ_REQ_CORRELATE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_REQ_CORRELATE, &req_correlate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CONFLATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_conflate (void *zocket, int conflate) { if (zsock_is (zocket)) { printf ("Please use zsock_set_conflate () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_CONFLATE) if (zsocket_type (zocket) != ZMQ_PUSH && zsocket_type (zocket) != ZMQ_PULL && zsocket_type (zocket) != ZMQ_PUB && zsocket_type (zocket) != ZMQ_SUB && zsocket_type (zocket) != ZMQ_DEALER) { printf ("ZMQ_CONFLATE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_CONFLATE, &conflate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_zap_domain (void *zocket, const char * zap_domain) { if (zsock_is (zocket)) { printf ("Please use zsock_set_zap_domain () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_ZAP_DOMAIN) int rc = zmq_setsockopt (zocket, ZMQ_ZAP_DOMAIN, zap_domain, strlen (zap_domain)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_zap_domain (void *zocket) { # if defined (ZMQ_ZAP_DOMAIN) size_t option_len = 255; char *zap_domain = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_ZAP_DOMAIN, zap_domain, &option_len); return (char *) zap_domain; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MECHANISM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_mechanism (void *zocket) { # if defined (ZMQ_MECHANISM) int mechanism; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_MECHANISM, &mechanism, &option_len); return mechanism; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_plain_server (void *zocket, int plain_server) { if (zsock_is (zocket)) { printf ("Please use zsock_set_plain_server () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_PLAIN_SERVER) int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_SERVER, &plain_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_plain_server (void *zocket) { # if defined (ZMQ_PLAIN_SERVER) int plain_server; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_PLAIN_SERVER, &plain_server, &option_len); return plain_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_plain_username (void *zocket, const char * plain_username) { if (zsock_is (zocket)) { printf ("Please use zsock_set_plain_username () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_PLAIN_USERNAME) int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_USERNAME, plain_username, strlen (plain_username)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_plain_username (void *zocket) { # if defined (ZMQ_PLAIN_USERNAME) size_t option_len = 255; char *plain_username = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_PLAIN_USERNAME, plain_username, &option_len); return (char *) plain_username; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_plain_password (void *zocket, const char * plain_password) { if (zsock_is (zocket)) { printf ("Please use zsock_set_plain_password () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_PLAIN_PASSWORD) int rc = zmq_setsockopt (zocket, ZMQ_PLAIN_PASSWORD, plain_password, strlen (plain_password)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_plain_password (void *zocket) { # if defined (ZMQ_PLAIN_PASSWORD) size_t option_len = 255; char *plain_password = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_PLAIN_PASSWORD, plain_password, &option_len); return (char *) plain_password; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_server (void *zocket, int curve_server) { if (zsock_is (zocket)) { printf ("Please use zsock_set_curve_server () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_CURVE_SERVER) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVER, &curve_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_curve_server (void *zocket) { # if defined (ZMQ_CURVE_SERVER) int curve_server; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_CURVE_SERVER, &curve_server, &option_len); return curve_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey) { if (zsock_is (zocket)) { printf ("Please use zsock_set_curve_publickey () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_CURVE_PUBLICKEY) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, strlen (curve_publickey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_PUBLICKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey) { # if defined (ZMQ_CURVE_PUBLICKEY) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_curve_publickey (void *zocket) { # if defined (ZMQ_CURVE_PUBLICKEY) size_t option_len = 40 + 1; // Z85 key + terminator char *curve_publickey = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_CURVE_PUBLICKEY, curve_publickey, &option_len); return (char *) curve_publickey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey) { if (zsock_is (zocket)) { printf ("Please use zsock_set_curve_secretkey () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_CURVE_SECRETKEY) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, strlen (curve_secretkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SECRETKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey) { # if defined (ZMQ_CURVE_SECRETKEY) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_curve_secretkey (void *zocket) { # if defined (ZMQ_CURVE_SECRETKEY) size_t option_len = 40 + 1; // Z85 key + terminator char *curve_secretkey = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_CURVE_SECRETKEY, curve_secretkey, &option_len); return (char *) curve_secretkey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey) { if (zsock_is (zocket)) { printf ("Please use zsock_set_curve_serverkey () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_CURVE_SERVERKEY) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, strlen (curve_serverkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVERKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey) { # if defined (ZMQ_CURVE_SERVERKEY) int rc = zmq_setsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_curve_serverkey (void *zocket) { # if defined (ZMQ_CURVE_SERVERKEY) size_t option_len = 40 + 1; // Z85 key + terminator char *curve_serverkey = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_CURVE_SERVERKEY, curve_serverkey, &option_len); return (char *) curve_serverkey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_gssapi_server (void *zocket, int gssapi_server) { if (zsock_is (zocket)) { printf ("Please use zsock_set_gssapi_server () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_GSSAPI_SERVER) int rc = zmq_setsockopt (zocket, ZMQ_GSSAPI_SERVER, &gssapi_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_gssapi_server (void *zocket) { # if defined (ZMQ_GSSAPI_SERVER) int gssapi_server; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_GSSAPI_SERVER, &gssapi_server, &option_len); return gssapi_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_PLAINTEXT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_gssapi_plaintext (void *zocket, int gssapi_plaintext) { if (zsock_is (zocket)) { printf ("Please use zsock_set_gssapi_plaintext () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_GSSAPI_PLAINTEXT) int rc = zmq_setsockopt (zocket, ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_PLAINTEXT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_gssapi_plaintext (void *zocket) { # if defined (ZMQ_GSSAPI_PLAINTEXT) int gssapi_plaintext; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, &option_len); return gssapi_plaintext; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_gssapi_principal (void *zocket, const char * gssapi_principal) { if (zsock_is (zocket)) { printf ("Please use zsock_set_gssapi_principal () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_GSSAPI_PRINCIPAL) int rc = zmq_setsockopt (zocket, ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, strlen (gssapi_principal)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_gssapi_principal (void *zocket) { # if defined (ZMQ_GSSAPI_PRINCIPAL) size_t option_len = 255; char *gssapi_principal = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, &option_len); return (char *) gssapi_principal; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_SERVICE_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_gssapi_service_principal (void *zocket, const char * gssapi_service_principal) { if (zsock_is (zocket)) { printf ("Please use zsock_set_gssapi_service_principal () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL) int rc = zmq_setsockopt (zocket, ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, strlen (gssapi_service_principal)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_SERVICE_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_gssapi_service_principal (void *zocket) { # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL) size_t option_len = 255; char *gssapi_service_principal = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, &option_len); return (char *) gssapi_service_principal; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_ipv6 (void *zocket, int ipv6) { if (zsock_is (zocket)) { printf ("Please use zsock_set_ipv6 () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IPV6) int rc = zmq_setsockopt (zocket, ZMQ_IPV6, &ipv6, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_ipv6 (void *zocket) { # if defined (ZMQ_IPV6) int ipv6; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_IPV6, &ipv6, &option_len); return ipv6; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_immediate (void *zocket, int immediate) { if (zsock_is (zocket)) { printf ("Please use zsock_set_immediate () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IMMEDIATE) int rc = zmq_setsockopt (zocket, ZMQ_IMMEDIATE, &immediate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_immediate (void *zocket) { # if defined (ZMQ_IMMEDIATE) int immediate; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_IMMEDIATE, &immediate, &option_len); return immediate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_router_raw (void *zocket, int router_raw) { if (zsock_is (zocket)) { printf ("Please use zsock_set_router_raw () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_ROUTER_RAW) if (zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_RAW, &router_raw, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_ipv4only (void *zocket, int ipv4only) { if (zsock_is (zocket)) { printf ("Please use zsock_set_ipv4only () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IPV4ONLY) int rc = zmq_setsockopt (zocket, ZMQ_IPV4ONLY, &ipv4only, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_ipv4only (void *zocket) { # if defined (ZMQ_IPV4ONLY) int ipv4only; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_IPV4ONLY, &ipv4only, &option_len); return ipv4only; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect) { if (zsock_is (zocket)) { printf ("Please use zsock_set_delay_attach_on_connect () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) int rc = zmq_setsockopt (zocket, ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_type (void *zocket) { # if defined (ZMQ_TYPE) int type; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndhwm (void *zocket, int sndhwm) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndhwm () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDHWM) int rc = zmq_setsockopt (zocket, ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndhwm (void *zocket) { # if defined (ZMQ_SNDHWM) int sndhwm; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDHWM, &sndhwm, &option_len); return sndhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvhwm (void *zocket, int rcvhwm) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvhwm () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVHWM) int rc = zmq_setsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvhwm (void *zocket) { # if defined (ZMQ_RCVHWM) int rcvhwm; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, &option_len); return rcvhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_affinity (void *zocket, int affinity) { if (zsock_is (zocket)) { printf ("Please use zsock_set_affinity () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_AFFINITY) uint64_t value = affinity; int rc = zmq_setsockopt (zocket, ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_affinity (void *zocket) { # if defined (ZMQ_AFFINITY) uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zocket, ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_subscribe (void *zocket, const char * subscribe) { if (zsock_is (zocket)) { printf ("Please use zsock_set_subscribe () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SUBSCRIBE) if (zsocket_type (zocket) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) { if (zsock_is (zocket)) { printf ("Please use zsock_set_unsubscribe () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_UNSUBSCRIBE) if (zsocket_type (zocket) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_identity (void *zocket, const char * identity) { if (zsock_is (zocket)) { printf ("Please use zsock_set_identity () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IDENTITY) if (zsocket_type (zocket) != ZMQ_REQ && zsocket_type (zocket) != ZMQ_REP && zsocket_type (zocket) != ZMQ_DEALER && zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_identity (void *zocket) { # if defined (ZMQ_IDENTITY) size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rate (void *zocket, int rate) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rate () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RATE) int rc = zmq_setsockopt (zocket, ZMQ_RATE, &rate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rate (void *zocket) { # if defined (ZMQ_RATE) int rate; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); return rate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_recovery_ivl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECOVERY_IVL) int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_recovery_ivl (void *zocket) { # if defined (ZMQ_RECOVERY_IVL) int recovery_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return recovery_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndbuf (void *zocket, int sndbuf) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndbuf () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDBUF) int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &sndbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndbuf (void *zocket) { # if defined (ZMQ_SNDBUF) int sndbuf; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); return sndbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvbuf (void *zocket, int rcvbuf) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvbuf () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVBUF) int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvbuf (void *zocket) { # if defined (ZMQ_RCVBUF) int rcvbuf; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); return rcvbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_linger (void *zocket, int linger) { if (zsock_is (zocket)) { printf ("Please use zsock_set_linger () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_LINGER) int rc = zmq_setsockopt (zocket, ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_linger (void *zocket) { # if defined (ZMQ_LINGER) int linger; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_reconnect_ivl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECONNECT_IVL) int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_reconnect_ivl (void *zocket) { # if defined (ZMQ_RECONNECT_IVL) int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max) { if (zsock_is (zocket)) { printf ("Please use zsock_set_reconnect_ivl_max () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECONNECT_IVL_MAX) int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_reconnect_ivl_max (void *zocket) { # if defined (ZMQ_RECONNECT_IVL_MAX) int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_backlog (void *zocket, int backlog) { if (zsock_is (zocket)) { printf ("Please use zsock_set_backlog () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_BACKLOG) int rc = zmq_setsockopt (zocket, ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_backlog (void *zocket) { # if defined (ZMQ_BACKLOG) int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize) { if (zsock_is (zocket)) { printf ("Please use zsock_set_maxmsgsize () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_MAXMSGSIZE) int64_t value = maxmsgsize; int rc = zmq_setsockopt (zocket, ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_maxmsgsize (void *zocket) { # if defined (ZMQ_MAXMSGSIZE) int64_t maxmsgsize; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); return (int) maxmsgsize; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_multicast_hops (void *zocket, int multicast_hops) { if (zsock_is (zocket)) { printf ("Please use zsock_set_multicast_hops () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_MULTICAST_HOPS) int rc = zmq_setsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_multicast_hops (void *zocket) { # if defined (ZMQ_MULTICAST_HOPS) int multicast_hops; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); return multicast_hops; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvtimeo () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVTIMEO) int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvtimeo (void *zocket) { # if defined (ZMQ_RCVTIMEO) int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndtimeo (void *zocket, int sndtimeo) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndtimeo () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDTIMEO) int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndtimeo (void *zocket) { # if defined (ZMQ_SNDTIMEO) int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_VERBOSE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose) { if (zsock_is (zocket)) { printf ("Please use zsock_set_xpub_verbose () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_XPUB_VERBOSE) if (zsocket_type (zocket) != ZMQ_XPUB) { printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE) int tcp_keepalive; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); return tcp_keepalive; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive_idle () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive_idle (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int tcp_keepalive_idle; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); return tcp_keepalive_idle; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive_cnt () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE_CNT) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive_cnt (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE_CNT) int tcp_keepalive_cnt; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); return tcp_keepalive_cnt; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive_intvl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive_intvl (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int tcp_keepalive_intvl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); return tcp_keepalive_intvl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_accept_filter () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_ACCEPT_FILTER) int rc = zmq_setsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_tcp_accept_filter (void *zocket) { # if defined (ZMQ_TCP_ACCEPT_FILTER) size_t option_len = 255; char *tcp_accept_filter = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); return (char *) tcp_accept_filter; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvmore (void *zocket) { # if defined (ZMQ_RCVMORE) int rcvmore; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVMORE, &rcvmore, &option_len); return rcvmore; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsocket_fd (void *zocket) { # if defined (ZMQ_FD) SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zocket, ZMQ_FD, &fd, &option_len); return (SOCKET) fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_events (void *zocket) { # if defined (ZMQ_EVENTS) int events; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_EVENTS, &events, &option_len); return events; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LAST_ENDPOINT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_last_endpoint (void *zocket) { # if defined (ZMQ_LAST_ENDPOINT) size_t option_len = 255; char *last_endpoint = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_LAST_ENDPOINT, last_endpoint, &option_len); return (char *) last_endpoint; # else return NULL; # endif } #endif #if (ZMQ_VERSION_MAJOR == 3) // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_router_raw (void *zocket, int router_raw) { if (zsock_is (zocket)) { printf ("Please use zsock_set_router_raw () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_ROUTER_RAW) if (zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_ROUTER_RAW, &router_raw, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_ipv4only (void *zocket, int ipv4only) { if (zsock_is (zocket)) { printf ("Please use zsock_set_ipv4only () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IPV4ONLY) int rc = zmq_setsockopt (zocket, ZMQ_IPV4ONLY, &ipv4only, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_ipv4only (void *zocket) { # if defined (ZMQ_IPV4ONLY) int ipv4only; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_IPV4ONLY, &ipv4only, &option_len); return ipv4only; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect) { if (zsock_is (zocket)) { printf ("Please use zsock_set_delay_attach_on_connect () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) int rc = zmq_setsockopt (zocket, ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_type (void *zocket) { # if defined (ZMQ_TYPE) int type; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndhwm (void *zocket, int sndhwm) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndhwm () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDHWM) int rc = zmq_setsockopt (zocket, ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndhwm (void *zocket) { # if defined (ZMQ_SNDHWM) int sndhwm; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDHWM, &sndhwm, &option_len); return sndhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvhwm (void *zocket, int rcvhwm) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvhwm () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVHWM) int rc = zmq_setsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvhwm (void *zocket) { # if defined (ZMQ_RCVHWM) int rcvhwm; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVHWM, &rcvhwm, &option_len); return rcvhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_affinity (void *zocket, int affinity) { if (zsock_is (zocket)) { printf ("Please use zsock_set_affinity () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_AFFINITY) uint64_t value = affinity; int rc = zmq_setsockopt (zocket, ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_affinity (void *zocket) { # if defined (ZMQ_AFFINITY) uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zocket, ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_subscribe (void *zocket, const char * subscribe) { if (zsock_is (zocket)) { printf ("Please use zsock_set_subscribe () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SUBSCRIBE) if (zsocket_type (zocket) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) { if (zsock_is (zocket)) { printf ("Please use zsock_set_unsubscribe () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_UNSUBSCRIBE) if (zsocket_type (zocket) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_identity (void *zocket, const char * identity) { if (zsock_is (zocket)) { printf ("Please use zsock_set_identity () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IDENTITY) if (zsocket_type (zocket) != ZMQ_REQ && zsocket_type (zocket) != ZMQ_REP && zsocket_type (zocket) != ZMQ_DEALER && zsocket_type (zocket) != ZMQ_ROUTER) { printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_identity (void *zocket) { # if defined (ZMQ_IDENTITY) size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rate (void *zocket, int rate) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rate () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RATE) int rc = zmq_setsockopt (zocket, ZMQ_RATE, &rate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rate (void *zocket) { # if defined (ZMQ_RATE) int rate; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); return rate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_recovery_ivl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECOVERY_IVL) int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_recovery_ivl (void *zocket) { # if defined (ZMQ_RECOVERY_IVL) int recovery_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return recovery_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndbuf (void *zocket, int sndbuf) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndbuf () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDBUF) int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &sndbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndbuf (void *zocket) { # if defined (ZMQ_SNDBUF) int sndbuf; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); return sndbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvbuf (void *zocket, int rcvbuf) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvbuf () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVBUF) int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvbuf (void *zocket) { # if defined (ZMQ_RCVBUF) int rcvbuf; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); return rcvbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_linger (void *zocket, int linger) { if (zsock_is (zocket)) { printf ("Please use zsock_set_linger () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_LINGER) int rc = zmq_setsockopt (zocket, ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_linger (void *zocket) { # if defined (ZMQ_LINGER) int linger; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_reconnect_ivl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECONNECT_IVL) int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_reconnect_ivl (void *zocket) { # if defined (ZMQ_RECONNECT_IVL) int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max) { if (zsock_is (zocket)) { printf ("Please use zsock_set_reconnect_ivl_max () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECONNECT_IVL_MAX) int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_reconnect_ivl_max (void *zocket) { # if defined (ZMQ_RECONNECT_IVL_MAX) int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_backlog (void *zocket, int backlog) { if (zsock_is (zocket)) { printf ("Please use zsock_set_backlog () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_BACKLOG) int rc = zmq_setsockopt (zocket, ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_backlog (void *zocket) { # if defined (ZMQ_BACKLOG) int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize) { if (zsock_is (zocket)) { printf ("Please use zsock_set_maxmsgsize () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_MAXMSGSIZE) int64_t value = maxmsgsize; int rc = zmq_setsockopt (zocket, ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_maxmsgsize (void *zocket) { # if defined (ZMQ_MAXMSGSIZE) int64_t maxmsgsize; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); return (int) maxmsgsize; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_multicast_hops (void *zocket, int multicast_hops) { if (zsock_is (zocket)) { printf ("Please use zsock_set_multicast_hops () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_MULTICAST_HOPS) int rc = zmq_setsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_multicast_hops (void *zocket) { # if defined (ZMQ_MULTICAST_HOPS) int multicast_hops; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); return multicast_hops; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvtimeo () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVTIMEO) int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvtimeo (void *zocket) { # if defined (ZMQ_RCVTIMEO) int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndtimeo (void *zocket, int sndtimeo) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndtimeo () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDTIMEO) int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndtimeo (void *zocket) { # if defined (ZMQ_SNDTIMEO) int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_VERBOSE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose) { if (zsock_is (zocket)) { printf ("Please use zsock_set_xpub_verbose () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_XPUB_VERBOSE) if (zsocket_type (zocket) != ZMQ_XPUB) { printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE) int tcp_keepalive; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); return tcp_keepalive; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive_idle () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive_idle (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int tcp_keepalive_idle; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); return tcp_keepalive_idle; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive_cnt () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE_CNT) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive_cnt (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE_CNT) int tcp_keepalive_cnt; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); return tcp_keepalive_cnt; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_keepalive_intvl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int rc = zmq_setsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_tcp_keepalive_intvl (void *zocket) { # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int tcp_keepalive_intvl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); return tcp_keepalive_intvl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter) { if (zsock_is (zocket)) { printf ("Please use zsock_set_tcp_accept_filter () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_TCP_ACCEPT_FILTER) int rc = zmq_setsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_tcp_accept_filter (void *zocket) { # if defined (ZMQ_TCP_ACCEPT_FILTER) size_t option_len = 255; char *tcp_accept_filter = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); return (char *) tcp_accept_filter; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvmore (void *zocket) { # if defined (ZMQ_RCVMORE) int rcvmore; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVMORE, &rcvmore, &option_len); return rcvmore; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsocket_fd (void *zocket) { # if defined (ZMQ_FD) SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zocket, ZMQ_FD, &fd, &option_len); return (SOCKET) fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_events (void *zocket) { # if defined (ZMQ_EVENTS) int events; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_EVENTS, &events, &option_len); return events; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LAST_ENDPOINT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_last_endpoint (void *zocket) { # if defined (ZMQ_LAST_ENDPOINT) size_t option_len = 255; char *last_endpoint = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_LAST_ENDPOINT, last_endpoint, &option_len); return (char *) last_endpoint; # else return NULL; # endif } #endif #if (ZMQ_VERSION_MAJOR == 2) // -------------------------------------------------------------------------- // Set socket ZMQ_HWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_hwm (void *zocket, int hwm) { if (zsock_is (zocket)) { printf ("Please use zsock_set_hwm () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_HWM) uint64_t value = hwm; int rc = zmq_setsockopt (zocket, ZMQ_HWM, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_hwm (void *zocket) { # if defined (ZMQ_HWM) uint64_t hwm; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zocket, ZMQ_HWM, &hwm, &option_len); return (int) hwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SWAP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_swap (void *zocket, int swap) { if (zsock_is (zocket)) { printf ("Please use zsock_set_swap () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SWAP) int64_t value = swap; int rc = zmq_setsockopt (zocket, ZMQ_SWAP, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SWAP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_swap (void *zocket) { # if defined (ZMQ_SWAP) int64_t swap; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_SWAP, &swap, &option_len); return (int) swap; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_affinity (void *zocket, int affinity) { if (zsock_is (zocket)) { printf ("Please use zsock_set_affinity () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_AFFINITY) uint64_t value = affinity; int rc = zmq_setsockopt (zocket, ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_affinity (void *zocket) { # if defined (ZMQ_AFFINITY) uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zocket, ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_identity (void *zocket, const char * identity) { if (zsock_is (zocket)) { printf ("Please use zsock_set_identity () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_IDENTITY) int rc = zmq_setsockopt (zocket, ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsocket_identity (void *zocket) { # if defined (ZMQ_IDENTITY) size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zocket, ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rate (void *zocket, int rate) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rate () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RATE) int64_t value = rate; int rc = zmq_setsockopt (zocket, ZMQ_RATE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rate (void *zocket) { # if defined (ZMQ_RATE) int64_t rate; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_RATE, &rate, &option_len); return (int) rate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_recovery_ivl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECOVERY_IVL) int64_t value = recovery_ivl; int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_recovery_ivl (void *zocket) { # if defined (ZMQ_RECOVERY_IVL) int64_t recovery_ivl; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return (int) recovery_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL_MSEC value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec) { if (zsock_is (zocket)) { printf ("Please use zsock_set_recovery_ivl_msec () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECOVERY_IVL_MSEC) int64_t value = recovery_ivl_msec; int rc = zmq_setsockopt (zocket, ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL_MSEC value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_recovery_ivl_msec (void *zocket) { # if defined (ZMQ_RECOVERY_IVL_MSEC) int64_t recovery_ivl_msec; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len); return (int) recovery_ivl_msec; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MCAST_LOOP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_mcast_loop (void *zocket, int mcast_loop) { if (zsock_is (zocket)) { printf ("Please use zsock_set_mcast_loop () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_MCAST_LOOP) int64_t value = mcast_loop; int rc = zmq_setsockopt (zocket, ZMQ_MCAST_LOOP, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MCAST_LOOP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_mcast_loop (void *zocket) { # if defined (ZMQ_MCAST_LOOP) int64_t mcast_loop; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_MCAST_LOOP, &mcast_loop, &option_len); return (int) mcast_loop; # else return 0; # endif } # if (ZMQ_VERSION_MINOR == 2) // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvtimeo () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVTIMEO) int rc = zmq_setsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvtimeo (void *zocket) { # if defined (ZMQ_RCVTIMEO) int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } # endif # if (ZMQ_VERSION_MINOR == 2) // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndtimeo (void *zocket, int sndtimeo) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndtimeo () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDTIMEO) int rc = zmq_setsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndtimeo (void *zocket) { # if defined (ZMQ_SNDTIMEO) int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } # endif // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_sndbuf (void *zocket, int sndbuf) { if (zsock_is (zocket)) { printf ("Please use zsock_set_sndbuf () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SNDBUF) uint64_t value = sndbuf; int rc = zmq_setsockopt (zocket, ZMQ_SNDBUF, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_sndbuf (void *zocket) { # if defined (ZMQ_SNDBUF) uint64_t sndbuf; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zocket, ZMQ_SNDBUF, &sndbuf, &option_len); return (int) sndbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_rcvbuf (void *zocket, int rcvbuf) { if (zsock_is (zocket)) { printf ("Please use zsock_set_rcvbuf () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RCVBUF) uint64_t value = rcvbuf; int rc = zmq_setsockopt (zocket, ZMQ_RCVBUF, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvbuf (void *zocket) { # if defined (ZMQ_RCVBUF) uint64_t rcvbuf; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zocket, ZMQ_RCVBUF, &rcvbuf, &option_len); return (int) rcvbuf; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_linger (void *zocket, int linger) { if (zsock_is (zocket)) { printf ("Please use zsock_set_linger () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_LINGER) int rc = zmq_setsockopt (zocket, ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_linger (void *zocket) { # if defined (ZMQ_LINGER) int linger; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl) { if (zsock_is (zocket)) { printf ("Please use zsock_set_reconnect_ivl () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECONNECT_IVL) int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_reconnect_ivl (void *zocket) { # if defined (ZMQ_RECONNECT_IVL) int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max) { if (zsock_is (zocket)) { printf ("Please use zsock_set_reconnect_ivl_max () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_RECONNECT_IVL_MAX) int rc = zmq_setsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_reconnect_ivl_max (void *zocket) { # if defined (ZMQ_RECONNECT_IVL_MAX) int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_backlog (void *zocket, int backlog) { if (zsock_is (zocket)) { printf ("Please use zsock_set_backlog () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_BACKLOG) int rc = zmq_setsockopt (zocket, ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_backlog (void *zocket) { # if defined (ZMQ_BACKLOG) int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_subscribe (void *zocket, const char * subscribe) { if (zsock_is (zocket)) { printf ("Please use zsock_set_subscribe () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_SUBSCRIBE) if (zsocket_type (zocket) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe) { if (zsock_is (zocket)) { printf ("Please use zsock_set_unsubscribe () on zsock_t instances\n"); assert (false); } # if defined (ZMQ_UNSUBSCRIBE) if (zsocket_type (zocket) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsocket_type_str (zocket)); assert (false); } int rc = zmq_setsockopt (zocket, ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_type (void *zocket) { # if defined (ZMQ_TYPE) int type; size_t option_len = sizeof (int); zmq_getsockopt (zocket, ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_rcvmore (void *zocket) { # if defined (ZMQ_RCVMORE) int64_t rcvmore; size_t option_len = sizeof (int64_t); zmq_getsockopt (zocket, ZMQ_RCVMORE, &rcvmore, &option_len); return (int) rcvmore; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsocket_fd (void *zocket) { # if defined (ZMQ_FD) SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zocket, ZMQ_FD, &fd, &option_len); return (SOCKET) fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsocket_events (void *zocket) { # if defined (ZMQ_EVENTS) uint32_t events; size_t option_len = sizeof (uint32_t); zmq_getsockopt (zocket, ZMQ_EVENTS, &events, &option_len); return (int) events; # else return 0; # endif } #endif // -------------------------------------------------------------------------- // Selftest // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsockopt_test (bool verbose) { printf (" * zsockopt (deprecated): "); // @selftest zctx_t *ctx = zctx_new (); assert (ctx); void *zocket; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_tos (zocket, 1); assert (zsocket_tos (zocket) == 1); zsocket_tos (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_HANDOVER) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_handover (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_MANDATORY) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_mandatory (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PROBE_ROUTER) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_probe_router (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_RELAXED) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_relaxed (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_CORRELATE) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_correlate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_CONFLATE) zocket = zsocket_new (ctx, ZMQ_PUSH); assert (zocket); zsocket_set_conflate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ZAP_DOMAIN) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_zap_domain (zocket, "test"); char *zap_domain = zsocket_zap_domain (zocket); assert (zap_domain); free (zap_domain); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MECHANISM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_mechanism (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_SERVER) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_plain_server (zocket, 1); assert (zsocket_plain_server (zocket) == 1); zsocket_plain_server (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_USERNAME) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_username (zocket, "test"); char *plain_username = zsocket_plain_username (zocket); assert (plain_username); free (plain_username); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_PASSWORD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_password (zocket, "test"); char *plain_password = zsocket_plain_password (zocket); assert (plain_password); free (plain_password); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV6) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv6 (zocket, 1); assert (zsocket_ipv6 (zocket) == 1); zsocket_ipv6 (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IMMEDIATE) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_immediate (zocket, 1); assert (zsocket_immediate (zocket) == 1); zsocket_immediate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_hwm (zocket, 1); assert (zsocket_hwm (zocket) == 1); zsocket_hwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SWAP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_swap (zocket, 1); assert (zsocket_swap (zocket) == 1); zsocket_swap (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl_msec (zocket, 1); assert (zsocket_recovery_ivl_msec (zocket) == 1); zsocket_recovery_ivl_msec (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MCAST_LOOP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_mcast_loop (zocket, 1); assert (zsocket_mcast_loop (zocket) == 1); zsocket_mcast_loop (zocket); zsocket_destroy (ctx, zocket); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif #endif zctx_destroy (&ctx); // @end printf ("OK\n"); } czmq-3.0.2/src/zhash.c0000664000175000017500000007426512522736135013664 0ustar00phph00000000000000/* ========================================================================= zhash - simple generic hash container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zhash is an expandable hash table container. This is a simple container. For heavy-duty applications we recommend using zhashx. @discuss Note that it's relatively slow (~50K insertions/deletes per second), so don't do inserts/updates on the critical path for message I/O. It can do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU. @end */ #include "../include/czmq.h" // Hash table performance parameters #define INITIAL_SIZE 255 // Initial size in items #define LOAD_FACTOR 75 // Percent loading before splitting #define GROWTH_FACTOR 200 // Increase in % after splitting // Hash item, used internally only typedef struct _item_t { void *value; // Opaque item value struct _item_t *next; // Next item in the hash slot size_t index; // Index of item in table char *key; // Item's original key zhash_free_fn *free_fn; // Value free function if any } item_t; // --------------------------------------------------------------------- // Structure of our class struct _zhash_t { size_t size; // Current size of hash table size_t limit; // Current hash table limit item_t **items; // Array of items size_t cached_index; // Avoids duplicate hash calculations bool autofree; // If true, free values in destructor size_t cursor_index; // For first/next iteration item_t *cursor_item; // For first/next iteration const char *cursor_key; // After first/next call, points to key zlist_t *comments; // File comments, if any time_t modified; // Set during zhash_load char *filename; // Set during zhash_load }; // Local helper functions static uint s_item_hash (const char *key, size_t limit); static item_t *s_item_lookup (zhash_t *self, const char *key); static item_t *s_item_insert (zhash_t *self, const char *key, void *value); static void s_item_destroy (zhash_t *self, item_t *item, bool hard); // -------------------------------------------------------------------------- // Hash table constructor zhash_t * zhash_new (void) { zhash_t *self = (zhash_t *) zmalloc (sizeof (zhash_t)); if (self) { self->limit = INITIAL_SIZE; self->items = (item_t **) zmalloc (sizeof (item_t *) * self->limit); if (!self->items) zhash_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Hash table destructor void zhash_destroy (zhash_t **self_p) { assert (self_p); if (*self_p) { zhash_t *self = *self_p; uint index; for (index = 0; index < self->limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } } if (self->items) free (self->items); zlist_destroy (&self->comments); free (self->filename); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Local helper function // Destroy item in hash table, item must exist in table static void s_item_destroy (zhash_t *self, item_t *item, bool hard) { // Find previous item since it's a singly-linked list item_t *cur_item = self->items [item->index]; item_t **prev_item = &(self->items [item->index]); while (cur_item) { if (cur_item == item) break; prev_item = &(cur_item->next); cur_item = cur_item->next; } assert (cur_item); *prev_item = item->next; self->size--; if (hard) { if (item->free_fn) (item->free_fn) (item->value); else if (self->autofree) free (item->value); free (item->key); self->cursor_item = NULL; self->cursor_key = NULL; free (item); } } // -------------------------------------------------------------------------- // Insert item into hash table with specified key and item // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhash_insert (zhash_t *self, const char *key, void *value) { assert (self); assert (key); // If we're exceeding the load factor of the hash table, // resize it according to the growth factor if (self->size >= self->limit * LOAD_FACTOR / 100) { // Create new hash table size_t new_limit = self->limit * GROWTH_FACTOR / 100; item_t **new_items = (item_t **) zmalloc (sizeof (item_t *) * new_limit); if (!new_items) return -1; // Move all items to the new hash table, rehashing to // take into account new hash table limit uint index; for (index = 0; index != self->limit; index++) { item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; uint new_index = s_item_hash (cur_item->key, new_limit); cur_item->index = new_index; cur_item->next = new_items [new_index]; new_items [new_index] = cur_item; cur_item = next_item; } } // Destroy old hash table free (self->items); self->items = new_items; self->limit = new_limit; } return s_item_insert (self, key, value)? 0: -1; } // -------------------------------------------------------------------------- // Local helper function // Compute hash for key string static uint s_item_hash (const char *key, size_t limit) { // Modified Bernstein hashing function uint key_hash = 0; while (*key) key_hash = 33 * key_hash ^ *key++; key_hash %= limit; return key_hash; } // -------------------------------------------------------------------------- // Local helper function // Insert new item into hash table, returns item // If item already existed, returns NULL static item_t * s_item_insert (zhash_t *self, const char *key, void *value) { // Check that item does not already exist in hash table // Leaves self->cached_index with calculated hash item item_t *item = s_item_lookup (self, key); if (item == NULL) { item = (item_t *) zmalloc (sizeof (item_t)); if (!item) return NULL; // If necessary, take duplicate of item (string) value if (self->autofree) value = strdup ((char *) value); item->value = value; item->key = strdup (key); item->index = self->cached_index; // Insert into start of bucket list item->next = self->items [self->cached_index]; self->items [self->cached_index] = item; self->size++; } else item = NULL; // Signal duplicate insertion return item; } // -------------------------------------------------------------------------- // Local helper function // Lookup item in hash table, returns item or NULL static item_t * s_item_lookup (zhash_t *self, const char *key) { // Look in bucket list for item by key self->cached_index = s_item_hash (key, self->limit); item_t *item = self->items [self->cached_index]; while (item) { if (streq (item->key, key)) break; item = item->next; } return item; } // -------------------------------------------------------------------------- // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void zhash_update (zhash_t *self, const char *key, void *value) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { if (item->free_fn) (item->free_fn) (item->value); else if (self->autofree) free (item->value); // If necessary, take duplicate of item (string) value if (self->autofree) value = strdup ((char *) value); item->value = value; } else zhash_insert (self, key, value); } // -------------------------------------------------------------------------- // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhash_delete (zhash_t *self, const char *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) s_item_destroy (self, item, true); } // -------------------------------------------------------------------------- // Look for item in hash table and return its item, or NULL void * zhash_lookup (zhash_t *self, const char *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) return item->value; else return NULL; } // -------------------------------------------------------------------------- // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. If the new key already exists, deletes old item. int zhash_rename (zhash_t *self, const char *old_key, const char *new_key) { item_t *old_item = s_item_lookup (self, old_key); item_t *new_item = s_item_lookup (self, new_key); if (old_item && !new_item) { s_item_destroy (self, old_item, false); free (old_item->key); old_item->key = strdup (new_key); old_item->index = self->cached_index; old_item->next = self->items [self->cached_index]; self->items [self->cached_index] = old_item; self->size++; return 0; } else return -1; } // -------------------------------------------------------------------------- // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn *free_fn) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { item->free_fn = free_fn; return item->value; } else return NULL; } // -------------------------------------------------------------------------- // Return size of hash table size_t zhash_size (zhash_t *self) { assert (self); return self->size; } // -------------------------------------------------------------------------- // Make copy of hash table // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhash_t * zhash_dup (zhash_t *self) { if (!self) return NULL; zhash_t *copy = zhash_new (); zhash_autofree (copy); if (copy) { uint index; for (index = 0; index != self->limit; index++) { item_t *item = self->items [index]; while (item) { zhash_insert (copy, item->key, item->value); item = item->next; } } } return copy; } // -------------------------------------------------------------------------- // Return keys for items in table zlist_t * zhash_keys (zhash_t *self) { assert (self); zlist_t *keys = zlist_new (); if (!keys) return NULL; zlist_autofree (keys); uint index; for (index = 0; index != self->limit; index++) { item_t *item = self->items [index]; while (item) { zlist_append (keys, item->key); item = item->next; } } return keys; } // -------------------------------------------------------------------------- // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. NOTE: do NOT modify the table // while iterating. void * zhash_first (zhash_t *self) { assert (self); // Point to before or at first item self->cursor_index = 0; self->cursor_item = self->items [self->cursor_index]; // Now scan forwards to find it, leave cursor after item return zhash_next (self); } // -------------------------------------------------------------------------- // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). NOTE: // do NOT modify the table while iterating. void * zhash_next (zhash_t *self) { assert (self); // Scan forward from cursor until we find an item while (self->cursor_item == NULL) { if (self->cursor_index < self->limit - 1) self->cursor_index++; else return NULL; // At end of table // Get first item in next bucket self->cursor_item = self->items [self->cursor_index]; } // We have an item, so return it, and bump past it assert (self->cursor_item); item_t *item = self->cursor_item; self->cursor_key = item->key; self->cursor_item = self->cursor_item->next; return item->value; } // -------------------------------------------------------------------------- // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const char * zhash_cursor (zhash_t *self) { assert (self); return self->cursor_key; } // -------------------------------------------------------------------------- // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhash_comment (zhash_t *self, const char *format, ...) { if (format) { if (!self->comments) { self->comments = zlist_new (); if (!self->comments) return; zlist_autofree (self->comments); } va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (string) zlist_append (self->comments, string); free (string); } else zlist_destroy (&self->comments); } // -------------------------------------------------------------------------- // Save hash table to a text file in name=value format // Hash values must be printable strings. // Returns 0 if OK, else -1 if a file error occurred int zhash_save (zhash_t *self, const char *filename) { assert (self); FILE *handle = fopen (filename, "w"); if (!handle) return -1; // Failed to create file if (self->comments) { char *comment = (char *) zlist_first (self->comments); while (comment) { fprintf (handle, "# %s\n", comment); comment = (char *) zlist_next (self->comments); } fprintf (handle, "\n"); } uint index; for (index = 0; index != self->limit; index++) { item_t *item = self->items [index]; while (item) { fprintf (handle, "%s=%s\n", item->key, (char *) item->value); item = item->next; } } fclose (handle); return 0; } // -------------------------------------------------------------------------- // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings. // Returns 0 if OK, else -1 if a file was not readable. int zhash_load (zhash_t *self, const char *filename) { assert (self); zhash_autofree (self); // Whether or not file exists, we'll track the filename and last // modification date (0 for unknown files), so that zhash_refresh () // will always work after zhash_load (), to load a newly-created // file. // Take copy of filename in case self->filename is same string. char *filename_copy = strdup (filename); if (filename_copy) { free (self->filename); self->filename = filename_copy; self->modified = zsys_file_modified (self->filename); FILE *handle = fopen (self->filename, "r"); if (handle) { char *buffer = (char *) zmalloc (1024); if (buffer) { while (fgets (buffer, 1024, handle)) { // Skip lines starting with "#" or that do not look like // name=value data. char *equals = strchr (buffer, '='); if (buffer [0] == '#' || equals == buffer || !equals) continue; // Buffer may end in newline, which we don't want if (buffer [strlen (buffer) - 1] == '\n') buffer [strlen (buffer) - 1] = 0; *equals++ = 0; zhash_update (self, buffer, equals); } free (buffer); } else { fclose (handle); return -1; // Out of memory } fclose (handle); } else return -1; // Failed to open file for reading } else return -1; // Out of memory return 0; } // -------------------------------------------------------------------------- // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhash_refresh (zhash_t *self) { assert (self); if (self->filename) { if (zsys_file_modified (self->filename) > self->modified && zsys_file_stable (self->filename)) { // Empty the hash table; code is copied from zhash_destroy uint index; for (index = 0; index < self->limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } } zhash_load (self, self->filename); } } return 0; } // -------------------------------------------------------------------------- // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhash_pack (zhash_t *self) { assert (self); // First, calculate packed data size size_t frame_size = 4; // Dictionary size, number-4 uint index; for (index = 0; index < self->limit; index++) { item_t *item = self->items [index]; while (item) { // We store key as short string frame_size += 1 + strlen ((char *) item->key); // We store value as long string frame_size += 4 + strlen ((char *) item->value); item = item->next; } } // Now serialize items into the frame zframe_t *frame = zframe_new (NULL, frame_size); if (!frame) return NULL; byte *needle = zframe_data (frame); // Store size as number-4 *(uint32_t *) needle = htonl ((uint32_t) self->size); needle += 4; for (index = 0; index < self->limit; index++) { item_t *item = self->items [index]; while (item) { // Store key as string *needle++ = (byte) strlen ((char *) item->key); memcpy (needle, item->key, strlen ((char *) item->key)); needle += strlen ((char *) item->key); // Store value as longstr size_t length = strlen ((char *) item->value); *(uint32_t *) needle = htonl ((u_long) length); needle += 4; memcpy (needle, (char *) item->value, strlen ((char *) item->value)); needle += strlen ((char *) item->value); item = item->next; } } return frame; } // -------------------------------------------------------------------------- // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhash_t * zhash_unpack (zframe_t *frame) { zhash_t *self = zhash_new (); if (!self) return NULL; assert (frame); if (zframe_size (frame) < 4) return self; // Arguable... byte *needle = zframe_data (frame); byte *ceiling = needle + zframe_size (frame); size_t nbr_items = ntohl (*(uint32_t *) needle); needle += 4; while (nbr_items && needle < ceiling) { // Get key as string size_t key_size = *needle++; if (needle + key_size <= ceiling) { char key [256]; memcpy (key, needle, key_size); key [key_size] = 0; needle += key_size; // Get value as longstr if (needle + 4 <= ceiling) { size_t value_size = ntohl (*(uint32_t *) needle); needle += 4; // Be wary of malformed frames if (needle + value_size <= ceiling) { char *value = (char *) malloc (value_size + 1); memcpy (value, needle, value_size); value [value_size] = 0; needle += value_size; // Hash takes ownership of value if (zhash_insert (self, key, value)) { zhash_destroy (&self); break; } } } } } // Hash will free values in destructor if (self) zhash_autofree (self); return self; } // -------------------------------------------------------------------------- // Set hash for automatic value destruction void zhash_autofree (zhash_t *self) { assert (self); self->autofree = true; } // -------------------------------------------------------------------------- // DEPRECATED as clumsy -- use zhash_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). int zhash_foreach (zhash_t *self, zhash_foreach_fn *callback, void *argument) { assert (self); uint index; for (index = 0; index < self->limit; index++) { item_t *item = self->items [index]; while (item) { // Invoke callback, passing item properties and argument item_t *next = item->next; int rc = callback ((const char *) item->key, item->value, argument); if (rc) return rc; // End if non-zero return code item = next; } } return 0; } // -------------------------------------------------------------------------- // Runs selftest of class // void zhash_test (int verbose) { printf (" * zhash: "); // @selftest zhash_t *hash = zhash_new (); assert (hash); assert (zhash_size (hash) == 0); assert (zhash_first (hash) == NULL); assert (zhash_cursor (hash) == NULL); // Insert some items int rc; rc = zhash_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhash_first (hash); assert (streq (zhash_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhash_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhash_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhash_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhash_size (hash) == 4); // Look for existing items item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhash_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhash_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhash_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhash_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhash_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlist_t *keys = zhash_keys (hash); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Test dup method zhash_t *copy = zhash_dup (hash); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test pack/unpack methods zframe_t *frame = zhash_pack (hash); copy = zhash_unpack (frame); zframe_destroy (&frame); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test save and load zhash_comment (hash, "This is a test file"); zhash_comment (hash, "Created by %s", "czmq_selftest"); zhash_save (hash, ".cache"); copy = zhash_new (); assert (copy); zhash_load (copy, ".cache"); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); zsys_file_delete (".cache"); // Delete a item zhash_delete (hash, "LIVEBEEF"); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhash_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr].exists) { item = (char *) zhash_lookup (hash, testset [testnbr].name); assert (item); zhash_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhash_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhash_destroy (&hash); zhash_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhash_new (); assert (hash); zhash_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhash_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Inserting with the same key will fail"); rc = zhash_insert (hash, "key1", value); assert (rc == -1); strcpy (value, "Ring a ding ding"); rc = zhash_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding")); zhash_destroy (&hash); // @end printf ("OK\n"); } czmq-3.0.2/src/foreign/0000775000175000017500000000000012535242314014011 5ustar00phph00000000000000czmq-3.0.2/src/foreign/slre/0000775000175000017500000000000012535242314014756 5ustar00phph00000000000000czmq-3.0.2/src/foreign/slre/slre.h0000664000175000017500000000603112533666571016111 0ustar00phph00000000000000/* * Copyright (c) 2004-2005 Sergey Lyubka * All rights reserved * * "THE BEER-WARE LICENSE" (Revision 42): * Sergey Lyubka wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. */ /* * This is a regular expression library that implements a subset of Perl RE. * Please refer to http://slre.sourceforge.net for detailed description. * * Usage example (parsing HTTP request): * * struct slre slre; * struct cap captures[4 + 1]; // Number of braket pairs + 1 * ... * * slre_compile(&slre,"^(GET|POST) (\S+) HTTP/(\S+?)\r\n"); * * if (slre_match(&slre, buf, len, captures)) { * printf("Request line length: %d\n", captures[0].len); * printf("Method: %.*s\n", captures[1].len, captures[1].ptr); * printf("URI: %.*s\n", captures[2].len, captures[2].ptr); * } * * Supported syntax: * ^ Match beginning of a buffer * $ Match end of a buffer * () Grouping and substring capturing * [...] Match any character from set * [^...] Match any character but ones from set * \s Match whitespace * \S Match non-whitespace * \d Match decimal digit * \r Match carriage return * \n Match newline * + Match one or more times (greedy) * +? Match one or more times (non-greedy) * * Match zero or more times (greedy) * *? Match zero or more times (non-greedy) * ? Match zero or once * \xDD Match byte with hex value 0xDD * \meta Match one of the meta character: ^$().[*+?\ */ #ifndef SLRE_HEADER_DEFINED #define SLRE_HEADER_DEFINED /* * Compiled regular expression */ struct slre { unsigned char code[256]; unsigned char data[256]; int code_size; int data_size; int num_caps; /* Number of bracket pairs */ int anchored; /* Must match from string start */ const char *err_str; /* Error string */ }; /* * Captured substring */ struct cap { const char *ptr; /* Pointer to the substring */ size_t len; /* Substring length */ }; /* * Compile regular expression. If success, 1 is returned. * If error, 0 is returned and slre.err_str points to the error message. */ int slre_compile(struct slre *, const char *re); /* * Return 1 if match, 0 if no match. * If `captured_substrings' array is not NULL, then it is filled with the * values of captured substrings. captured_substrings[0] element is always * a full matched substring. The round bracket captures start from * captured_substrings[1]. * It is assumed that the size of captured_substrings array is enough to * hold all captures. The caller function must make sure it is! So, the * array_size = number_of_round_bracket_pairs + 1 */ int slre_match(const struct slre *, const char *buf, size_t buf_len, struct cap *captured_substrings); #endif /* SLRE_HEADER_DEFINED */ czmq-3.0.2/src/foreign/slre/slre.inc_c0000664000175000017500000004541212533666571016743 0ustar00phph00000000000000/* * Copyright (c) 2004-2005 Sergey Lyubka * All rights reserved * * "THE BEER-WARE LICENSE" (Revision 42): * Sergey Lyubka wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. */ #include #include #include #include #include #include #include "slre.h" enum { END, BRANCH, ANY, EXACT, ANYOF, ANYBUT, OPEN, CLOSE, BOL, EOL, STAR, PLUS, STARQ, PLUSQ, QUEST, SPACE, NONSPACE, DIGIT, NONDIGIT, ALPHA, NONALPHA, ALNUM, NONALNUM }; static struct { const char *name; int narg; const char *flags; } opcodes [] = { {"END", 0, ""}, /* End of code block or program */ {"BRANCH", 2, "oo"}, /* Alternative operator, "|" */ {"ANY", 0, ""}, /* Match any character, "." */ {"EXACT", 2, "d"}, /* Match exact string */ {"ANYOF", 2, "D"}, /* Match any from set, " []" */ {"ANYBUT", 2, "D"}, /* Match any but from set, " [^]"*/ {"OPEN ", 1, "i"}, /* Capture start, " (" */ {"CLOSE", 1, "i"}, /* Capture end, ")" */ {"BOL", 0, ""}, /* Beginning of string, "^" */ {"EOL", 0, ""}, /* End of string, "$" */ {"STAR", 1, "o"}, /* Match zero or more times "*" */ {"PLUS", 1, "o"}, /* Match one or more times, "+" */ {"STARQ", 1, "o"}, /* Non-greedy STAR, "*?" */ {"PLUSQ", 1, "o"}, /* Non-greedy PLUS, "+?" */ {"QUEST", 1, "o"}, /* Match zero or one time, "?" */ {"SPACE", 0, ""}, /* Match whitespace, "\s" */ {"NONSPACE",0, ""}, /* Match non-space, "\S" */ {"DIGIT", 0, ""}, /* Match digit, "\d" */ {"NONDIGIT",0, ""}, /* Match non-digit, "\D" */ {"ALPHA", 0, ""}, /* Match alpha, "\a" */ {"NONALPHA",0, ""}, /* Match non-alpha, "\A" */ {"ALNUM", 0, ""}, /* Match letter, "\w" */ {"NONALNUM", 0, ""} /* Match non-letter, "\W" */ }; /* * Commands and operands are all unsigned char (1 byte long). All code offsets * are relative to current address, and positive (always point forward). Data * offsets are absolute. Commands with operands: * * BRANCH offset1 offset2 * Try to match the code block that follows the BRANCH instruction * (code block ends with END). If no match, try to match code block that * starts at offset1. If either of these match, jump to offset2. * * EXACT data_offset data_length * Try to match exact string. String is recorded in data section from * data_offset, and has length data_length. * * OPEN capture_number * CLOSE capture_number * If the user have passed 'struct cap' array for captures, OPEN * records the beginning of the matched substring (cap->ptr), CLOSE * sets the length (cap->len) for respective capture_number. * * STAR code_offset * PLUS code_offset * QUEST code_offset * *, +, ?, respectively. Try to gobble as much as possible from the * matched buffer, until code block that follows these instructions * matches. When the longest possible string is matched, * jump to code_offset * * STARQ, PLUSQ are non-greedy versions of STAR and PLUS. */ static const char *meta_chars = "|.^$*+?()[\\"; static void print_character_set (FILE *fp, const unsigned char *p, int len) { int i; for (i = 0; i < len; i++) { if (i > 0) (void) fputc (',', fp); if (p [i] == 0) { i++; if (p [i] == 0) (void) fprintf (fp, "\\x%02x", p [i]); else (void) fprintf (fp, "%s", opcodes [p [i]].name); } else if (isprint (p [i])) (void) fputc (p [i], fp); else (void) fprintf (fp,"\\x%02x", p [i]); } } void slre_dump (const struct slre *r, FILE *fp) { int i, j, ch, op, pc; for (pc = 0; pc < r->code_size; pc++) { op = r->code [pc]; (void) fprintf (fp, "%3d %s ", pc, opcodes [op].name); for (i = 0; opcodes [op].flags [i] != '\0'; i++) switch (opcodes [op].flags [i]) { case 'i': (void) fprintf (fp, "%d ", r->code [pc + 1]); pc++; break; case 'o': (void) fprintf (fp, "%d ", pc + r->code [pc + 1] - i); pc++; break; case 'D': print_character_set (fp, r->data + r->code [pc + 1], r->code [pc + 2]); pc += 2; break; case 'd': (void) fputc ('"', fp); for (j = 0; j < r->code [pc + 2]; j++) { ch = r->data [r->code [pc + 1] + j]; if (isprint (ch)) (void) fputc (ch, fp); else (void) fprintf (fp,"\\x%02x",ch); } (void) fputc ('"', fp); pc += 2; break; } (void) fputc ('\n', fp); } } static void set_jump_offset (struct slre *r, int pc, int offset) { assert (offset < r->code_size); if (r->code_size - offset > 0xff) r->err_str = "Jump offset is too big"; else r->code [pc] = (unsigned char) (r->code_size - offset); } static void emit (struct slre *r, int code) { if (r->code_size >= (int) (sizeof (r->code) / sizeof (r->code [0]))) r->err_str = "RE is too long (code overflow)"; else r->code [r->code_size++] = (unsigned char) code; } static void store_char_in_data (struct slre *r, int ch) { if (r->data_size >= (int) sizeof (r->data)) r->err_str = "RE is too long (data overflow)"; else r->data [r->data_size++] = ch; } static void exact (struct slre *r, const char **re) { int old_data_size = r->data_size; while (**re != '\0' && (strchr (meta_chars, **re)) == NULL) store_char_in_data (r, *(*re)++); emit (r, EXACT); emit (r, old_data_size); emit (r, r->data_size - old_data_size); } static int get_escape_char (const char **re) { int res; switch (*(*re)++) { case 'n': res = '\n'; break; case 'r': res = '\r'; break; case 't': res = '\t'; break; case '0': res = 0; break; case 's': res = SPACE << 8; break; case 'S': res = NONSPACE << 8; break; case 'd': res = DIGIT << 8; break; case 'D': res = NONDIGIT << 8; break; case 'a': res = ALPHA << 8; break; case 'A': res = NONALPHA << 8; break; case 'w': res = ALNUM << 8; break; case 'W': res = NONALNUM << 8; break; default: res = (*re) [-1]; break; } return (res); } static void anyof (struct slre *r, const char **re) { int esc, old_data_size = r->data_size, op = ANYOF; if (**re == '^') { op = ANYBUT; (*re)++; } while (**re != '\0') { switch (*(*re)++) { case ']': emit (r, op); emit (r, old_data_size); emit (r, r->data_size - old_data_size); return; /* NOTREACHED */ break; case '\\': esc = get_escape_char (re); if ((esc & 0xff) == 0) { store_char_in_data (r, 0); store_char_in_data (r, esc >> 8); } else store_char_in_data (r, esc); break; default: store_char_in_data (r, (*re) [-1]); break; } } r->err_str = "No closing ']' bracket"; } static void relocate (struct slre *r, int begin, int shift) { emit (r, END); memmove (r->code + begin + shift, r->code + begin, r->code_size - begin); r->code_size += shift; } static void quantifier (struct slre *r, int prev, int op) { if (r->code [prev] == EXACT && r->code [prev + 2] > 1) { r->code [prev + 2]--; emit (r, EXACT); emit (r, r->code [prev + 1] + r->code [prev + 2]); emit (r, 1); prev = r->code_size - 3; } relocate (r, prev, 2); r->code [prev] = op; set_jump_offset (r, prev + 1, prev); } static void exact_one_char (struct slre *r, int ch) { emit (r, EXACT); emit (r, r->data_size); emit (r, 1); store_char_in_data (r, ch); } static void fixup_branch (struct slre *r, int fixup) { if (fixup > 0) { emit (r, END); set_jump_offset (r, fixup, fixup - 2); } } static void compile (struct slre *r, const char **re) { int op, esc, branch_start, last_op, fixup, cap_no, level; fixup = 0; level = r->num_caps; branch_start = last_op = r->code_size; for (;;) { switch (*(*re)++) { case '\0': (*re)--; return; case '^': emit (r, BOL); break; case '$': emit (r, EOL); break; case '.': last_op = r->code_size; emit (r, ANY); break; case '[': last_op = r->code_size; anyof (r, re); break; case '\\': last_op = r->code_size; esc = get_escape_char (re); if (esc & 0xff00) emit (r, esc >> 8); else exact_one_char (r, esc); break; case '(': last_op = r->code_size; cap_no = ++r->num_caps; emit (r, OPEN); emit (r, cap_no); compile (r, re); if (*(*re)++ != ')') { r->err_str = "No closing bracket"; return; } emit (r, CLOSE); emit (r, cap_no); break; case ')': (*re)--; fixup_branch (r, fixup); if (level == 0) { r->err_str = "Unbalanced brackets"; return; } return; case '+': case '*': op = (*re) [-1] == '*' ? STAR: PLUS; if (**re == '?') { (*re)++; op = op == STAR ? STARQ : PLUSQ; } quantifier (r, last_op, op); break; case '?': quantifier (r, last_op, QUEST); break; case '|': fixup_branch (r, fixup); relocate (r, branch_start, 3); r->code [branch_start] = BRANCH; set_jump_offset (r, branch_start + 1, branch_start); fixup = branch_start + 2; r->code [fixup] = 0xff; break; default: (*re)--; last_op = r->code_size; exact (r, re); break; } } } int slre_compile (struct slre *r, const char *re) { r->err_str = NULL; r->code_size = r->data_size = r->num_caps = r->anchored = 0; if (*re == '^') r->anchored++; emit (r, OPEN); /* This will capture what matches full RE */ emit (r, 0); while (*re != '\0') compile (r, &re); if (r->code [2] == BRANCH) fixup_branch (r, 4); emit (r, CLOSE); emit (r, 0); emit (r, END); return (r->err_str == NULL? 1: 0); } static int match (const struct slre *, int, const char *, size_t, size_t *, struct cap *); static void loop_greedy (const struct slre *r, int pc, const char *s, size_t len, size_t *ofs) { size_t saved_offset, matched_offset; saved_offset = matched_offset = *ofs; while (match (r, pc + 2, s, len, ofs, NULL)) { saved_offset = *ofs; if (match (r, pc + r->code [pc + 1], s, len, ofs, NULL)) matched_offset = saved_offset; *ofs = saved_offset; } *ofs = matched_offset; } static void loop_non_greedy (const struct slre *r, int pc, const char *s, size_t len, size_t *ofs) { size_t saved_offset = *ofs; while (match (r, pc + 2, s, len, ofs, NULL)) { saved_offset = *ofs; if (match (r, pc + r->code [pc + 1], s, len, ofs, NULL)) break; } *ofs = saved_offset; } static int is_any_of (const unsigned char *p, int len, const char *s, size_t *ofs) { int i, ch; ch = s [*ofs]; for (i = 0; i < len; i++) if (p [i] == ch) { (*ofs)++; return (1); } return (0); } static int is_any_but (const unsigned char *p, int len, const char *s, size_t *ofs) { int i, ch; ch = s [*ofs]; for (i = 0; i < len; i++) if (p [i] == ch) return (0); (*ofs)++; return (1); } static int match (const struct slre *r, int pc, const char *s, size_t len, size_t *ofs, struct cap *caps) { int res = 1; size_t n, saved_offset; while (res && r->code [pc] != END) { assert (pc < r->code_size); assert (pc < (int) (sizeof (r->code) / sizeof (r->code [0]))); switch (r->code [pc]) { case BRANCH: saved_offset = *ofs; res = match (r, pc + 3, s, len, ofs, caps); if (res == 0) { *ofs = saved_offset; res = match (r, pc + r->code [pc + 1], s, len, ofs, caps); } pc += r->code [pc + 2]; break; case EXACT: res = 0; n = r->code [pc + 2]; /* String length */ if (n <= len - *ofs && !memcmp (s + *ofs, r->data + r->code [pc + 1], n)) { (*ofs) += n; res = 1; } pc += 3; break; case QUEST: res = 1; saved_offset = *ofs; if (!match (r, pc + 2, s, len, ofs, caps)) *ofs = saved_offset; pc += r->code [pc + 1]; break; case STAR: res = 1; loop_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case STARQ: res = 1; loop_non_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case PLUS: if ((res = match (r, pc + 2, s, len, ofs, caps)) == 0) break; loop_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case PLUSQ: if ((res = match (r, pc + 2, s, len, ofs, caps)) == 0) break; loop_non_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case SPACE: res = 0; if (*ofs < len && isspace (((unsigned char *)s) [*ofs])) { (*ofs)++; res = 1; } pc++; break; case NONSPACE: res = 0; if (*ofs data + r->code [pc + 1], r->code [pc + 2], s, ofs); pc += 3; break; case ANYBUT: res = 0; if (*ofs < len) res = is_any_but (r->data + r->code [pc + 1], r->code [pc + 2], s, ofs); pc += 3; break; case BOL: res = *ofs == 0 ? 1 : 0; pc++; break; case EOL: res = *ofs == len ? 1 : 0; pc++; break; case OPEN: if (caps != NULL) caps [r->code [pc + 1]].ptr = s + *ofs; pc += 2; break; case CLOSE: if (caps != NULL) caps [r->code [pc + 1]].len = (s + *ofs) - caps [r->code [pc + 1]].ptr; pc += 2; break; case END: pc++; break; default: printf ("unknown cmd (%d) at %d\n", r->code [pc], pc); assert (0); break; } } return (res); } int slre_match(const struct slre *r, const char *buf, size_t len, struct cap *caps) { int res = 0; size_t ofs = 0; if (r->anchored) res = match (r, 0, buf, len, &ofs, caps); else { size_t i; for (i = 0; i < len && res == 0; i++) { ofs = i; res = match (r, 0, buf, len, &ofs, caps); } } return (res); } czmq-3.0.2/src/foreign/slre/readme.txt0000664000175000017500000000726412533666571017002 0ustar00phph00000000000000SLRE - Super Light Regular Expression library Modified 2014-08-26 Pieter Hintjens SLRE is an ANSI C library that implements a tiny subset of Perl regular expressions. It is primarily targeted for developers who want to parse configuation files, where speed is unimportant. It is in single .c file, easily modifiable for custom needs. For example, if one wants to introduce a new metacharacter, '\i', that means 'IP address', it is easy to do so. Features Crossplatform - pure ANSI C Very simple API Light: about 5kB of code when compiled Uses no dynamic memory allocation Thread safe Supported RE Syntax ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ API Two functions represent the API: one is used for compilations of the RE, the other for performing a match. Both functions return 0 on error, and 1 on success. If the round brackets are used in the RE, then matched substrings can be returned back to the caller in the 'struct cap *' array. Array size must be enough to hold all matches: array_size = number_of_round_bracket_pairs + 1. The first element of the array will always hold the substring matched by the whole RE. /* Captured substring */ struct cap { const char *ptr; /* Pointer to the substring */ int len; /* Substring length */ }; int slre_compile(struct slre *, const char *re); int slre_match(const struct slre *, const char *buf, int buf_len, struct cap *captured_substrings); Usage example This example shows how to parse HTTP request line: struct slre slre; struct cap captures[4 + 1]; if (!slre_compile(&slre, "^(GET|POST) (\S+) HTTP/(\S+?)\r\n") { printf("Error compiling RE: %s\n", slre.err_str); } else if (!slre_match(&slre, buf, len, captures)) { printf("Not a valid HTTP request\n" ); } else { printf("Request line length: %d\n", captures[0].len); printf("Method: %.*s\n", captures[1].len, captures[1].ptr); printf("URI: %.*s\n", captures[2].len, captures[2].ptr); } Download Version 1.0: slre.h, slre.c License /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Sergey Lyubka wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. * ---------------------------------------------------------------------------- */ Author Copyright © by Sergey Lyubka (valenok at gmail dot com). Feel free to contact me if you want to comply with the license. czmq-3.0.2/src/foreign/sha1/0000775000175000017500000000000012535242314014645 5ustar00phph00000000000000czmq-3.0.2/src/foreign/sha1/sha1.inc_c0000664000175000017500000002100312533666571016507 0ustar00phph00000000000000/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm * implemented by Jun-ichiro itojun Itoh */ #include "../../../include/czmq.h" #include "sha1.h" /* constant table */ static uint32_t _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; #define K(t) _K[(t) / 20] #define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d))) #define F1(b, c, d) (((b) ^ (c)) ^ (d)) #define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) #define F3(b, c, d) (((b) ^ (c)) ^ (d)) #define S(n, x) (((x) << (n)) | ((x) >> (32 - (n)))) #define H(n) (ctxt->h.b32[(n)]) #define COUNT (ctxt->count) #define BCOUNT (ctxt->c.b64[0] / 8) #define W(n) (ctxt->m.b32[(n)]) #define PUTBYTE(x) \ do { \ ctxt->m.b8[(COUNT % 64)] = (x); \ COUNT++; \ COUNT %= 64; \ ctxt->c.b64[0] += 8; \ if (COUNT % 64 == 0) \ sha1_step(ctxt); \ } while (0) #define PUTPAD(x) \ do { \ ctxt->m.b8[(COUNT % 64)] = (x); \ COUNT++; \ COUNT %= 64; \ if (COUNT % 64 == 0) \ sha1_step(ctxt); \ } while (0) static void sha1_step(struct sha1_ctxt *); static void sha1_step(struct sha1_ctxt * ctxt) { uint32_t a, b, c, d, e; size_t t, s; uint32_t tmp; #ifndef WORDS_BIGENDIAN struct sha1_ctxt tctxt; memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64); ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2]; ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[3] = tctxt.m.b8[0]; ctxt->m.b8[4] = tctxt.m.b8[7]; ctxt->m.b8[5] = tctxt.m.b8[6]; ctxt->m.b8[6] = tctxt.m.b8[5]; ctxt->m.b8[7] = tctxt.m.b8[4]; ctxt->m.b8[8] = tctxt.m.b8[11]; ctxt->m.b8[9] = tctxt.m.b8[10]; ctxt->m.b8[10] = tctxt.m.b8[9]; ctxt->m.b8[11] = tctxt.m.b8[8]; ctxt->m.b8[12] = tctxt.m.b8[15]; ctxt->m.b8[13] = tctxt.m.b8[14]; ctxt->m.b8[14] = tctxt.m.b8[13]; ctxt->m.b8[15] = tctxt.m.b8[12]; ctxt->m.b8[16] = tctxt.m.b8[19]; ctxt->m.b8[17] = tctxt.m.b8[18]; ctxt->m.b8[18] = tctxt.m.b8[17]; ctxt->m.b8[19] = tctxt.m.b8[16]; ctxt->m.b8[20] = tctxt.m.b8[23]; ctxt->m.b8[21] = tctxt.m.b8[22]; ctxt->m.b8[22] = tctxt.m.b8[21]; ctxt->m.b8[23] = tctxt.m.b8[20]; ctxt->m.b8[24] = tctxt.m.b8[27]; ctxt->m.b8[25] = tctxt.m.b8[26]; ctxt->m.b8[26] = tctxt.m.b8[25]; ctxt->m.b8[27] = tctxt.m.b8[24]; ctxt->m.b8[28] = tctxt.m.b8[31]; ctxt->m.b8[29] = tctxt.m.b8[30]; ctxt->m.b8[30] = tctxt.m.b8[29]; ctxt->m.b8[31] = tctxt.m.b8[28]; ctxt->m.b8[32] = tctxt.m.b8[35]; ctxt->m.b8[33] = tctxt.m.b8[34]; ctxt->m.b8[34] = tctxt.m.b8[33]; ctxt->m.b8[35] = tctxt.m.b8[32]; ctxt->m.b8[36] = tctxt.m.b8[39]; ctxt->m.b8[37] = tctxt.m.b8[38]; ctxt->m.b8[38] = tctxt.m.b8[37]; ctxt->m.b8[39] = tctxt.m.b8[36]; ctxt->m.b8[40] = tctxt.m.b8[43]; ctxt->m.b8[41] = tctxt.m.b8[42]; ctxt->m.b8[42] = tctxt.m.b8[41]; ctxt->m.b8[43] = tctxt.m.b8[40]; ctxt->m.b8[44] = tctxt.m.b8[47]; ctxt->m.b8[45] = tctxt.m.b8[46]; ctxt->m.b8[46] = tctxt.m.b8[45]; ctxt->m.b8[47] = tctxt.m.b8[44]; ctxt->m.b8[48] = tctxt.m.b8[51]; ctxt->m.b8[49] = tctxt.m.b8[50]; ctxt->m.b8[50] = tctxt.m.b8[49]; ctxt->m.b8[51] = tctxt.m.b8[48]; ctxt->m.b8[52] = tctxt.m.b8[55]; ctxt->m.b8[53] = tctxt.m.b8[54]; ctxt->m.b8[54] = tctxt.m.b8[53]; ctxt->m.b8[55] = tctxt.m.b8[52]; ctxt->m.b8[56] = tctxt.m.b8[59]; ctxt->m.b8[57] = tctxt.m.b8[58]; ctxt->m.b8[58] = tctxt.m.b8[57]; ctxt->m.b8[59] = tctxt.m.b8[56]; ctxt->m.b8[60] = tctxt.m.b8[63]; ctxt->m.b8[61] = tctxt.m.b8[62]; ctxt->m.b8[62] = tctxt.m.b8[61]; ctxt->m.b8[63] = tctxt.m.b8[60]; #endif a = H(0); b = H(1); c = H(2); d = H(3); e = H(4); for (t = 0; t < 20; t++) { s = t & 0x0f; if (t >= 16) W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 20; t < 40; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 40; t < 60; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 60; t < 80; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } H(0) = H(0) + a; H(1) = H(1) + b; H(2) = H(2) + c; H(3) = H(3) + d; H(4) = H(4) + e; memset(&ctxt->m.b8[0], 0, 64); } /*------------------------------------------------------------*/ void sha1_init(struct sha1_ctxt * ctxt) { memset(ctxt, 0, sizeof(struct sha1_ctxt)); H(0) = 0x67452301; H(1) = 0xefcdab89; H(2) = 0x98badcfe; H(3) = 0x10325476; H(4) = 0xc3d2e1f0; } void sha1_pad(struct sha1_ctxt * ctxt) { size_t padlen; /* pad length in bytes */ size_t padstart; PUTPAD(0x80); padstart = COUNT % 64; padlen = 64 - padstart; if (padlen < 8) { memset(&ctxt->m.b8[padstart], 0, padlen); COUNT += (uint8_t) padlen; COUNT %= 64; sha1_step(ctxt); padstart = COUNT % 64; /* should be 0 */ padlen = 64 - padstart; /* should be 64 */ } memset(&ctxt->m.b8[padstart], 0, padlen - 8); COUNT += ((uint8_t) padlen - 8); COUNT %= 64; #ifdef WORDS_BIGENDIAN PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]); #else PUTPAD(ctxt->c.b8[7]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[0]); #endif } void sha1_loop(struct sha1_ctxt * ctxt, const uint8_t *input0, size_t len) { const uint8_t *input; size_t gaplen; size_t gapstart; size_t off; size_t copysiz; input = (const uint8_t *) input0; off = 0; while (off < len) { gapstart = COUNT % 64; gaplen = 64 - gapstart; copysiz = (gaplen < len - off) ? gaplen : len - off; memmove(&ctxt->m.b8[gapstart], &input[off], copysiz); COUNT += (uint8_t) copysiz; COUNT %= 64; ctxt->c.b64[0] += copysiz * 8; if (COUNT % 64 == 0) sha1_step(ctxt); off += copysiz; } } void sha1_result(struct sha1_ctxt * ctxt, uint8_t *digest0) { uint8_t *digest; digest = (uint8_t *) digest0; sha1_pad(ctxt); #ifdef WORDS_BIGENDIAN memmove(digest, &ctxt->h.b8[0], 20); #else digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2]; digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0]; digest[4] = ctxt->h.b8[7]; digest[5] = ctxt->h.b8[6]; digest[6] = ctxt->h.b8[5]; digest[7] = ctxt->h.b8[4]; digest[8] = ctxt->h.b8[11]; digest[9] = ctxt->h.b8[10]; digest[10] = ctxt->h.b8[9]; digest[11] = ctxt->h.b8[8]; digest[12] = ctxt->h.b8[15]; digest[13] = ctxt->h.b8[14]; digest[14] = ctxt->h.b8[13]; digest[15] = ctxt->h.b8[12]; digest[16] = ctxt->h.b8[19]; digest[17] = ctxt->h.b8[18]; digest[18] = ctxt->h.b8[17]; digest[19] = ctxt->h.b8[16]; #endif } czmq-3.0.2/src/foreign/sha1/sha1.h0000664000175000017500000000511712533666571015673 0ustar00phph00000000000000/* contrib/pgcrypto/sha1.h */ /* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm * implemented by Jun-ichiro itojun Itoh */ #ifndef _NETINET6_SHA1_H_ #define _NETINET6_SHA1_H_ struct sha1_ctxt { union { uint8_t b8[20]; uint32_t b32[5]; } h; union { uint8_t b8[8]; uint64_t b64[1]; } c; union { uint8_t b8[64]; uint32_t b32[16]; } m; uint8_t count; }; extern void sha1_init(struct sha1_ctxt *); extern void sha1_pad(struct sha1_ctxt *); extern void sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t); extern void sha1_result(struct sha1_ctxt *, uint8_t *); // Compatibility with OpenSSL API #define SHA_DIGEST_LENGTH 20 typedef struct sha1_ctxt SHA_CTX; #define SHA1_Init(x) sha1_init((x)) #define SHA1_Update(x, y, z) sha1_loop((x), (y), (z)) #define SHA1_Final(x, y) sha1_result((y), (x)) #define SHA1_RESULTLEN (160/8) #endif /* _NETINET6_SHA1_H_ */ czmq-3.0.2/src/zdir_patch.c0000664000175000017500000001315012505070716014655 0ustar00phph00000000000000/* ========================================================================= zdir_patch - work with directory patches A patch is a change to the directory (create/delete). Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time). @discuss @end */ #include "../include/czmq.h" // Structure of our class // If you modify this beware to also change _dup struct _zdir_patch_t { char *path; // Directory path char *vpath; // Virtual file path zfile_t *file; // File we refer to zdir_patch_op_t op; // Operation char *digest; // File SHA-1 digest }; // -------------------------------------------------------------------------- // Constructor // Create new patch, create virtual path from alias zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, zdir_patch_op_t op, const char *alias) { zdir_patch_t *self = (zdir_patch_t *) zmalloc (sizeof (zdir_patch_t)); if (!self) return NULL; self->path = strdup (path); if (self->path) self->file = zfile_dup (file); if (!self->file) { zdir_patch_destroy (&self); return NULL; } self->op = op; // Calculate virtual path for patch (remove path, prefix alias) const char *filename = zfile_filename (file, path); if (!filename) { zdir_patch_destroy (&self); return NULL; } assert (*filename != '/'); self->vpath = (char *) zmalloc (strlen (alias) + strlen (filename) + 2); if (!self->vpath) { zdir_patch_destroy (&self); return NULL; } if (alias [strlen (alias) - 1] == '/') sprintf (self->vpath, "%s%s", alias, filename); else sprintf (self->vpath, "%s/%s", alias, filename); return self; } // -------------------------------------------------------------------------- // Destroy a patch void zdir_patch_destroy (zdir_patch_t **self_p) { assert (self_p); if (*self_p) { zdir_patch_t *self = *self_p; free (self->path); free (self->vpath); free (self->digest); zfile_destroy (&self->file); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. zdir_patch_t * zdir_patch_dup (zdir_patch_t *self) { if (self) { zdir_patch_t *copy = (zdir_patch_t *) zmalloc (sizeof (zdir_patch_t)); if (copy) { copy->op = self->op; copy->path = strdup (self->path); if (copy->path) copy->file = zfile_dup (self->file); if (copy->file) copy->vpath = strdup (self->vpath); if (copy->vpath) // Don't recalculate hash when we duplicate patch copy->digest = self->digest ? strdup (self->digest) : NULL; if (copy->digest == NULL && copy->op != patch_delete) zdir_patch_destroy (©); } return copy; } else return NULL; } // -------------------------------------------------------------------------- // Return patch file directory path const char * zdir_patch_path (zdir_patch_t *self) { assert (self); return self->path; } // -------------------------------------------------------------------------- // Return patch file item zfile_t * zdir_patch_file (zdir_patch_t *self) { assert (self); return self->file; } // -------------------------------------------------------------------------- // Return operation zdir_patch_op_t zdir_patch_op (zdir_patch_t *self) { assert (self); return self->op; } // -------------------------------------------------------------------------- // Return patch virtual file path const char * zdir_patch_vpath (zdir_patch_t *self) { assert (self); return self->vpath; } // -------------------------------------------------------------------------- // Calculate hash digest for file (create only) void zdir_patch_digest_set (zdir_patch_t *self) { if (self->op == patch_create && self->digest == NULL) { self->digest = strdup (zfile_digest (self->file)); assert (self->digest); } } // -------------------------------------------------------------------------- // Return hash digest for patch file (create only) const char * zdir_patch_digest (zdir_patch_t *self) { assert (self); return self->digest; } // -------------------------------------------------------------------------- // Self test of this class void zdir_patch_test (bool verbose) { printf (" * zdir_patch: "); // @selftest zfile_t *file = zfile_new (".", "bilbo"); assert (file); zdir_patch_t *patch = zdir_patch_new (".", file, patch_create, "/"); assert (patch); zfile_destroy (&file); file = zdir_patch_file (patch); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (streq (zdir_patch_vpath (patch), "/bilbo")); zdir_patch_destroy (&patch); // @end printf ("OK\n"); } czmq-3.0.2/src/zpoller.c0000664000175000017500000002255212522736175014232 0ustar00phph00000000000000/* ========================================================================= zpoller - trivial socket poller class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. =========================================================================*/ /* @header The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll API, for the very common case of reading from a number of sockets. It does not provide polling for output, nor polling on file handles. If you need either of these, use the zmq_poll API directly. @discuss @end */ #include "../include/czmq.h" // Structure of our class struct _zpoller_t { zlist_t *reader_list; // List of sockets to read from zmq_pollitem_t *poll_set; // Current zmq_poll set void **poll_readers; // Matching table of socket readers size_t poll_size; // Size of poll set bool need_rebuild; // Does pollset needs rebuilding? bool expired; // Did poll timer expire? bool terminated; // Did poll call end with EINTR? bool ignore_interrupts; // Should this poller ignore zsys_interrupted? }; static int s_rebuild_poll_set (zpoller_t *self); // -------------------------------------------------------------------------- // Constructor // Create new poller; the reader can be a libzmq socket (void *), a zsock_t // instance, or a zactor_t instance. zpoller_t * zpoller_new (void *reader, ...) { zpoller_t *self = (zpoller_t *) zmalloc (sizeof (zpoller_t)); if (self) { self->reader_list = zlist_new (); if (self->reader_list) { self->need_rebuild = true; va_list args; va_start (args, reader); while (reader) { if (zlist_append (self->reader_list, reader)) { zpoller_destroy (&self); break; } reader = va_arg (args, void *); } va_end (args); } else zpoller_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Destroy a poller void zpoller_destroy (zpoller_t **self_p) { assert (self_p); if (*self_p) { zpoller_t *self = *self_p; zlist_destroy (&self->reader_list); free (self->poll_readers); free (self->poll_set); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int zpoller_add (zpoller_t *self, void *reader) { assert (self); assert (reader); int rc = zlist_append (self->reader_list, reader); self->need_rebuild = true; return rc; } // -------------------------------------------------------------------------- // Remove a reader from the poller; returns 0 if OK, -1 on failure. The // reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t // instance. int zpoller_remove (zpoller_t *self, void *reader) { assert (self); assert (reader); zlist_remove (self->reader_list, reader); self->need_rebuild = true; return 0; } // -------------------------------------------------------------------------- // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * zpoller_wait (zpoller_t *self, int timeout) { self->expired = false; if (!self->ignore_interrupts && zsys_interrupted) { self->terminated = true; return NULL; } else self->terminated = false; if (self->need_rebuild) s_rebuild_poll_set (self); int rc = zmq_poll (self->poll_set, (int) self->poll_size, timeout * ZMQ_POLL_MSEC); if (rc > 0) { uint reader = 0; for (reader = 0; reader < self->poll_size; reader++) if (self->poll_set [reader].revents & ZMQ_POLLIN) return self->poll_readers [reader]; } else if (rc == -1 || (!self->ignore_interrupts && zsys_interrupted)) self->terminated = true; else if (rc == 0) self->expired = true; return NULL; } static int s_rebuild_poll_set (zpoller_t *self) { free (self->poll_set); self->poll_set = NULL; free (self->poll_readers); self->poll_readers = NULL; self->poll_size = zlist_size (self->reader_list); self->poll_set = (zmq_pollitem_t *) zmalloc (self->poll_size * sizeof (zmq_pollitem_t)); self->poll_readers = (void **) zmalloc (self->poll_size * sizeof (void *)); if (!self->poll_set || !self->poll_readers) return -1; uint reader_nbr = 0; void *reader = zlist_first (self->reader_list); while (reader) { self->poll_readers [reader_nbr] = reader; void *socket = zsock_resolve (reader); if (socket == NULL) { self->poll_set [reader_nbr].socket = NULL; #ifdef _WIN32 self->poll_set [reader_nbr].fd = *(SOCKET *) reader; #else self->poll_set [reader_nbr].fd = *(int *) reader; #endif } else self->poll_set [reader_nbr].socket = socket; self->poll_set [reader_nbr].events = ZMQ_POLLIN; reader_nbr++; reader = zlist_next (self->reader_list); } self->need_rebuild = false; return 0; } // -------------------------------------------------------------------------- // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool zpoller_expired (zpoller_t *self) { assert (self); return self->expired; } // -------------------------------------------------------------------------- // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool zpoller_terminated (zpoller_t *self) { assert (self); return self->terminated; } // -------------------------------------------------------------------------- // Ignore zsys_interrupted flag in this poller. By default, a zpoller_wait will // return immediately if detects zsys_interrupted is set to something other than // zero. Calling zpoller_ignore_interrupts will supress this behavior. void zpoller_ignore_interrupts(zpoller_t *self) { assert (self); self->ignore_interrupts = true; } // -------------------------------------------------------------------------- // Self test of this class void zpoller_test (bool verbose) { printf (" * zpoller: "); // @selftest // Create a few sockets zsock_t *vent = zsock_new (ZMQ_PUSH); assert (vent); int port_nbr = zsock_bind (vent, "tcp://127.0.0.1:*"); assert (port_nbr != -1); zsock_t *sink = zsock_new (ZMQ_PULL); assert (sink); int rc = zsock_connect (sink, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zsock_t *bowl = zsock_new (ZMQ_PULL); assert (bowl); zsock_t *dish = zsock_new (ZMQ_PULL); assert (dish); // Set-up poller zpoller_t *poller = zpoller_new (bowl, dish, NULL); assert (poller); // Add a reader to the existing poller rc = zpoller_add (poller, sink); assert (rc == 0); zstr_send (vent, "Hello, World"); // We expect a message only on the sink zsock_t *which = (zsock_t *) zpoller_wait (poller, -1); assert (which == sink); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); char *message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); // Stop polling reader rc = zpoller_remove (poller, sink); assert (rc == 0); // Check we can poll an FD rc = zsock_connect (bowl, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); SOCKET fd = zsock_fd (bowl); rc = zpoller_add (poller, (void *) &fd); assert (rc != -1); zstr_send (vent, "Hello again, world"); assert (zpoller_wait (poller, 500) == &fd); // Check whether poller properly ignores zsys_interrupted flag // when asked to zsys_interrupted = 1; zpoller_wait (poller, 0); assert (zpoller_terminated (poller)); zpoller_ignore_interrupts (poller); zpoller_wait (poller, 0); assert (!zpoller_terminated (poller)); zsys_interrupted = 0; // Destroy poller and sockets zpoller_destroy (&poller); zsock_destroy (&vent); zsock_destroy (&sink); zsock_destroy (&bowl); zsock_destroy (&dish); // @end printf ("OK\n"); } czmq-3.0.2/src/czmq_selftest.c0000664000175000017500000000600212535241704015407 0ustar00phph00000000000000/* ========================================================================= czmq_selftest.c - run selftests Runs all selftests. ------------------------------------------------------------------------- Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ ========================================================================= */ #include "czmq_classes.h" int main (int argc, char *argv []) { bool verbose; if (argc == 2 && streq (argv [1], "-v")) verbose = true; else verbose = false; printf ("Running czmq selftests...\n"); zactor_test (verbose); zauth_test (verbose); zarmour_test (verbose); zbeacon_test (verbose); zcert_test (verbose); zcertstore_test (verbose); zchunk_test (verbose); zclock_test (verbose); zconfig_test (verbose); zdigest_test (verbose); zdir_test (verbose); zdir_patch_test (verbose); zfile_test (verbose); zframe_test (verbose); zgossip_test (verbose); zhashx_test (verbose); ziflist_test (verbose); zlistx_test (verbose); zloop_test (verbose); zmonitor_test (verbose); zmsg_test (verbose); zpoller_test (verbose); zproxy_test (verbose); zrex_test (verbose); zsock_test (verbose); zsock_option_test (verbose); zstr_test (verbose); zsys_test (verbose); zuuid_test (verbose); zgossip_msg_test (verbose); zauth_v2_test (verbose); zbeacon_v2_test (verbose); zctx_test (verbose); zhash_test (verbose); zlist_test (verbose); zmonitor_v2_test (verbose); zmutex_test (verbose); zproxy_v2_test (verbose); zsocket_test (verbose); zsockopt_test (verbose); zthread_test (verbose); printf ("Tests passed OK\n"); return 0; } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ */ czmq-3.0.2/src/zactor.c0000664000175000017500000002116212515173670014036 0ustar00phph00000000000000/* ========================================================================= zactor - simple actor framework Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zactor class provides a simple actor framework. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard. A CZMQ actor is implemented as a thread plus a PAIR-PAIR pipe. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished.) A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, and zpoller. (zloop somehow escaped and needs catching.) An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command. @discuss @end */ #include "../include/czmq.h" // zactor_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZACTOR_TAG 0x0005cafe // Structure of our class struct _zactor_t { uint32_t tag; // Object tag for runtime detection zsock_t *pipe; // Front-end pipe through to actor }; // This shims the OS thread APIs typedef struct { zactor_fn *handler; zsock_t *pipe; // Pipe back to parent void *args; // Application arguments } shim_t; // -------------------------------------------------------------------------- // Thread creation code, wrapping POSIX and Win32 thread APIs #if defined (__UNIX__) // Thread shim for UNIX calls the actual thread and cleans up afterwards. static void * s_thread_shim (void *args) { assert (args); shim_t *shim = (shim_t *) args; shim->handler (shim->pipe, shim->args); // Do not block, if the other end of the pipe is already deleted zsock_set_sndtimeo (shim->pipe, 0); zsock_signal (shim->pipe, 0); zsock_destroy (&shim->pipe); free (shim); return NULL; } #elif defined (__WINDOWS__) // Thread shim for Windows that wraps a POSIX-style thread handler // and does the _endthreadex for us automatically. static unsigned __stdcall s_thread_shim (void *args) { assert (args); shim_t *shim = (shim_t *) args; shim->handler (shim->pipe, shim->args); // Do not block, if the other end of the pipe is already deleted zsock_set_sndtimeo (shim->pipe, 0); zsock_signal (shim->pipe, 0); zsock_destroy (&shim->pipe); free (shim); _endthreadex (0); // Terminates thread return 0; } #endif // -------------------------------------------------------------------------- // Create a new actor. zactor_t * zactor_new (zactor_fn *actor, void *args) { zactor_t *self = (zactor_t *) zmalloc (sizeof (zactor_t)); if (!self) return NULL; self->tag = ZACTOR_TAG; shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t)); if (!shim) { zactor_destroy (&self); return NULL; } shim->pipe = zsys_create_pipe (&self->pipe); if (!shim->pipe) { zactor_destroy (&self); return NULL; } shim->handler = actor; shim->args = args; #if defined (__UNIX__) pthread_t thread; pthread_create (&thread, NULL, s_thread_shim, shim); pthread_detach (thread); #elif defined (__WINDOWS__) HANDLE handle = (HANDLE) _beginthreadex ( NULL, // Handle is private to this process 0, // Use a default stack size for new thread &s_thread_shim, // Start real thread function via this shim shim, // Which gets arguments shim CREATE_SUSPENDED, // Set thread priority before starting it NULL); // We don't use the thread ID assert (handle); // Set child thread priority to same as current int priority = GetThreadPriority (GetCurrentThread ()); SetThreadPriority (handle, priority); // Start thread & release resources ResumeThread (handle); CloseHandle (handle); #endif // Mandatory handshake for new actor so that constructor returns only // when actor has also initialized. This eliminates timing issues at // application start up. zsock_wait (self->pipe); return self; } // -------------------------------------------------------------------------- // Destroy the actor. void zactor_destroy (zactor_t **self_p) { assert (self_p); if (*self_p) { zactor_t *self = *self_p; assert (zactor_is (self)); // Signal the actor to end and wait for the thread exit code // If the pipe isn't connected any longer, assume child thread // has already quit due to other reasons and don't collect the // exit signal. zsock_set_sndtimeo (self->pipe, 0); if (zstr_send (self->pipe, "$TERM") == 0) zsock_wait (self->pipe); zsock_destroy (&self->pipe); self->tag = 0xDeadBeef; free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int zactor_send (zactor_t *self, zmsg_t **msg_p) { return zmsg_send (msg_p, self); } // -------------------------------------------------------------------------- // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. zmsg_t * zactor_recv (zactor_t *self) { return zmsg_recv (self); } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zactor_t. bool zactor_is (void *self) { assert (self); return ((zactor_t *) self)->tag == ZACTOR_TAG; } // -------------------------------------------------------------------------- // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * zactor_resolve (void *self) { assert (self); if (zactor_is (self)) return zsock_resolve (((zactor_t *) self)->pipe); else return self; } // -------------------------------------------------------------------------- // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. zsock_t * zactor_sock (zactor_t *self) { assert (self); assert (zactor_is (self)); return self->pipe; } // -------------------------------------------------------------------------- // Actor // must call zsock_signal (pipe) when initialized // must listen to pipe and exit on $TERM command static void echo_actor (zsock_t *pipe, void *args) { // Do some initialization assert (streq ((char *) args, "Hello, World")); zsock_signal (pipe, 0); bool terminated = false; while (!terminated) { zmsg_t *msg = zmsg_recv (pipe); if (!msg) break; // Interrupted char *command = zmsg_popstr (msg); // All actors must handle $TERM in this way if (streq (command, "$TERM")) terminated = true; else // This is an example command for our test actor if (streq (command, "ECHO")) zmsg_send (&msg, pipe); else { puts ("E: invalid message to actor"); assert (false); } free (command); zmsg_destroy (&msg); } } // -------------------------------------------------------------------------- // Selftest void zactor_test (bool verbose) { printf (" * zactor: "); // @selftest zactor_t *actor = zactor_new (echo_actor, "Hello, World"); assert (actor); zstr_sendx (actor, "ECHO", "This is a string", NULL); char *string = zstr_recv (actor); assert (streq (string, "This is a string")); free (string); zactor_destroy (&actor); // @end printf ("OK\n"); } czmq-3.0.2/src/zbeacon_v2.c0000664000175000017500000004400712505070716014563 0ustar00phph00000000000000/* ========================================================================= zbeacon - LAN discovery and presence (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. The zbeacon API provides a incoming beacons on a ZeroMQ socket (the pipe) that you can configure, poll on, and receive messages on. Incoming beacons are always delivered as two frames: the ipaddress of the sender (a string), and the beacon data itself (binary, as published). @discuss This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets. @end */ #include "platform.h" #include "../include/czmq.h" // Constants #define INTERVAL_DFLT 1000 // Default interval = 1 second // Structure of our class struct _zbeacon_t { void *pipe; // Pipe through to backend agent char *hostname; // Our own address as string zctx_t *ctx; // TODO: actorize this class }; // Background task does the real I/O static void s_agent_task (void *args, zctx_t *ctx, void *pipe); // -------------------------------------------------------------------------- // Create a new beacon on a certain UDP port. If the system does not // support UDP broadcasts (lacking a useful interface), returns NULL. // To force the beacon to operate on a given port, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() beforehand. // If you are using the new zsock API then pass NULL as the ctx here. zbeacon_t * zbeacon_new (zctx_t *ctx, int port_nbr) { zbeacon_t *self = (zbeacon_t *) zmalloc (sizeof (zbeacon_t)); if (!self) return NULL; // If user passes a ctx, use that, else take the global context from // zsys and use that. This provides compatibility with old zsocket // and new zsock APIs. if (ctx) self->ctx = zctx_shadow (ctx); else self->ctx = zctx_shadow_zmq_ctx (zsys_init ()); // Start background agent and wait for it to initialize self->pipe = zthread_fork (self->ctx, s_agent_task, NULL); if (self->pipe) { zstr_sendf (self->pipe, "%d", port_nbr); self->hostname = zstr_recv (self->pipe); if (streq (self->hostname, "-")) { free (self->hostname); free (self); self = NULL; } } else zbeacon_destroy (&self); return self; } // -------------------------------------------------------------------------- // Destructor void zbeacon_destroy (zbeacon_t **self_p) { assert (self_p); if (*self_p) { zbeacon_t *self = *self_p; if (self->pipe) { zstr_send (self->pipe, "TERMINATE"); char *reply = zstr_recv (self->pipe); zstr_free (&reply); } zctx_destroy (&self->ctx); free (self->hostname); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Set broadcast interval in milliseconds void zbeacon_set_interval (zbeacon_t *self, int interval) { assert (self); zstr_sendm (self->pipe, "INTERVAL"); zstr_sendf (self->pipe, "%d", interval); } // -------------------------------------------------------------------------- // Filter out any beacon that looks exactly like ours void zbeacon_noecho (zbeacon_t *self) { assert (self); zstr_send (self->pipe, "NOECHO"); } // -------------------------------------------------------------------------- // Start broadcasting beacon to peers at the specified interval void zbeacon_publish (zbeacon_t *self, byte *transmit, size_t size) { assert (self); assert (transmit); assert (size > 0 && size <= UDP_FRAME_MAX); zmsg_t *msg = zmsg_new (); assert (msg); zmsg_addstr (msg, "PUBLISH"); zmsg_addmem (msg, transmit, size); zmsg_send (&msg, self->pipe); } // -------------------------------------------------------------------------- // Stop broadcasting beacons void zbeacon_silence (zbeacon_t *self) { assert (self); zstr_send (self->pipe, "SILENCE"); } // -------------------------------------------------------------------------- // Start listening to other peers; zero-sized filter means get everything void zbeacon_subscribe (zbeacon_t *self, byte *filter, size_t size) { assert (self); assert (size <= UDP_FRAME_MAX); zmsg_t *msg = zmsg_new (); assert (msg); zmsg_addstr (msg, "SUBSCRIBE"); zmsg_addmem (msg, filter, size); zmsg_send (&msg, self->pipe); } // -------------------------------------------------------------------------- // Stop listening to other peers void zbeacon_unsubscribe (zbeacon_t *self) { zstr_send (self->pipe, "UNSUBSCRIBE"); } // -------------------------------------------------------------------------- // Get beacon ZeroMQ socket, for polling or receiving messages void * zbeacon_socket (zbeacon_t *self) { assert (self); return self->pipe; } // -------------------------------------------------------------------------- // Return our own IP address as printable string char * zbeacon_hostname (zbeacon_t *self) { assert (self); return self->hostname; } // -------------------------------------------------------------------------- // Backend agent implementation // Agent instance typedef struct { void *pipe; // Socket to talk back to application SOCKET udpsock; // UDP socket for send/recv int port_nbr; // UDP port number we work on int interval; // Beacon broadcast interval bool noecho; // Ignore own (unique) beacons? bool terminated; // API shut us down int64_t ping_at; // Next broadcast time zframe_t *transmit; // Beacon transmit data zframe_t *filter; // Beacon filter data inaddr_t address; // Our own address inaddr_t broadcast; // Our broadcast address } agent_t; // Prototypes for local functions we use in the agent static agent_t * s_agent_new (void *pipe, int port_nbr); static void s_agent_destroy (agent_t **self_p); static void s_get_interface (agent_t *self); static void s_api_command (agent_t *self); static void s_beacon_recv (agent_t *self); // This is the background task static void s_agent_task (void *args, zctx_t *ctx, void *pipe) { // Get port argument from caller char *port_str = zstr_recv (pipe); assert (port_str); // Create agent instance agent_t *self = s_agent_new (pipe, atoi (port_str)); zstr_free (&port_str); if (!self) return; // Give up if we couldn't initialize while (!self->terminated) { // Poll on API pipe and on UDP socket zmq_pollitem_t pollitems [] = { { self->pipe, 0, ZMQ_POLLIN, 0 }, { NULL, self->udpsock, ZMQ_POLLIN, 0 } }; long timeout = -1; if (self->transmit) { timeout = (long) (self->ping_at - zclock_mono ()); if (timeout < 0) timeout = 0; } if (zmq_poll (pollitems, 2, timeout * ZMQ_POLL_MSEC) == -1) break; // Interrupted if (pollitems [0].revents & ZMQ_POLLIN) s_api_command (self); if (pollitems [1].revents & ZMQ_POLLIN) s_beacon_recv (self); if (self->transmit && zclock_mono () >= self->ping_at) { // Send beacon to any listening peers zsys_udp_send (self->udpsock, self->transmit, &self->broadcast); self->ping_at = zclock_mono () + self->interval; } } s_agent_destroy (&self); } // Create and initialize new agent instance static agent_t * s_agent_new (void *pipe, int port_nbr) { agent_t *self = (agent_t *) zmalloc (sizeof (agent_t)); if (!self) return NULL; self->pipe = pipe; self->port_nbr = port_nbr; self->interval = INTERVAL_DFLT; // Create our UDP socket self->udpsock = zsys_udp_new (false); if (self->udpsock == INVALID_SOCKET) { free (self); // No more file handles - forget it return NULL; } // PROBLEM: this design will not survive the network interface // being killed and restarted while the program is running // Get the network interface s_get_interface (self); // Bind to the port on all interfaces #if (defined (__WINDOWS__)) inaddr_t sockaddr = self->address; #elif (defined (__APPLE__)) inaddr_t sockaddr = self->broadcast; sockaddr.sin_addr.s_addr = htons (INADDR_ANY); #else inaddr_t sockaddr = self->broadcast; #endif int rc = bind (self->udpsock, (struct sockaddr *) &sockaddr, sizeof (inaddr_t)); if (rc == SOCKET_ERROR) zsys_socket_error ("bind"); // Send our hostname back to API // PROBLEM: this hostname will not be accurate when the node // has more than one active interface. char hostname [NI_MAXHOST]; rc = getnameinfo ((struct sockaddr *) &self->address, sizeof (inaddr_t), hostname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (rc == 0) { // It all looks OK zstr_send (pipe, hostname); return self; } else { // Interface looks unsupported, abort zstr_send (pipe, "-"); zsys_udp_close (self->udpsock); free (self); return NULL; } } // Get the actual network interface we're working on. static void s_get_interface (agent_t *self) { const char *iface = zsys_interface (); if (streq (iface, "*")) { // Force binding to INADDR_ANY and sending to INADDR_BROADCAST self->broadcast.sin_family = AF_INET; self->broadcast.sin_addr.s_addr = INADDR_BROADCAST; self->broadcast.sin_port = htons (self->port_nbr); self->address = self->broadcast; self->address.sin_addr.s_addr = INADDR_ANY; } else { ziflist_t *iflist = ziflist_new (); assert (iflist); const char *name = ziflist_first (iflist); if (*iface) { while (name) { if (streq (iface, name)) break; // iface is known, so allow it name = ziflist_next (iflist); } } if (name) { // Using inet_addr instead of inet_aton or inet_atop because these // are not supported in Win XP self->broadcast.sin_family = AF_INET; self->broadcast.sin_addr.s_addr = inet_addr (ziflist_broadcast (iflist)); self->broadcast.sin_port = htons (self->port_nbr); self->address = self->broadcast; self->address.sin_addr.s_addr = inet_addr (ziflist_address (iflist)); } else zsys_error ("No adapter found, ZSYS_INTERFACE=%s isn't helping", iface); ziflist_destroy (&iflist); } } // Handle command from API static void s_api_command (agent_t *self) { char *command = zstr_recv (self->pipe); if (streq (command, "INTERVAL")) { char *interval = zstr_recv (self->pipe); self->interval = atoi (interval); zstr_free (&interval); } else if (streq (command, "NOECHO")) self->noecho = true; else if (streq (command, "PUBLISH")) { zframe_destroy (&self->transmit); self->transmit = zframe_recv (self->pipe); assert (self->transmit); // Start broadcasting immediately self->ping_at = zclock_mono (); } else if (streq (command, "SILENCE")) zframe_destroy (&self->transmit); else if (streq (command, "SUBSCRIBE")) { zframe_destroy (&self->filter); self->filter = zframe_recv (self->pipe); } else if (streq (command, "UNSUBSCRIBE")) zframe_destroy (&self->filter); else if (streq (command, "TERMINATE")) { self->terminated = true; zstr_send (self->pipe, "OK"); } else zsys_error ("zbeacon: unexpected API command '%s'\n", command); zstr_free (&command); } // Receive and filter the waiting beacon static void s_beacon_recv (agent_t *self) { assert (self); char peername [INET_ADDRSTRLEN]; zframe_t *frame = zsys_udp_recv (self->udpsock, peername); // If filter is set, check that beacon matches it bool is_valid = false; if (self->filter) { byte *filter_data = zframe_data (self->filter); size_t filter_size = zframe_size (self->filter); if (zframe_size (frame) >= filter_size && memcmp (zframe_data (frame), filter_data, filter_size) == 0) is_valid = true; } // If valid, check for echoed beacons (i.e. our own broadcast) if (is_valid && self->noecho && self->transmit) { byte *transmit_data = zframe_data (self->transmit); size_t transmit_size = zframe_size (self->transmit); if (zframe_size (frame) == transmit_size && memcmp (zframe_data (frame), transmit_data, transmit_size) == 0) is_valid = false; } // If still a valid beacon, send on to the API if (is_valid) { zmsg_t *msg = zmsg_new (); assert (msg); zmsg_addstr (msg, peername); zmsg_append (msg, &frame); zmsg_send (&msg, self->pipe); } else zframe_destroy (&frame); } // Destroy agent instance static void s_agent_destroy (agent_t **self_p) { assert (self_p); if (*self_p) { agent_t *self = *self_p; zsys_udp_close (self->udpsock); zframe_destroy (&self->transmit); zframe_destroy (&self->filter); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Self test of this class // // If this test fails with an unable to bind error, try specifying the default // interface to be used for zbeacon with the ZSYS_INTERFACE environment // variable. void zbeacon_v2_test (bool verbose) { printf (" * zbeacon (deprecated): "); // @selftest // Create beacon to broadcast our service zctx_t *ctx = zctx_new (); assert (ctx); zbeacon_t *service_beacon = zbeacon_new (ctx, 9999); if (service_beacon == NULL) { printf ("OK (skipping test, no UDP discovery)\n"); return; } // Create a service socket and bind to an ephemeral port zsock_t *service = zsock_new (ZMQ_PUB); assert (service); int port_nbr = zsock_bind (service, "tcp://127.0.0.1:*"); byte announcement [2] = { (port_nbr >> 8) & 0xFF, port_nbr & 0xFF }; zbeacon_set_interval (service_beacon, 100); zbeacon_publish (service_beacon, announcement, 2); // Create beacon to lookup service zbeacon_t *client_beacon = zbeacon_new (ctx, 9999); assert (client_beacon); zbeacon_subscribe (client_beacon, NULL, 0); // Wait for at most 1/2 second if there's no broadcast networking zsocket_set_rcvtimeo (zbeacon_socket (client_beacon), 500); char *ipaddress = zstr_recv (zbeacon_socket (client_beacon)); if (ipaddress) { zframe_t *content = zframe_recv (zbeacon_socket (client_beacon)); int received_port = (zframe_data (content) [0] << 8) + zframe_data (content) [1]; assert (received_port == port_nbr); zframe_destroy (&content); zbeacon_silence (service_beacon); zstr_free (&ipaddress); } zbeacon_destroy (&client_beacon); zbeacon_destroy (&service_beacon); zbeacon_t *node1 = zbeacon_new (ctx, 5670); assert (node1); zbeacon_t *node2 = zbeacon_new (ctx, 5670); assert (node2); zbeacon_t *node3 = zbeacon_new (ctx, 5670); assert (node3); assert (*zbeacon_hostname (node1)); assert (*zbeacon_hostname (node2)); assert (*zbeacon_hostname (node3)); zbeacon_set_interval (node1, 250); zbeacon_set_interval (node2, 250); zbeacon_set_interval (node3, 250); zbeacon_noecho (node1); zbeacon_publish (node1, (byte *) "NODE/1", 6); zbeacon_publish (node2, (byte *) "NODE/2", 6); zbeacon_publish (node3, (byte *) "GARBAGE", 7); zbeacon_subscribe (node1, (byte *) "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new ( zbeacon_socket (node1), zbeacon_socket (node2), zbeacon_socket (node3), NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == zbeacon_socket (node1)); char *ipaddress, *beacon; zstr_recvx (zbeacon_socket (node1), &ipaddress, &beacon, NULL); assert (streq (beacon, "NODE/2")); zstr_free (&ipaddress); zstr_free (&beacon); } } zpoller_destroy (&poller); // Stop listening zbeacon_unsubscribe (node1); // Stop all node broadcasts zbeacon_silence (node1); zbeacon_silence (node2); zbeacon_silence (node3); // Destroy the test nodes zbeacon_destroy (&node1); zbeacon_destroy (&node2); zbeacon_destroy (&node3); zsock_destroy (&service); zctx_destroy (&ctx); // @end printf ("OK\n"); } czmq-3.0.2/src/zbeacon.c0000664000175000017500000003403412505070716014153 0ustar00phph00000000000000/* ========================================================================= zbeacon - LAN discovery and presence Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. @discuss This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "platform.h" #include "../include/czmq.h" // Constants #define INTERVAL_DFLT 1000 // Default interval = 1 second // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe SOCKET udpsock; // UDP socket for send/recv int port_nbr; // UDP port number we work on int interval; // Beacon broadcast interval int64_t ping_at; // Next broadcast time zframe_t *transmit; // Beacon transmit data zframe_t *filter; // Beacon filter data inaddr_t broadcast; // Our broadcast address bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? char hostname [NI_MAXHOST]; // Saved host name } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zframe_destroy (&self->transmit); zframe_destroy (&self->filter); zsys_udp_close (self->udpsock); free (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); if (!self) return NULL; self->pipe = pipe; return self; } // -------------------------------------------------------------------------- // Prepare beacon to work on specified UPD port. static void s_self_prepare_udp (self_t *self) { // Create our UDP socket if (self->udpsock) zsys_udp_close (self->udpsock); self->hostname [0] = 0; self->udpsock = zsys_udp_new (false); if (self->udpsock == INVALID_SOCKET) return; // Get the network interface fro ZSYS_INTERFACE or else use first // broadcast interface defined on system. ZSYS_INTERFACE=* means // use INADDR_ANY + INADDR_BROADCAST. const char *iface = zsys_interface (); in_addr_t bind_to = 0; in_addr_t send_to = 0; if (streq (iface, "*")) { // Wildcard means bind to INADDR_ANY and send to INADDR_BROADCAST bind_to = INADDR_ANY; send_to = INADDR_BROADCAST; } else { // Look for matching interface, or first ziflist item ziflist_t *iflist = ziflist_new (); assert (iflist); const char *name = ziflist_first (iflist); while (name) { if (streq (iface, name) || streq (iface, "")) { // Using inet_addr instead of inet_aton or inet_atop // because these are not supported in Win XP send_to = inet_addr (ziflist_broadcast (iflist)); bind_to = inet_addr (ziflist_address (iflist)); if (self->verbose) zsys_info ("zbeacon: interface=%s address=%s broadcast=%s", name, ziflist_address (iflist), ziflist_broadcast (iflist)); break; // iface is known, so allow it } name = ziflist_next (iflist); } ziflist_destroy (&iflist); } if (bind_to) { self->broadcast.sin_family = AF_INET; self->broadcast.sin_port = htons (self->port_nbr); self->broadcast.sin_addr.s_addr = send_to; inaddr_t address = self->broadcast; address.sin_addr.s_addr = bind_to; // Bind to the port on all interfaces #if (defined (__WINDOWS__)) inaddr_t sockaddr = address; #elif (defined (__APPLE__)) inaddr_t sockaddr = self->broadcast; sockaddr.sin_addr.s_addr = htons (INADDR_ANY); #else inaddr_t sockaddr = self->broadcast; #endif // Bind must succeed; we treat failure here as a hard violation (assert) if (bind (self->udpsock, (struct sockaddr *) &sockaddr, sizeof (inaddr_t))) zsys_socket_error ("bind"); // Get our hostname so we can send it back to the API if (getnameinfo ((struct sockaddr *) &address, sizeof (inaddr_t), self->hostname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0) { if (self->verbose) zsys_info ("zbeacon: configured, hostname=%s", self->hostname); } } } // -------------------------------------------------------------------------- // Prepare beacon to work on specified UPD port, reply hostname to // pipe (or "" if this failed) static void s_self_configure (self_t *self, int port_nbr) { assert (port_nbr); self->port_nbr = port_nbr; s_self_prepare_udp (self); zstr_send (self->pipe, self->hostname); if (streq (self->hostname, "")) zsys_error ("No broadcast interface found, (ZSYS_INTERFACE=%s)", zsys_interface ()); } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get just the command off the pipe char *command = zstr_recv (self->pipe); if (!command) return -1; // Interrupted if (self->verbose) zsys_info ("zbeacon: API command=%s", command); if (streq (command, "VERBOSE")) self->verbose = true; else if (streq (command, "CONFIGURE")) { int port; int rc = zsock_recv (self->pipe, "i", &port); assert (rc == 0); s_self_configure (self, port); } else if (streq (command, "PUBLISH")) { zframe_destroy (&self->transmit); zsock_recv (self->pipe, "fi", &self->transmit, &self->interval); assert (zframe_size (self->transmit) <= UDP_FRAME_MAX); if (self->interval == 0) self->interval = INTERVAL_DFLT; // Start broadcasting immediately self->ping_at = zclock_mono (); } else if (streq (command, "SILENCE")) zframe_destroy (&self->transmit); else if (streq (command, "SUBSCRIBE")) { zframe_destroy (&self->filter); self->filter = zframe_recv (self->pipe); assert (zframe_size (self->filter) <= UDP_FRAME_MAX); } else if (streq (command, "UNSUBSCRIBE")) zframe_destroy (&self->filter); else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zbeacon: - invalid command: %s", command); assert (false); } zstr_free (&command); return 0; } // -------------------------------------------------------------------------- // Receive and filter the waiting beacon static void s_self_handle_udp (self_t *self) { assert (self); char peername [INET_ADDRSTRLEN]; zframe_t *frame = zsys_udp_recv (self->udpsock, peername); // If filter is set, check that beacon matches it bool is_valid = false; if (self->filter) { byte *filter_data = zframe_data (self->filter); size_t filter_size = zframe_size (self->filter); if (zframe_size (frame) >= filter_size && memcmp (zframe_data (frame), filter_data, filter_size) == 0) is_valid = true; } // If valid, discard our own broadcasts, which UDP echoes to us if (is_valid && self->transmit) { byte *transmit_data = zframe_data (self->transmit); size_t transmit_size = zframe_size (self->transmit); if (zframe_size (frame) == transmit_size && memcmp (zframe_data (frame), transmit_data, transmit_size) == 0) is_valid = false; } // If still a valid beacon, send on to the API if (is_valid) { zmsg_t *msg = zmsg_new (); assert (msg); zmsg_addstr (msg, peername); zmsg_append (msg, &frame); zmsg_send (&msg, self->pipe); } else zframe_destroy (&frame); } // -------------------------------------------------------------------------- // zbeacon() implements the zbeacon actor interface void zbeacon (zsock_t *pipe, void *args) { self_t *self = s_self_new (pipe); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { // Poll on API pipe and on UDP socket zmq_pollitem_t pollitems [] = { { zsock_resolve (self->pipe), 0, ZMQ_POLLIN, 0 }, { NULL, self->udpsock, ZMQ_POLLIN, 0 } }; long timeout = -1; if (self->transmit) { timeout = (long) (self->ping_at - zclock_mono ()); if (timeout < 0) timeout = 0; } int pollset_size = self->udpsock? 2: 1; if (zmq_poll (pollitems, pollset_size, timeout * ZMQ_POLL_MSEC) == -1) break; // Interrupted if (pollitems [0].revents & ZMQ_POLLIN) s_self_handle_pipe (self); if (pollitems [1].revents & ZMQ_POLLIN) s_self_handle_udp (self); if (self->transmit && zclock_mono () >= self->ping_at) { // Send beacon to any listening peers if (zsys_udp_send (self->udpsock, self->transmit, &self->broadcast)) // Try to recreate UDP socket on interface s_self_prepare_udp (self); self->ping_at = zclock_mono () + self->interval; } } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zbeacon_test (bool verbose) { printf (" * zbeacon: "); if (verbose) printf ("\n"); // @selftest // Test 1 - two beacons, one speaking, one listening // Create speaker beacon to broadcast our service zactor_t *speaker = zactor_new (zbeacon, NULL); assert (speaker); if (verbose) zstr_sendx (speaker, "VERBOSE", NULL); zsock_send (speaker, "si", "CONFIGURE", 9999); char *hostname = zstr_recv (speaker); if (!*hostname) { printf ("OK (skipping test, no UDP broadcasting)\n"); zactor_destroy (&speaker); free (hostname); return; } free (hostname); // Create listener beacon on port 9999 to lookup service zactor_t *listener = zactor_new (zbeacon, NULL); assert (listener); if (verbose) zstr_sendx (listener, "VERBOSE", NULL); zsock_send (listener, "si", "CONFIGURE", 9999); hostname = zstr_recv (listener); assert (*hostname); free (hostname); // We will broadcast the magic value 0xCAFE byte announcement [2] = { 0xCA, 0xFE }; zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100); // We will listen to anything (empty subscription) zsock_send (listener, "sb", "SUBSCRIBE", "", 0); // Wait for at most 1/2 second if there's no broadcasting zsock_set_rcvtimeo (listener, 500); char *ipaddress = zstr_recv (listener); if (ipaddress) { zframe_t *content = zframe_recv (listener); assert (zframe_size (content) == 2); assert (zframe_data (content) [0] == 0xCA); assert (zframe_data (content) [1] == 0xFE); zframe_destroy (&content); zstr_free (&ipaddress); zstr_sendx (speaker, "SILENCE", NULL); } zactor_destroy (&listener); zactor_destroy (&speaker); // Test subscription filter using a 3-node setup zactor_t *node1 = zactor_new (zbeacon, NULL); assert (node1); zsock_send (node1, "si", "CONFIGURE", 5670); hostname = zstr_recv (node1); assert (*hostname); free (hostname); zactor_t *node2 = zactor_new (zbeacon, NULL); assert (node2); zsock_send (node2, "si", "CONFIGURE", 5670); hostname = zstr_recv (node2); assert (*hostname); free (hostname); zactor_t *node3 = zactor_new (zbeacon, NULL); assert (node3); zsock_send (node3, "si", "CONFIGURE", 5670); hostname = zstr_recv (node3); assert (*hostname); free (hostname); zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250); zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250); zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250); zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new (node1, node2, node3, NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == node1); char *ipaddress, *received; zstr_recvx (node1, &ipaddress, &received, NULL); assert (streq (received, "NODE/2")); zstr_free (&ipaddress); zstr_free (&received); } } zpoller_destroy (&poller); // Stop listening zstr_sendx (node1, "UNSUBSCRIBE", NULL); // Stop all node broadcasts zstr_sendx (node1, "SILENCE", NULL); zstr_sendx (node2, "SILENCE", NULL); zstr_sendx (node3, "SILENCE", NULL); // Destroy the test nodes zactor_destroy (&node1); zactor_destroy (&node2); zactor_destroy (&node3); // @end printf ("OK\n"); } czmq-3.0.2/src/zmsg.c0000664000175000017500000010167212533666571013530 0ustar00phph00000000000000/* ========================================================================= zmsg - working with multipart messages ------------------------------------------------------------------------- Copyright (c) 1991-2014 iMatix Corporation Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.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 . ========================================================================= */ /* @header The zmsg class provides methods to send and receive multipart messages across 0MQ sockets. This class provides a list-like container interface, with methods to work with the overall container. zmsg_t messages are composed of zero or more zframe_t frames. @discuss @end */ #include "../include/czmq.h" // zmsg_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZMSG_TAG 0x0003cafe // Structure of our class struct _zmsg_t { uint32_t tag; // Object tag for runtime detection zlist_t *frames; // List of frames size_t content_size; // Total content size }; // -------------------------------------------------------------------------- // Constructor zmsg_t * zmsg_new (void) { zmsg_t *self = (zmsg_t *) zmalloc (sizeof (zmsg_t)); if (self) { self->tag = ZMSG_TAG; self->frames = zlist_new (); if (!self->frames) zmsg_destroy (&self); } return self; } // -------------------------------------------------------------------------- // Destructor void zmsg_destroy (zmsg_t **self_p) { assert (self_p); if (*self_p) { zmsg_t *self = *self_p; assert (zmsg_is (self)); zframe_t *frame; while ((frame = (zframe_t *) zlist_pop (self->frames))) zframe_destroy (&frame); zlist_destroy (&self->frames); self->tag = 0xDeadBeef; free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Receive a message from a socket. The socket may be a libzmq socket, or a // zsock_t object. Returns a new zmsg_t object if successful, or NULL if the // receive was interrupted. The recv call blocks: if you want a non-blocking // call, use the zloop or zpoller class to receive only from ready sockets. zmsg_t * zmsg_recv (void *source) { assert (source); zmsg_t *self = zmsg_new (); if (!self) return NULL; void *handle = zsock_resolve (source); while (true) { zframe_t *frame = zframe_recv (handle); if (!frame) { zmsg_destroy (&self); break; // Interrupted or terminated } if (zmsg_append (self, &frame)) { zmsg_destroy (&self); break; } if (!zsock_rcvmore (handle)) break; // Last message frame } return self; } // -------------------------------------------------------------------------- // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_send (zmsg_t **self_p, void *dest) { assert (self_p); assert (dest); zmsg_t *self = *self_p; int rc = 0; void *handle = zsock_resolve (dest); if (self) { assert (zmsg_is (self)); zframe_t *frame = (zframe_t *) zlist_pop (self->frames); while (frame) { rc = zframe_send (&frame, handle, zlist_size (self->frames) ? ZFRAME_MORE : 0); if (rc != 0) break; frame = (zframe_t *) zlist_pop (self->frames); } if (rc == 0) zmsg_destroy (self_p); } return rc; } // -------------------------------------------------------------------------- // Send (More) message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_sendm (zmsg_t **self_p, void *dest) { assert (self_p); assert (dest); zmsg_t *self = *self_p; int rc = 0; void *handle = zsock_resolve (dest); if (self) { assert (zmsg_is (self)); zframe_t *frame = (zframe_t *) zlist_pop (self->frames); while (frame) { rc = zframe_send (&frame, handle,ZFRAME_MORE); if (rc != 0) break; frame = (zframe_t *) zlist_pop (self->frames); } if (rc == 0) zmsg_destroy (self_p); } return rc; } // -------------------------------------------------------------------------- // Return size of message, i.e. number of frames (0 or more). size_t zmsg_size (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return zlist_size (self->frames); } // -------------------------------------------------------------------------- // Return total size of all frames in message. size_t zmsg_content_size (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return self->content_size; } // -------------------------------------------------------------------------- // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int zmsg_prepend (zmsg_t *self, zframe_t **frame_p) { assert (self); assert (zmsg_is (self)); assert (frame_p); zframe_t *frame = *frame_p; *frame_p = NULL; // We now own frame self->content_size += zframe_size (frame); return zlist_push (self->frames, frame); } // -------------------------------------------------------------------------- // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Nullifies caller's reference to frame. int zmsg_append (zmsg_t *self, zframe_t **frame_p) { assert (self); assert (zmsg_is (self)); assert (frame_p); zframe_t *frame = *frame_p; *frame_p = NULL; // We now own frame self->content_size += zframe_size (frame); return zlist_append (self->frames, frame); } // -------------------------------------------------------------------------- // Remove first frame from message, if any. Returns frame, or NULL. Caller // now owns frame and must destroy it when finished with it. zframe_t * zmsg_pop (zmsg_t *self) { assert (self); assert (zmsg_is (self)); zframe_t *frame = (zframe_t *) zlist_pop (self->frames); if (frame) self->content_size -= zframe_size (frame); return frame; } // -------------------------------------------------------------------------- // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_pushmem (zmsg_t *self, const void *src, size_t size) { assert (self); assert (zmsg_is (self)); zframe_t *frame = zframe_new (src, size); if (frame) { self->content_size += size; return zlist_push (self->frames, frame); } else return -1; } // -------------------------------------------------------------------------- // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_addmem (zmsg_t *self, const void *src, size_t size) { assert (self); assert (zmsg_is (self)); zframe_t *frame = zframe_new (src, size); if (frame) { self->content_size += size; return zlist_append (self->frames, frame); } else return -1; } // -------------------------------------------------------------------------- // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstr (zmsg_t *self, const char *string) { assert (self); assert (zmsg_is (self)); assert (string); size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); if (frame) { self->content_size += len; return zlist_push (self->frames, frame); } else return -1; } // -------------------------------------------------------------------------- // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstr (zmsg_t *self, const char *string) { assert (self); assert (zmsg_is (self)); assert (string); size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); if (frame) { self->content_size += len; return zlist_append (self->frames, frame); } else return -1; } // -------------------------------------------------------------------------- // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstrf (zmsg_t *self, const char *format, ...) { assert (self); assert (zmsg_is (self)); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (!string) return -1; size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); free (string); if (frame) { self->content_size += len; return zlist_push (self->frames, frame); } else return -1; } // -------------------------------------------------------------------------- // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstrf (zmsg_t *self, const char *format, ...) { assert (self); assert (zmsg_is (self)); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (!string) return -1; size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); free (string); if (frame) { self->content_size += len; return zlist_append (self->frames, frame); } else return -1; } // -------------------------------------------------------------------------- // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. char * zmsg_popstr (zmsg_t *self) { assert (self); assert (zmsg_is (self)); zframe_t *frame = (zframe_t *) zlist_pop (self->frames); char *string = NULL; if (frame) { self->content_size -= zframe_size (frame); string = zframe_strdup (frame); zframe_destroy (&frame); } return string; } // -------------------------------------------------------------------------- // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p) { assert (self); assert (zmsg_is (self)); assert (msg_p); zmsg_t *msg = *msg_p; byte *data; size_t len = zmsg_encode (msg, &data); int r = zmsg_addmem (self, data, len); if (r == 0) { zmsg_destroy (&msg); *msg_p = NULL; } free (data); return r; } // -------------------------------------------------------------------------- // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not succesfull. Caller now owns message and must destroy it // when finished with it. zmsg_t * zmsg_popmsg (zmsg_t *self) { assert (self); assert (zmsg_is (self)); zframe_t *frame = zmsg_pop (self); if (!frame) return NULL; size_t len = zframe_size (frame); byte *data = zframe_data (frame); zmsg_t *msg = zmsg_decode (data, len); zframe_destroy (&frame); return msg; } // -------------------------------------------------------------------------- // Remove specified frame from list, if present. Does not destroy frame. void zmsg_remove (zmsg_t *self, zframe_t *frame) { assert (self); assert (zmsg_is (self)); self->content_size -= zframe_size (frame); zlist_remove (self->frames, frame); } // -------------------------------------------------------------------------- // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. zframe_t * zmsg_first (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return (zframe_t *) zlist_first (self->frames); } // -------------------------------------------------------------------------- // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. zframe_t * zmsg_next (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return (zframe_t *) zlist_next (self->frames); } // -------------------------------------------------------------------------- // Return the last frame. If there are no frames, returns NULL. zframe_t * zmsg_last (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return (zframe_t *) zlist_last (self->frames); } // -------------------------------------------------------------------------- // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int zmsg_save (zmsg_t *self, FILE *file) { assert (self); assert (zmsg_is (self)); assert (file); zframe_t *frame = zmsg_first (self); while (frame) { size_t frame_size = zframe_size (frame); if (fwrite (&frame_size, sizeof (frame_size), 1, file) != 1) return -1; if (fwrite (zframe_data (frame), frame_size, 1, file) != 1) return -1; frame = zmsg_next (self); } return 0; } // -------------------------------------------------------------------------- // Load/append an open file into message, create new message if // null message provided. Returns NULL if the message could not be // loaded. zmsg_t * zmsg_load (zmsg_t *self, FILE *file) { assert (file); if (!self) self = zmsg_new (); if (!self) return NULL; while (true) { size_t frame_size; size_t rc = fread (&frame_size, sizeof (frame_size), 1, file); if (rc == 1) { zframe_t *frame = zframe_new (NULL, frame_size); if (!frame) { zmsg_destroy (&self); return NULL; // Unable to allocate frame, fail } rc = fread (zframe_data (frame), frame_size, 1, file); if (frame_size > 0 && rc != 1) { zframe_destroy (&frame); zmsg_destroy (&self); return NULL; // Corrupt file, fail } if (zmsg_append (self, &frame) == -1) { zmsg_destroy (&self); return NULL; // Unable to add frame, fail } } else break; // Unable to read properly, quit } if (!zmsg_size (self)) { zmsg_destroy (&self); self = NULL; } return self; } // -------------------------------------------------------------------------- // Serialize multipart message to a single buffer. Use this method to send // structured messages across transports that do not support multipart data. // Allocates and returns a new buffer containing the serialized message. // To decode a serialized message buffer, use zmsg_decode (). // Frame lengths are encoded as 1 or 1+4 bytes // 0..254 bytes octet + data // 255..4Gb-1 bytes 0xFF + 4octet + data size_t zmsg_encode (zmsg_t *self, byte **buffer) { assert (self); assert (zmsg_is (self)); // Calculate real size of buffer size_t buffer_size = 0; zframe_t *frame = zmsg_first (self); while (frame) { size_t frame_size = zframe_size (frame); if (frame_size < 255) buffer_size += frame_size + 1; else buffer_size += frame_size + 1 + 4; frame = zmsg_next (self); } *buffer = (byte *) zmalloc (buffer_size); if (*buffer) { // Encode message now byte *dest = *buffer; frame = zmsg_first (self); while (frame) { size_t frame_size = zframe_size (frame); if (frame_size < 255) { *dest++ = (byte) frame_size; memcpy (dest, zframe_data (frame), frame_size); dest += frame_size; } else { *dest++ = 0xFF; *dest++ = (frame_size >> 24) & 255; *dest++ = (frame_size >> 16) & 255; *dest++ = (frame_size >> 8) & 255; *dest++ = frame_size & 255; memcpy (dest, zframe_data (frame), frame_size); dest += frame_size; } frame = zmsg_next (self); } assert ((dest - *buffer) == buffer_size); } return buffer_size; } // -------------------------------------------------------------------------- // Decodes a serialized message buffer created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the buffer was badly formatted or // there was insufficient memory to work. zmsg_t * zmsg_decode (const byte *buffer, size_t buffer_size) { zmsg_t *self = zmsg_new (); if (!self) return NULL; const byte *source = buffer; const byte *limit = buffer + buffer_size; while (source < limit) { size_t frame_size = *source++; if (frame_size == 255) { if (source > limit - 4) { zmsg_destroy (&self); break; } frame_size = (source [0] << 24) + (source [1] << 16) + (source [2] << 8) + source [3]; source += 4; } if (source > limit - frame_size) { zmsg_destroy (&self); break; } zframe_t *frame = zframe_new (source, frame_size); if (frame) { if (zmsg_append (self, &frame)) { zmsg_destroy (&self); break; } source += frame_size; } else { zmsg_destroy (&self); break; } } return self; } // -------------------------------------------------------------------------- // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. zmsg_t * zmsg_dup (zmsg_t *self) { if (self) { assert (zmsg_is (self)); zmsg_t *copy = zmsg_new (); if (copy) { zframe_t *frame = zmsg_first (self); while (frame) { if (zmsg_addmem (copy, zframe_data (frame), zframe_size (frame))) { zmsg_destroy (©); break; // Abandon attempt to copy message } frame = zmsg_next (self); } } return copy; } else return NULL; } // -------------------------------------------------------------------------- // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void zmsg_print (zmsg_t *self) { assert (self); assert (zmsg_is (self)); if (!self) { zsys_debug ("(NULL)"); return; } zframe_t *frame = zmsg_first (self); while (frame) { zframe_print (frame, NULL); frame = zmsg_next (self); } } // -------------------------------------------------------------------------- // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool zmsg_eq (zmsg_t *self, zmsg_t *other) { if (!self || !other) return false; if (zlist_size (self->frames) != zlist_size (other->frames)) return false; zframe_t *self_frame = (zframe_t *) zlist_first (self->frames); zframe_t *other_frame = (zframe_t *) zlist_first (other->frames); while (self_frame && other_frame) { if (!zframe_eq (self_frame, other_frame)) return false; self_frame = (zframe_t *) zlist_next (self->frames); other_frame = (zframe_t *) zlist_next (other->frames); } return true; } // -------------------------------------------------------------------------- // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. zmsg_t * zmsg_new_signal (byte status) { zmsg_t *self = zmsg_new (); int64_t signal_value = 0x7766554433221100L + status; if (zmsg_addmem (self, &signal_value, 8)) zmsg_destroy (&self); return self; } // -------------------------------------------------------------------------- // Return signal value, 0 or greater, if message is a signal, -1 if not. int zmsg_signal (zmsg_t *self) { if (zmsg_size (self) == 1 && zmsg_content_size (self) == 8) { zframe_t *frame = zmsg_first (self); int64_t signal_value = *((int64_t *) zframe_data (frame)); if ((signal_value & 0xFFFFFFFFFFFFFF00L) == 0x7766554433221100L) return signal_value & 255; } return -1; } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zmsg_t. bool zmsg_is (void *self) { assert (self); return ((zmsg_t *) self)->tag == ZMSG_TAG; } // -------------------------------------------------------------------------- // DEPRECATED as over-engineered, poor style // Pop frame off front of message, caller now owns frame // If next frame is empty, pops and destroys that empty frame. zframe_t * zmsg_unwrap (zmsg_t *self) { assert (self); zframe_t *frame = zmsg_pop (self); zframe_t *empty = zmsg_first (self); if (empty && zframe_size (empty) == 0) { empty = zmsg_pop (self); zframe_destroy (&empty); } return frame; } // -------------------------------------------------------------------------- // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive message from socket, returns zmsg_t object, or NULL either if // there was no input waiting, or the recv was interrupted. zmsg_t * zmsg_recv_nowait (void *source) { assert (source); zmsg_t *self = zmsg_new (); if (!self) return NULL; void *handle = zsock_resolve (source); while (true) { zframe_t *frame = zframe_recv_nowait (handle); if (!frame) { zmsg_destroy (&self); break; // Interrupted or terminated } if (zmsg_append (self, &frame)) { zmsg_destroy (&self); break; } if (!zsock_rcvmore (source)) break; // Last message frame } return self; } // -------------------------------------------------------------------------- // DEPRECATED as unsafe -- does not nullify frame reference. // Push frame plus empty frame to front of message, before first frame. // Message takes ownership of frame, will destroy it when message is sent. void zmsg_wrap (zmsg_t *self, zframe_t *frame) { assert (self); assert (frame); if (zmsg_pushmem (self, "", 0) == 0) zmsg_push (self, frame); } // -------------------------------------------------------------------------- // DEPRECATED by zmsg_prepend (). // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. int zmsg_push (zmsg_t *self, zframe_t *frame) { assert (self); assert (frame); self->content_size += zframe_size (frame); return zlist_push (self->frames, frame); } // -------------------------------------------------------------------------- // DEPRECATED by zmsg_append (). // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. int zmsg_add (zmsg_t *self, zframe_t *frame) { assert (self); assert (frame); self->content_size += zframe_size (frame); return zlist_append (self->frames, frame); } // -------------------------------------------------------------------------- // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Dump message to FILE stream, for debugging and tracing. // Truncates to first 10 frames, for readability. void zmsg_fprint (zmsg_t *self, FILE *file) { assert (self); assert (zmsg_is (self)); fprintf (file, "--------------------------------------\n"); if (!self) { fprintf (file, "NULL"); return; } zframe_t *frame = zmsg_first (self); int frame_nbr = 0; while (frame && frame_nbr++ < 10) { zframe_fprint (frame, NULL, file); frame = zmsg_next (self); } } // -------------------------------------------------------------------------- // Selftest void zmsg_test (bool verbose) { printf (" * zmsg: "); int rc = 0; // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zmsg.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zmsg.test"); assert (input); // Test send and receive of single-frame message zmsg_t *msg = zmsg_new (); assert (msg); zframe_t *frame = zframe_new ("Hello", 5); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); rc = zmsg_send (&msg, output); assert (msg == NULL); assert (rc == 0); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); zmsg_destroy (&msg); // Test send and receive of multi-frame message msg = zmsg_new (); assert (msg); rc = zmsg_addmem (msg, "Frame0", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame1", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame2", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame3", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame4", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame5", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame6", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame7", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame8", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame9", 6); assert (rc == 0); zmsg_t *copy = zmsg_dup (msg); assert (copy); rc = zmsg_send (©, output); assert (rc == 0); rc = zmsg_send (&msg, output); assert (rc == 0); copy = zmsg_recv (input); assert (copy); assert (zmsg_size (copy) == 10); assert (zmsg_content_size (copy) == 60); zmsg_destroy (©); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // create empty file for null test FILE *file = fopen ("zmsg.test", "w"); assert (file); fclose (file); file = fopen ("zmsg.test", "r"); zmsg_t *null_msg = zmsg_load (NULL, file); assert (null_msg == NULL); fclose (file); remove ("zmsg.test"); // Save to a file, read back file = fopen ("zmsg.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg.test", "r"); rc = zmsg_save (msg, file); assert (rc == -1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg.test", "r"); msg = zmsg_load (NULL, file); assert (msg); fclose (file); remove ("zmsg.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Remove all frames except first and last int frame_nbr; for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) { zmsg_first (msg); frame = zmsg_next (msg); zmsg_remove (msg, frame); zframe_destroy (&frame); } // Test message frame manipulation assert (zmsg_size (msg) == 2); frame = zmsg_last (msg); assert (zframe_streq (frame, "Frame9")); assert (zmsg_content_size (msg) == 12); frame = zframe_new ("Address", 7); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 3); rc = zmsg_addstr (msg, "Body"); assert (rc == 0); assert (zmsg_size (msg) == 4); frame = zmsg_pop (msg); zframe_destroy (&frame); assert (zmsg_size (msg) == 3); char *body = zmsg_popstr (msg); assert (streq (body, "Frame0")); free (body); zmsg_destroy (&msg); // Test encoding/decoding msg = zmsg_new (); assert (msg); byte *blank = (byte *) zmalloc (100000); assert (blank); rc = zmsg_addmem (msg, blank, 0); assert (rc == 0); rc = zmsg_addmem (msg, blank, 1); assert (rc == 0); rc = zmsg_addmem (msg, blank, 253); assert (rc == 0); rc = zmsg_addmem (msg, blank, 254); assert (rc == 0); rc = zmsg_addmem (msg, blank, 255); assert (rc == 0); rc = zmsg_addmem (msg, blank, 256); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65535); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65536); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65537); assert (rc == 0); free (blank); assert (zmsg_size (msg) == 9); byte *buffer; size_t buffer_size = zmsg_encode (msg, &buffer); zmsg_destroy (&msg); msg = zmsg_decode (buffer, buffer_size); assert (msg); free (buffer); zmsg_destroy (&msg); // Test submessages msg = zmsg_new (); assert (msg); zmsg_t *submsg = zmsg_new (); zmsg_pushstr (msg, "matr"); zmsg_pushstr (submsg, "joska"); rc = zmsg_addmsg (msg, &submsg); assert (rc == 0); assert (submsg == NULL); submsg = zmsg_popmsg (msg); assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded submsg = zmsg_popmsg (msg); assert (submsg); body = zmsg_popstr (submsg); assert (streq (body, "joska")); free (body); zmsg_destroy (&submsg); frame = zmsg_pop (msg); assert (frame == NULL); zmsg_destroy (&msg); // Test comparison of two messages msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); zmsg_addstr (msg, "Three"); zmsg_t *msg_other = zmsg_new (); zmsg_addstr (msg_other, "One"); zmsg_addstr (msg_other, "Two"); zmsg_addstr (msg_other, "One-Hundred"); zmsg_t *msg_dup = zmsg_dup (msg); zmsg_t *empty_msg = zmsg_new (); zmsg_t *empty_msg_2 = zmsg_new (); assert (zmsg_eq (msg, msg_dup)); assert (!zmsg_eq (msg, msg_other)); assert (zmsg_eq (empty_msg, empty_msg_2)); assert (!zmsg_eq (msg, NULL)); assert (!zmsg_eq (NULL, empty_msg)); assert (!zmsg_eq (NULL, NULL)); zmsg_destroy (&msg); zmsg_destroy (&msg_other); zmsg_destroy (&msg_dup); zmsg_destroy (&empty_msg); zmsg_destroy (&empty_msg_2); // Test signal messages msg = zmsg_new_signal (0); assert (zmsg_signal (msg) == 0); zmsg_destroy (&msg); msg = zmsg_new_signal (-1); assert (zmsg_signal (msg) == 255); zmsg_destroy (&msg); // Now try methods on an empty message msg = zmsg_new (); assert (msg); assert (zmsg_size (msg) == 0); assert (zmsg_unwrap (msg) == NULL); assert (zmsg_first (msg) == NULL); assert (zmsg_last (msg) == NULL); assert (zmsg_next (msg) == NULL); assert (zmsg_pop (msg) == NULL); // Sending an empty message is valid and destroys the message assert (zmsg_send (&msg, output) == 0); assert (!msg); zsock_destroy (&input); zsock_destroy (&output); // @end printf ("OK\n"); } czmq-3.0.2/src/zdigest.c0000664000175000017500000001053512533666571014216 0ustar00phph00000000000000/* ========================================================================= zdigest - provides hashing functions (SHA-1 at present) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zdigest class generates a hash from zchunks of data. The current algorithm is SHA-1, chosen for speed. We are aiming to generate a unique digest for a file, and there are no security issues in this use case. @discuss The current code depends on OpenSSL, which might be replaced by hard coded SHA-1 implementation to reduce build dependencies. @end */ #include "platform.h" #include "../include/czmq.h" #include "foreign/sha1/sha1.inc_c" // Structure of our class struct _zdigest_t { SHA_CTX context; // Digest context // Binary hash byte hash [SHA_DIGEST_LENGTH]; // ASCII representation (hex) char string [SHA_DIGEST_LENGTH * 2 + 1]; bool final; // Finished calculating }; // -------------------------------------------------------------------------- // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. zdigest_t * zdigest_new (void) { zdigest_t *self = (zdigest_t *) zmalloc (sizeof (zdigest_t)); if (self) SHA1_Init (&self->context); return self; } // -------------------------------------------------------------------------- // Destroy a digest object void zdigest_destroy (zdigest_t **self_p) { assert (self_p); if (*self_p) { zdigest_t *self = *self_p; free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Add buffer into digest calculation void zdigest_update (zdigest_t *self, byte *buffer, size_t length) { // Calling this after zdigest_data() is illegal use of the API assert (self); assert (!self->final); SHA1_Update (&self->context, buffer, length); } // -------------------------------------------------------------------------- // Return final digest hash data. If built without crypto support, returns // NULL. byte * zdigest_data (zdigest_t *self) { assert (self); if (!self->final) { SHA1_Final (self->hash, &self->context); self->final = true; } return self->hash; } // -------------------------------------------------------------------------- // Return final digest hash size size_t zdigest_size (zdigest_t *self) { assert (self); return SHA_DIGEST_LENGTH; } // -------------------------------------------------------------------------- // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. char * zdigest_string (zdigest_t *self) { assert (self); byte *data = zdigest_data (self); char hex_char [] = "0123456789ABCDEF"; int byte_nbr; for (byte_nbr = 0; byte_nbr < SHA_DIGEST_LENGTH; byte_nbr++) { self->string [byte_nbr * 2 + 0] = hex_char [data [byte_nbr] >> 4]; self->string [byte_nbr * 2 + 1] = hex_char [data [byte_nbr] & 15]; } self->string [SHA_DIGEST_LENGTH * 2] = 0; return self->string; } // -------------------------------------------------------------------------- // Self test of this class void zdigest_test (bool verbose) { printf (" * zdigest: "); // @selftest byte *buffer = (byte *) zmalloc (1024); memset (buffer, 0xAA, 1024); zdigest_t *digest = zdigest_new (); assert (digest); zdigest_update (digest, buffer, 1024); byte *data = zdigest_data (digest); assert (data [0] == 0xDE); assert (data [1] == 0xB2); assert (data [2] == 0x38); assert (data [3] == 0x07); assert (streq (zdigest_string (digest), "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671")); zdigest_destroy (&digest); free (buffer); // @end printf ("OK\n"); } czmq-3.0.2/Makefile.am0000664000175000017500000000263512535241704013635 0ustar00phph00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ ACLOCAL_AMFLAGS = -I config AM_CPPFLAGS = \ ${zmq_CFLAGS} \ -I$(srcdir)/include project_libs = \ ${zmq_LIBS} SUBDIRS = DIST_SUBDIRS = SUBDIRS += doc DIST_SUBDIRS += doc lib_LTLIBRARIES = bin_PROGRAMS = noinst_PROGRAMS = check_PROGRAMS = noinst_LTLIBRARIES = TESTS = EXTRA_DIST = \ src/zgossip_engine.inc \ src/zhash_primes.inc \ src/zclass_example.xml \ src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h \ src/foreign/slre/readme.txt \ src/zgossip_msg.h \ src/czmq_classes.h \ LICENSE \ README.txt \ README.md \ CONTRIBUTING.md \ version.sh include $(srcdir)/src/Makemodule.am include $(srcdir)/src/Makemodule-local.am # Optional project-local hook ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/doc/0000775000175000017500000000000012535242315012337 5ustar00phph00000000000000czmq-3.0.2/doc/zuuid.30000664000175000017500000001263212533132172013564 0ustar00phph00000000000000'\" t .\" Title: zuuid .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZUUID" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zuuid \- UUID support class .SH "SYNOPSIS" .sp .nf // Constructor CZMQ_EXPORT zuuid_t * zuuid_new (void); // Destructor CZMQ_EXPORT void zuuid_destroy (zuuid_t **self_p); // Create UUID object from supplied ZUUID_LEN\-octet value CZMQ_EXPORT zuuid_t * zuuid_new_from (const byte *source); // Set UUID to new supplied ZUUID_LEN\-octet value CZMQ_EXPORT void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping \*(Aq\-\*(Aq and \*(Aq{\*(Aq \*(Aq}\*(Aq // optional delimiters\&. Return 0 if OK, else returns \-1\&. CZMQ_EXPORT int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data CZMQ_EXPORT const byte * zuuid_data (zuuid_t *self); // Return UUID binary size CZMQ_EXPORT size_t zuuid_size (zuuid_t *self); // Returns UUID as string CZMQ_EXPORT const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8\-4\-4\-4\-12, in lower // case\&. Caller does not modify or free returned value\&. See // http://en\&.wikipedia\&.org/wiki/Universally_unique_identifier CZMQ_EXPORT const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array CZMQ_EXPORT void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value CZMQ_EXPORT bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value CZMQ_EXPORT bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null\&. CZMQ_EXPORT zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class CZMQ_EXPORT void zuuid_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zuuid class generates UUIDs and provides methods for working with them\&. If you build CZMQ with libuuid, on Unix/Linux, it will use that library\&. On Windows it will use UuidCreate()\&. Otherwise it will use a random number generator to produce convincing imitations of uuids\&. .sp Please add @discuss section in \&.\&./src/zuuid\&.c\&. .SH "EXAMPLE" .PP \fBFrom zuuid_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Simple create/destroy test assert (ZUUID_LEN == 16); assert (ZUUID_STR_LEN == 32); zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == ZUUID_LEN); assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN); zuuid_t *copy = zuuid_dup (uuid); assert (streq (zuuid_str (uuid), zuuid_str (copy))); // Check set/set_str/export methods const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38"; const char *myuuid2 = "8CB3E9A9\-649B\-4BEF\-8DE2\-25E9C2CEBB38"; const char *myuuid3 = "{8CB3E9A9\-649B\-4BEF\-8DE2\-25E9C2CEBB38}"; const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838"; int rc = zuuid_set_str (uuid, myuuid); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid2); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid3); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid4); assert (rc == \-1); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the canonical string format assert (streq (zuuid_str_canonical (uuid), "8cb3e9a9\-649b\-4bef\-8de2\-25e9c2cebb38")); zuuid_destroy (&uuid); zuuid_destroy (©); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zmonitor.txt0000664000175000017500000000565612533132136014772 0ustar00phph00000000000000zmonitor(3) =========== NAME ---- zmonitor - socket event monitor SYNOPSIS -------- ---- // Create new zmonitor actor instance to monitor a zsock_t socket: // // zactor_t *monitor = zactor_new (zmonitor, mysocket); // // Destroy zmonitor instance. // // zactor_destroy (&monitor); // // Enable verbose logging of commands and activity. // // zstr_send (monitor, "VERBOSE"); // // Listen to monitor event type (zero or types, ending in NULL): // zstr_sendx (monitor, "LISTEN", type, ..., NULL); // // Events: // CONNECTED // CONNECT_DELAYED // CONNECT_RETRIED // LISTENING // BIND_FAILED // ACCEPTED // ACCEPT_FAILED // CLOSED // CLOSE_FAILED // DISCONNECTED // MONITOR_STOPPED // ALL // // Start monitor; after this, any further LISTEN commands are ignored. // // zstr_send (monitor, "START"); // zsock_wait (monitor); // // Receive next monitor event: // // zmsg_t *msg = zmsg_recv (monitor); // // This is the zmonitor constructor as a zactor_fn; the argument can be // a zactor_t, zsock_t, or libzmq void * socket: CZMQ_EXPORT void zmonitor (zsock_t *pipe, void *sock); // Selftest CZMQ_EXPORT void zmonitor_test (bool verbose); ---- DESCRIPTION ----------- The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Works on all versions of libzmq from 3.2 onwards. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). EXAMPLE ------- .From zmonitor_test method ---- zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zactor_t *clientmon = zactor_new (zmonitor, client); assert (clientmon); if (verbose) zstr_sendx (clientmon, "VERBOSE", NULL); zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL); zstr_sendx (clientmon, "START", NULL); zsock_wait (clientmon); zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon); // Allow a brief time for the message to get there... zmq_poll (NULL, 0, 200); // Check client is now listening int port_nbr = zsock_bind (client, "tcp://127.0.0.1:*"); assert (port_nbr != -1); s_assert_event (clientmon, "LISTENING"); // Check server connected to client zsock_connect (server, "tcp://127.0.0.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED"); // Check client accepted connection s_assert_event (clientmon, "ACCEPTED"); zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif ---- czmq-3.0.2/doc/zproxy_v2.txt0000664000175000017500000000631312533132136015062 0ustar00phph00000000000000zproxy_v2(3) ============ NAME ---- zproxy_v2 - run a steerable proxy in the background (deprecated) SYNOPSIS -------- ---- // Constructor // Create a new zproxy object. You must create the frontend and backend // sockets, configure them, and connect or bind them, before you pass them // to the constructor. Do NOT use the sockets again, after passing them to // this method. CZMQ_EXPORT zproxy_t * zproxy_new (zctx_t *ctx, void *frontend, void *backend); // Destructor // Destroy a zproxy object; note this first stops the proxy. CZMQ_EXPORT void zproxy_destroy (zproxy_t **self_p); // Copy all proxied messages to specified endpoint; if this is NULL, any // in-progress capturing will be stopped. You must already have bound the // endpoint to a PULL socket. CZMQ_EXPORT void zproxy_capture (zproxy_t *self, const char *endpoint); // Pauses a zproxy object; a paused proxy will cease processing messages, // causing them to be queued up and potentially hit the high-water mark on // the frontend socket, causing messages to be dropped, or writing // applications to block. CZMQ_EXPORT void zproxy_pause (zproxy_t *self); // Resume a zproxy object CZMQ_EXPORT void zproxy_resume (zproxy_t *self); // Self test of this class CZMQ_EXPORT void zproxy_v2_test (bool verbose); ---- DESCRIPTION ----------- The zproxy class provides an equivalent to the ZMQ steerable proxy, on all versions of ZeroMQ. This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zproxy interface, based on zactor, together with the zsock class for sockets. EXAMPLE ------- .From zproxy_v2_test method ---- zctx_t *ctx = zctx_new (); assert (ctx); void *frontend = zsocket_new (ctx, ZMQ_PULL); assert (frontend); int rc = zsocket_bind (frontend, "inproc://frontend"); assert (rc == 0); void *backend = zsocket_new (ctx, ZMQ_PUSH); assert (backend); rc = zsocket_bind (backend, "inproc://backend"); assert (rc == 0); zproxy_t *proxy = zproxy_new (ctx, frontend, backend); assert (proxy); // Connect application sockets to proxy void *faucet = zsocket_new (ctx, ZMQ_PUSH); assert (faucet); rc = zsocket_connect (faucet, "inproc://frontend"); assert (rc == 0); void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); rc = zsocket_connect (sink, "inproc://backend"); assert (rc == 0); // Send some messages and check they arrived zstr_send (faucet, "Hello"); char *string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); // Check pause/resume functionality zproxy_pause (proxy); zstr_send (faucet, "World"); zproxy_resume (proxy); string = zstr_recv (sink); assert (streq (string, "World")); zstr_free (&string); // Create capture socket, must be a PULL socket void *capture = zsocket_new (ctx, ZMQ_PULL); assert (capture); rc = zsocket_bind (capture, "inproc://capture"); assert (rc == 0); // Switch on capturing, check that it works zproxy_capture (proxy, "inproc://capture"); zstr_send (faucet, "Hello"); string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); string = zstr_recv (capture); assert (streq (string, "Hello")); zstr_free (&string); zproxy_destroy (&proxy); zctx_destroy (&ctx); ---- czmq-3.0.2/doc/zdir.txt0000664000175000017500000002012112533132136014041 0ustar00phph00000000000000zdir(3) ======= NAME ---- zdir - work with file-system directories SYNOPSIS -------- ---- // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. CZMQ_EXPORT zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. CZMQ_EXPORT void zdir_destroy (zdir_t **self_p); // Return directory path CZMQ_EXPORT const char * zdir_path (zdir_t *self); // Return last modification time for directory. CZMQ_EXPORT time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. CZMQ_EXPORT off_t zdir_cursize (zdir_t *self); // Return directory count CZMQ_EXPORT size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. CZMQ_EXPORT void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream CZMQ_EXPORT void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout CZMQ_EXPORT void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); CZMQ_EXPORT void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. CZMQ_EXPORT void zdir_test (bool verbose); ---- DESCRIPTION ----------- The zdir class gives access to the file system index. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure. It exists mainly to wrap non-portable OS functions to do this. Please add @discuss section in ../src/zdir.c. EXAMPLE ------- .From zdir_test method ---- zdir_t *older = zdir_new (".", NULL); assert (older); if (verbose) { printf ("\n"); zdir_dump (older, 0); } zdir_t *newer = zdir_new ("..", NULL); assert (newer); zlist_t *patches = zdir_diff (older, newer, "/"); assert (patches); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); zdir_patch_destroy (&patch); } zlist_destroy (&patches); zdir_destroy (&older); zdir_destroy (&newer); zdir_t *nosuch = zdir_new ("does-not-exist", NULL); assert (nosuch == NULL); // zdir_watch test: zactor_t *watch = zactor_new (zdir_watch, NULL); assert (watch); if (verbose) { zsock_send (watch, "s", "VERBOSE"); assert (zsock_wait (watch) == 0); } // need to create a file in the test directory we're watching // in order to ensure the directory exists zfile_t *initfile = zfile_new ("./zdir-test-dir", "initial_file"); assert (initfile); zfile_output (initfile); fprintf (zfile_handle (initfile), "initial file\n"); zfile_close (initfile); zfile_destroy (&initfile); zclock_sleep (1001); // wait for initial file to become 'stable' zsock_send (watch, "si", "TIMEOUT", 100); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir-test-dir"); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "UNSUBSCRIBE", "zdir-test-dir"); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir-test-dir"); assert (zsock_wait (watch) == 0); zfile_t *newfile = zfile_new ("zdir-test-dir", "test_abc"); zfile_output (newfile); fprintf (zfile_handle (newfile), "test file\n"); zfile_close (newfile); zpoller_t *watch_poll = zpoller_new (watch, NULL); // poll for a certain timeout before giving up and failing the test. assert(zpoller_wait (watch_poll, 1001) == watch); // wait for notification of the file being added char *path; int rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir-test-dir")); free (path); assert (zlist_size (patches) == 1); zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir-test-dir")); zfile_t *patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir-test-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); // remove the file zfile_remove (newfile); zfile_destroy (&newfile); // poll for a certain timeout before giving up and failing the test. assert(zpoller_wait (watch_poll, 1001) == watch); // wait for notification of the file being removed rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir-test-dir")); free (path); assert (zlist_size (patches) == 1); patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir-test-dir")); patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir-test-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); zpoller_destroy (&watch_poll); zactor_destroy (&watch); // clean up by removing the test directory. zdir_t *testdir = zdir_new ("zdir-test-dir", NULL); zdir_remove (testdir, true); zdir_destroy (&testdir); ---- czmq-3.0.2/doc/zconfig.txt0000664000175000017500000002013212533132136014532 0ustar00phph00000000000000zconfig(3) ========== NAME ---- zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. SYNOPSIS -------- ---- // Function that executes config typedef int (zconfig_fct) (zconfig_t *self, void *arg, int level); // Create new config item CZMQ_EXPORT zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children CZMQ_EXPORT void zconfig_destroy (zconfig_t **self_p); // Return name of config item CZMQ_EXPORT char * zconfig_name (zconfig_t *self); // Return value of config item CZMQ_EXPORT char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value CZMQ_EXPORT void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. CZMQ_EXPORT void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...); // Get value for config item into a string value; leading slash is optional // and ignored. CZMQ_EXPORT char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...); // Find our first child, if any CZMQ_EXPORT zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any CZMQ_EXPORT zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. CZMQ_EXPORT zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth CZMQ_EXPORT zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. CZMQ_EXPORT int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. CZMQ_EXPORT void zconfig_set_comment (zconfig_t *self, const char *format, ...); // Return comments of config item, as zlist. CZMQ_EXPORT zlist_t * zconfig_comments (zconfig_t *self); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. CZMQ_EXPORT zconfig_t * zconfig_load (const char *filename); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. CZMQ_EXPORT int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. CZMQ_EXPORT zconfig_t * zconfig_loadf (const char *format, ...); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. CZMQ_EXPORT int zconfig_savef (zconfig_t *self, const char *format, ...); // Report filename used during zconfig_load, or NULL if none CZMQ_EXPORT const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). CZMQ_EXPORT int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk CZMQ_EXPORT zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk CZMQ_EXPORT zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string CZMQ_EXPORT zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string CZMQ_EXPORT char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. CZMQ_EXPORT bool zconfig_has_changed (zconfig_t *self); // Print the config file to open stream CZMQ_EXPORT void zconfig_fprint (zconfig_t *self, FILE *file); // Print the config file to stdout CZMQ_EXPORT void zconfig_print (zconfig_t *self); ---- DESCRIPTION ----------- Lets applications load, work with, and save configuration files. This implements rfc.zeromq.org/spec:4/ZPL, which is a simple structured text format for configuration files. Here is an example ZPL stream and corresponding config structure: context iothreads = 1 verbose = 1 # Ask for a trace main type = zqueue # ZMQ_DEVICE type frontend option hwm = 1000 swap = 25000000 # 25MB bind = 'inproc://addr1' bind = 'ipc://addr2' backend bind = inproc://addr3 root Down = child | Across = next v context-->main | | | v | type=queue-->frontend-->backend | | | | | v | | bind=inproc://addr3 | v | option-->bind=inproc://addr1-->bind=ipc://addr2 | | | v | hwm=1000-->swap=25000000 v iothreads=1-->verbose=false EXAMPLE ------- .From zconfig_test method ---- // Create temporary directory for test files # define TESTDIR ".test_zconfig" zsys_dir_create (TESTDIR); zconfig_t *root = zconfig_new ("root", NULL); assert (root); zconfig_t *section, *item; section = zconfig_new ("headers", root); assert (section); item = zconfig_new ("email", section); assert (item); zconfig_set_value (item, "some@random.com"); item = zconfig_new ("name", section); assert (item); zconfig_set_value (item, "Justin Kayce"); zconfig_putf (root, "/curve/secret-key", "%s", "Top Secret"); zconfig_set_comment (root, " CURVE certificate"); zconfig_set_comment (root, " -----------------"); assert (zconfig_comments (root)); zconfig_save (root, TESTDIR "/test.cfg"); zconfig_destroy (&root); root = zconfig_load (TESTDIR "/test.cfg"); if (verbose) zconfig_save (root, "-"); assert (streq (zconfig_filename (root), TESTDIR "/test.cfg")); char *email = zconfig_get (root, "/headers/email", NULL); assert (email); assert (streq (email, "some@random.com")); char *passwd = zconfig_get (root, "/curve/secret-key", NULL); assert (passwd); assert (streq (passwd, "Top Secret")); zconfig_savef (root, "%s/%s", TESTDIR, "test.cfg"); assert (!zconfig_has_changed (root)); int rc = zconfig_reload (&root); assert (rc == 0); assert (!zconfig_has_changed (root)); zconfig_destroy (&root); // Test chunk load/save root = zconfig_new ("root", NULL); assert (root); section = zconfig_new ("section", root); assert (section); item = zconfig_new ("value", section); assert (item); zconfig_set_value (item, "somevalue"); zconfig_t *search = zconfig_locate (root, "section/value"); assert (search == item); zchunk_t *chunk = zconfig_chunk_save (root); assert (strlen ((char *) zchunk_data (chunk)) == 32); char *string = zconfig_str_save (root); assert (string); assert (streq (string, (char *) zchunk_data (chunk))); free (string); assert (chunk); zconfig_destroy (&root); root = zconfig_chunk_load (chunk); assert (root); char *value = zconfig_get (root, "/section/value", NULL); assert (value); assert (streq (value, "somevalue")); // Test config can't be saved to a file in a path that doesn't // exist or isn't writable rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", TESTDIR, "test.cfg"); assert (rc == -1); zconfig_destroy (&root); zchunk_destroy (&chunk); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); ---- czmq-3.0.2/doc/zsock.txt0000664000175000017500000005646712533132136014250 0ustar00phph00000000000000zsock(3) ======== NAME ---- zsock - high-level socket API that hides libzmq contexts and sockets SYNOPSIS -------- ---- // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. CZMQ_EXPORT zsock_t * zsock_new (int type); // Destroy the socket. You must use this for any socket created via the // zsock_new method. CZMQ_EXPORT void zsock_destroy (zsock_t **self_p); // Create a PUB socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_stream (const char *endpoint); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. CZMQ_EXPORT int zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Returns last bound endpoint, if any. CZMQ_EXPORT const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). CZMQ_EXPORT int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. CZMQ_EXPORT const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. CZMQ_EXPORT int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. CZMQ_EXPORT int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. CZMQ_EXPORT int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. CZMQ_EXPORT int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. CZMQ_EXPORT int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. Do not modify or destroy the returned // values. Returns 0 if successful, or -1 if it failed to read a message. CZMQ_EXPORT int zsock_brecv (void *self, const char *picture, ...); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. CZMQ_EXPORT void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. CZMQ_EXPORT void zsock_flush (void *self); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. CZMQ_EXPORT bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. CZMQ_EXPORT void * zsock_resolve (void *self); // Self test of this class CZMQ_EXPORT void zsock_test (bool verbose); ---- DESCRIPTION ----------- The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *. Please add @discuss section in ../src/zsock.c. EXAMPLE ------- .From zsock_test method ---- zsock_t *writer = zsock_new_push ("@tcp://127.0.0.1:5560"); assert (writer); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 5560); assert (streq (zsock_endpoint (writer), "tcp://127.0.0.1:5560")); #endif zsock_t *reader = zsock_new_pull (">tcp://127.0.0.1:5560"); assert (reader); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); // Basic Hello, World zstr_send (writer, "Hello, World"); zmsg_t *msg = zmsg_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); free (string); zmsg_destroy (&msg); // Test resolve FD SOCKET fd = zsock_fd (reader); assert (zsock_resolve ((void *) &fd) == NULL); // Test binding to ephemeral ports, sequential and random int port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60050]"); assert (port >= 60000 && port <= 60050); port = zsock_bind (writer, "tcp://127.0.0.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60050]"); assert (port >= 60000 && port <= 60050); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:5556,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == -1); zsock_destroy (&server); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test.writer")); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsock_connect (reader, "txp://127.0.0.1:5560"); assert (rc == -1); // Test signal/wait methods rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); // Test zsock_send/recv pictures uint8_t number1 = 123; uint16_t number2 = 123 * 123; uint32_t number4 = 123 * 123 * 123; uint64_t number8 = 123 * 123 * 123 * 123; zchunk_t *chunk = zchunk_new ("HELLO", 5); assert (chunk); zframe_t *frame = zframe_new ("WORLD", 5); assert (frame); zhashx_t *hash = zhashx_new (); assert (hash); zuuid_t *uuid = zuuid_new (); assert (uuid); zhashx_autofree (hash); zhashx_insert (hash, "1", "value A"); zhashx_insert (hash, "2", "value B"); char *original = "pointer"; // Test zsock_recv into each supported type zsock_send (writer, "i1248zsbcfUhp", -12345, number1, number2, number4, number8, "This is a string", "ABCDE", 5, chunk, frame, uuid, hash, original); char *uuid_str = strdup (zuuid_str (uuid)); zchunk_destroy (&chunk); zframe_destroy (&frame); zuuid_destroy (&uuid); zhashx_destroy (&hash); int integer; byte *data; size_t size; char *pointer; number8 = number4 = number2 = number1 = 0; rc = zsock_recv (reader, "i1248zsbcfUhp", &integer, &number1, &number2, &number4, &number8, &string, &data, &size, &chunk, &frame, &uuid, &hash, &pointer); assert (rc == 0); assert (integer == -12345); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "This is a string")); assert (memcmp (data, "ABCDE", 5) == 0); assert (size == 5); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); assert (streq (uuid_str, zuuid_str (uuid))); assert (memcmp (zframe_data (frame), "WORLD", 5) == 0); assert (zframe_size (frame) == 5); char *value = (char *) zhashx_lookup (hash, "1"); assert (streq (value, "value A")); value = (char *) zhashx_lookup (hash, "2"); assert (streq (value, "value B")); assert (original == pointer); free (string); free (data); free (uuid_str); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); // Test zsock_recv of short message; this lets us return a failure // with a status code and then nothing else; the receiver will get // the status code and NULL/zero for all other values zsock_send (writer, "i", -1); zsock_recv (reader, "izsbcfp", &integer, &string, &data, &size, &chunk, &frame, &pointer); assert (integer == -1); assert (string == NULL); assert (data == NULL); assert (size == 0); assert (chunk == NULL); assert (frame == NULL); assert (pointer == NULL); msg = zmsg_new (); zmsg_addstr (msg, "frame 1"); zmsg_addstr (msg, "frame 2"); zsock_send (writer, "szm", "header", msg); zmsg_destroy (&msg); zsock_recv (reader, "szm", &string, &msg); assert (streq ("header", string)); assert (zmsg_size (msg) == 2); assert (zframe_streq (zmsg_first (msg), "frame 1")); assert (zframe_streq (zmsg_next (msg), "frame 2")); zstr_free (&string); zmsg_destroy (&msg); // Test zsock_recv with null arguments chunk = zchunk_new ("HELLO", 5); assert (chunk); frame = zframe_new ("WORLD", 5); assert (frame); zsock_send (writer, "izsbcfp", -12345, "This is a string", "ABCDE", 5, chunk, frame, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL); assert (integer == -12345); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); zchunk_destroy (&chunk); // Test zsock_bsend/brecv pictures with binary encoding frame = zframe_new ("Hello", 5); chunk = zchunk_new ("World", 5); msg = zmsg_new (); zmsg_addstr (msg, "Hello"); zmsg_addstr (msg, "World"); zsock_bsend (writer, "1248sSpcfm", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk, frame, msg); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); number8 = number4 = number2 = number1 = 0; char *longstr; zsock_brecv (reader, "1248sSpcfm", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk, &frame, &msg); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); zstr_free (&longstr); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); // Check that we can send a zproto format message zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234); zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_recv (gossip, reader); assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH); zgossip_msg_destroy (&gossip); zsock_destroy (&reader); zsock_destroy (&writer); ---- czmq-3.0.2/doc/zchunk.txt0000664000175000017500000001515712533132136014410 0ustar00phph00000000000000zchunk(3) ========= NAME ---- zchunk - work with memory chunks SYNOPSIS -------- ---- // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. CZMQ_EXPORT zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk CZMQ_EXPORT void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero CZMQ_EXPORT void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size CZMQ_EXPORT size_t zchunk_size (zchunk_t *self); // Return chunk max size CZMQ_EXPORT size_t zchunk_max_size (zchunk_t *self); // Return chunk data CZMQ_EXPORT byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk CZMQ_EXPORT size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet CZMQ_EXPORT size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeed the available space, it is truncated. If you want to // grow the chunk to accomodate new data, use the zchunk_extend method. CZMQ_EXPORT size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeed the available space, the chunk grows in size. CZMQ_EXPORT size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. CZMQ_EXPORT size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. CZMQ_EXPORT bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor CZMQ_EXPORT zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor CZMQ_EXPORT int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. CZMQ_EXPORT zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. CZMQ_EXPORT zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. CZMQ_EXPORT char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. CZMQ_EXPORT char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator CZMQ_EXPORT bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. CZMQ_EXPORT zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. CZMQ_EXPORT zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. CZMQ_EXPORT const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. CZMQ_EXPORT void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details CZMQ_EXPORT void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. CZMQ_EXPORT bool zchunk_is (void *self); // Self test of this class CZMQ_EXPORT void zchunk_test (bool verbose); ---- DESCRIPTION ----------- The zchunk class works with variable sized blobs. Not as efficient as MQ's messages but they do less weirdness and so are easier to understand. The chunk class has methods to read and write chunks from disk. Please add @discuss section in ../src/zchunk.c. EXAMPLE ------- .From zchunk_test method ---- zchunk_t *chunk = zchunk_new ("1234567890", 10); assert (chunk); assert (zchunk_size (chunk) == 10); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 10); assert (chunk); zchunk_append (chunk, "12345678", 8); zchunk_append (chunk, "90ABCDEF", 8); zchunk_append (chunk, "GHIJKLMN", 8); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); assert (zchunk_size (chunk) == 10); assert (zchunk_streq (chunk, "1234567890")); assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A")); char *string = zchunk_strdup (chunk); assert (streq (string, "1234567890")); free (string); string = zchunk_strhex (chunk); assert (streq (string, "31323334353637383930")); free (string); zframe_t *frame = zchunk_pack (chunk); assert (frame); zchunk_t *chunk2 = zchunk_unpack (frame); assert (chunk2); assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0); zframe_destroy (&frame); zchunk_destroy (&chunk2); zchunk_t *copy = zchunk_dup (chunk); assert (copy); assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0); assert (zchunk_size (copy) == 10); zchunk_destroy (©); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 0); zchunk_extend (chunk, "12345678", 8); zchunk_extend (chunk, "90ABCDEF", 8); zchunk_extend (chunk, "GHIJKLMN", 8); assert (zchunk_size (chunk) == 24); assert (zchunk_streq (chunk, "1234567890ABCDEFGHIJKLMN")); zchunk_destroy (&chunk); copy = zchunk_new ("1234567890abcdefghij", 20); assert (copy); chunk = zchunk_new (NULL, 8); assert (chunk); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (zchunk_exhausted (copy)); assert (zchunk_size (chunk) == 4); assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0); zchunk_destroy (©); zchunk_destroy (&chunk); ---- czmq-3.0.2/doc/zauth.30000664000175000017500000002256712533132151013564 0ustar00phph00000000000000'\" t .\" Title: zauth .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZAUTH" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zauth \- authentication for ZeroMQ security mechanisms .SH "SYNOPSIS" .sp .nf #define CURVE_ALLOW_ANY "*" // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated)\&. // // Create new zauth actor instance\&. This installs authentication on all // zsock sockets\&. Until you add policies, all incoming NULL connections are // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections // are denied: // // zactor_t *auth = zactor_new (zauth, NULL); // // Destroy zauth instance\&. This removes authentication and allows all // connections to pass, without authentication: // // zactor_destroy (&auth); // // Note that all zauth commands are synchronous, so your application always // waits for a signal from the actor after each command\&. // // Enable verbose logging of commands and activity\&. Verbose logging can help // debug non\-trivial authentication policies: // // zstr_send (auth, "VERBOSE"); // zsock_wait (auth); // // Allow (whitelist) a list of IP addresses\&. For NULL, all clients from // these addresses will be accepted\&. For PLAIN and CURVE, they will be // allowed to continue with authentication\&. You can call this method // multiple times to whitelist more IP addresses\&. If you whitelist one // or nmore addresses, any non\-whitelisted addresses are treated as // blacklisted: // // zstr_sendx (auth, "ALLOW", "127\&.0\&.0\&.1", "127\&.0\&.0\&.2", NULL); // zsock_wait (auth); // // Deny (blacklist) a list of IP addresses\&. For all security mechanisms, // this rejects the connection without any further authentication\&. Use // either a whitelist, or a blacklist, not not both\&. If you define both // a whitelist and a blacklist, only the whitelist takes effect: // // zstr_sendx (auth, "DENY", "192\&.168\&.0\&.1", "192\&.168\&.0\&.2", NULL); // zsock_wait (auth); // // Configure PLAIN authentication using a plain\-text password file\&. You can // modify the password file at any time; zauth will reload it automatically // if modified externally: // // zstr_sendx (auth, "PLAIN", filename, NULL); // zsock_wait (auth); // // Configure CURVE authentication, using a directory that holds all public // client certificates, i\&.e\&. their public keys\&. The certificates must be in // zcert_save format\&. You can add and remove certificates in that directory // at any time\&. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the directory name: // // zstr_sendx (auth, "CURVE", directory, NULL); // zsock_wait (auth); // // Configure GSSAPI authentication, using an underlying mechanism (usually // Kerberos) to establish a secure context and perform mutual authentication: // // zstr_sendx (auth, "GSSAPI", NULL); // zsock_wait (auth); // // This is the zauth constructor as a zactor_fn: CZMQ_EXPORT void zauth (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zauth_test (bool verbose); .fi .SH "DESCRIPTION" .sp A zauth actor takes over authentication for all incoming connections in its context\&. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections\&. .sp This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&. .SH "EXAMPLE" .PP \fBFrom zauth_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create temporary directory for test files # define TESTDIR "\&.test_zauth" zsys_dir_create (TESTDIR); // Check there\*(Aqs no authentication zsock_t *server = zsock_new (ZMQ_PUSH); assert (server); zsock_t *client = zsock_new (ZMQ_PULL); assert (client); bool success = s_can_connect (&server, &client); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there\*(Aqs no authentication on a default NULL server success = s_can_connect (&server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed\&. zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client); assert (success); // Blacklist 127\&.0\&.0\&.1, connection should fail zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "DENY", "127\&.0\&.0\&.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "ALLOW", "127\&.0\&.0\&.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Try PLAIN authentication zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); success = s_can_connect (&server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password\-file", "w"); assert (password); fprintf (password, "admin=Password\en"); fclose (password); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); zstr_sendx (auth, "PLAIN", TESTDIR "/password\-file", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Bogus"); success = s_can_connect (&server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We\*(Aqll create two new certificates and save the client public // certificate on disk; in a real case we\*(Aqd transfer this securely // from the client machine to the server machine\&. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting\-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); success = s_can_connect (&server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert\&.txt"); zstr_sendx (auth, "CURVE", TESTDIR, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); success = s_can_connect (&server, &client); assert (success); zsock_destroy (&client); zsock_destroy (&server); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/czmq.70000664000175000017500000006703512532603107013411 0ustar00phph00000000000000'\" t .\" Title: czmq .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 05/31/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "CZMQ" "7" "05/31/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" czmq \- high\-level C binding for ZeroMQ .SH "SYNOPSIS" .sp .nf #include cc [\*(Aqflags\*(Aq] \*(Aqfiles\*(Aq \-lzmq \-lczmq [\*(Aqlibraries\*(Aq] .fi .SH "DESCRIPTION" .SS "Classes" .sp These classes provide the main socket and message API: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzsock\fR(3) \- working with ZeroMQ sockets (high\-level) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzstr\fR(3) \- sending and receiving strings .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzmsg\fR(3) \- working with multipart messages .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzframe\fR(3) \- working with single message frames .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzactor\fR(3) \- Actor class (socket + thread) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzloop\fR(3) \- event\-driven reactor .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzpoller\fR(3) \- trivial socket poller class .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzproxy\fR(3) \- proxy actor (like zmq_proxy_steerable) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzmonitor\fR(3) \- monitor events on ZeroMQ sockets .RE .sp These classes support authentication and encryption: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzauth\fR(3) \- authentication actor for ZeroMQ servers .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzcert\fR(3) \- work with CURVE security certificates .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzcertstore\fR(3) \- work with CURVE security certificate stores .RE .sp These classes provide generic containers: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzhash\fR(3) \- simple generic hash container .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzhashx\fR(3) \- extended generic hash container .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzlist\fR(3) \- simple generic list container .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzlistx\fR(3) \- extended generic list container .RE .sp These classes wrap\-up non\-portable functionality: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzbeacon\fR(3) \- LAN discovery and presence .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzclock\fR(3) \- millisecond clocks and delays .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzdir\fR(3) \- work with file\-system directories .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzdir_patch\fR(3) \- work with directory differences .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzfile\fR(3) \- work with file\-system files .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzsys\fR(3) \- system\-level methods .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzuuid\fR(3) \- UUID support class .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBziflist\fR(3) \- list available network interfaces .RE .sp And these utility classes add value: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzchunk\fR(3) \- work with memory chunks .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzconfig\fR(3) \- work with textual config files .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzrex\fR(3) \- work with regular expressions .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzgossip\fR(3) \- decentralized configuration management .RE .sp These classes are deprecated: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzctx\fR(3) \- working with ZeroMQ contexts .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzsocket\fR(3) \- working with ZeroMQ sockets (low\-level) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzsockopt\fR(3) \- get/set ZeroMQ socket options .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzthread\fR(3) \- working with system threads .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzauth_v2\fR(3) \- authentication for ZeroMQ servers .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzbeacon_v2\fR(3) \- LAN discovery and presence .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzmonitor_v2\fR(3) \- socket event monitor .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBzproxy_v2\fR(3) \- zmq_proxy wrapper .RE .SS "Scope and Goals" .sp CZMQ has these goals: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} To wrap the \(/OMQ core API in semantics that are natural and lead to shorter, more readable applications\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} To hide the differences between versions of \(/OMQ\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} To provide a space for development of more sophisticated API semantics\&. .RE .SS "Ownership and License" .sp CZMQ is maintained by the ZeroMQ community at github\&.com/zeromq\&. Its other authors and contributors are listed in the AUTHORS file\&. .sp The contributors are listed in AUTHORS\&. This project uses the MPL v2 license, see LICENSE\&. .SS "Contributing" .sp To submit an issue use the issue tracker at \m[blue]\fBhttp://github\&.com/zeromq/czmq/issues\fR\m[]\&. All discussion happens on the zeromq\-dev list or #zeromq IRC channel at irc\&.freenode\&.net\&. .sp 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 \m[blue]\fBhttp://www\&.zeromq\&.org/docs:contributing\fR\m[]\&. All contributors are listed in AUTHORS\&. .sp 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\&. .sp The general rule is, if you contribute code to CZMQ 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\&. .SH "USING CZMQ" .SS "Building and Installing" .sp CZMQ uses autotools for packaging\&. To build from git (all example commands are for Linux): .sp .if n \{\ .RS 4 .\} .nf git clone git://github\&.com/zeromq/czmq\&.git cd czmq sh autogen\&.sh \&./configure make all sudo make install sudo ldconfig .fi .if n \{\ .RE .\} .sp You will need the pkg\-config, libtool, and autoreconf packages\&. Set the LD_LIBRARY_PATH to /usr/local/libs unless you install elsewhere\&. .sp After building, you can run the CZMQ selftests: .sp .if n \{\ .RS 4 .\} .nf cd src \&./czmq_selftest .fi .if n \{\ .RE .\} .SS "Linking with an Application" .sp Include czmq\&.h in your application and link with CZMQ\&. Here is a typical gcc link command: .sp .if n \{\ .RS 4 .\} .nf gcc \-lczmq \-lzmq myapp\&.c \-o myapp .fi .if n \{\ .RE .\} .sp You should read czmq\&.h\&. This file includes zmq\&.h and the system header files that typical \(/OMQ applications will need\&. The provided \fIc\fR shell script lets you write simple portable build scripts: .sp .if n \{\ .RS 4 .\} .nf c \-lczmq \-lzmq \-l myapp .fi .if n \{\ .RE .\} .SS "The Class Model" .sp CZMQ consists of classes, each class consisting of a \&.h and a \&.c\&. Classes may depend on other classes\&. .sp czmq\&.h includes all classes header files, all the time\&. For the user, CZMQ forms one single package\&. All classes start by including czmq\&.h\&. All applications that use CZMQ start by including czmq\&.h\&. czmq\&.h also defines a limited number of small, useful macros and typedefs that have proven useful for writing clearer C code\&. .sp All classes (with some exceptions) are based on a flat C class system and follow these rules (where \fIzclass\fR is the class name): .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Class typedef: zclass_t .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Constructor: zclass_new .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Destructor: zclass_destroy .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Property methods: zclass_property_set, zclass_property .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Class structures are private (defined in the \&.c source but not the \&.h) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Properties are accessed only via methods named as described above\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In the class source code the object is always called self\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The constructor may take arbitrary arguments, and returns NULL on failure, or a new object\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The destructor takes a pointer to an object reference and nullifies it\&. .RE .sp Return values for methods are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For methods that return an object reference, either the reference, or NULL on failure\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For methods that signal success/failure, a return value of 0 means sucess, \-1 failure\&. .RE .sp Private/static functions in a class are named s_functionname and are not exported via the header file\&. .sp All classes (with some exceptions) have a test method called zclass_test\&. .SH "DESIGN IDEOLOGY" .SS "The Problem with C" .sp 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\&. .sp 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\&. .sp 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\&. .SS "A Simple Class Model" .sp 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 (\m[blue]\fBhttp://www\&.openamq\&.org\fR\m[]), a messaging client and server of 0\&.5M LoC, that a consistent model for extending C makes life for the application developer much easier\&. .sp 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 CZMQ class): .sp .if n \{\ .RS 4 .\} .nf zregexp_t *regexp = zregexp_new (regexp_string); if (!regexp) printf ("E: invalid regular expression: %s\en", regexp_string); else if (zregexp_match (regexp, input_buffer)) printf ("I: successful match for %s\en", input buffer); zregexp_destroy (&regexp); .fi .if n \{\ .RE .\} .sp 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\(cqs not worthwhile\&. The goal is not to emulate an OO system, it\(cqs simply to gain consistency\&. The constructor returns an object reference, or NULL if it fails\&. The destructor nullifies the class pointer, and is idempotent\&. .sp What we aim at here is the simplest possible consistent syntax\&. .sp No model is fully consistent, and classes can define their own rules if it helps make a better result\&. For example: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .SS "Naming Style" .sp CZMQ 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: .sp .if n \{\ .RS 4 .\} .nf zclassname_methodname .fi .if n \{\ .RE .\} .sp And the reader can easily parse this without needing special syntax to separate the class name from the method name\&. .SS "Containers" .sp After a long experiment with containers, we\(cqve decided that we need exactly two containers: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A singly\-linked list\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A hash table using text keys\&. .RE .sp These are zlist and zhash, 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\&. .sp We assume that at some point we\(cqll need to switch to a doubly\-linked list\&. .SS "Portability" .sp 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 \(/OMQ core), there is no portability layer and application code does conditional compilation for all mixes of platforms\&. This leads to quite messy code\&. .sp czmq acts as a portability layer, similar to but thinner than libraries like the [Apache Portable Runtime](\m[blue]\fBhttp://apr\&.apache\&.org\fR\m[]) (APR)\&. .sp These are the places a C application is subject to arbitrary system differences: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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 \fIpatching\fR the language in czmq_prelude\&.h, e\&.g\&. defining int64_t on Windows\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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 czmq_prelude\&.h\&. This is a proven brute\-force approach that increases recompilation times but eliminates a major source of pain\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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, \fIC\fR, which detects the OS type and version (at runtime) and builds the necessary link commands\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .sp An example of the last: .sp .if n \{\ .RS 4 .\} .nf #if (defined (__UNIX__)) pid = GetCurrentProcessId(); #elif (defined (__WINDOWS__)) pid = getpid (); #else pid = 0; #endif .fi .if n \{\ .RE .\} .sp CZMQ uses the GNU autotools system, so non\-portable code can use the macros this defines\&. It can also use macros defined by the czmq_prelude\&.h header file\&. .SS "Technical Aspects" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBThread safety\fR: the use of opaque structures is thread safe, though \(/OMQ applications should not share state between threads in any case\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBName spaces\fR: we prefix class names with z, which ensures that all exported functions are globally safe\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBLibrary versioning\fR: we don\(cqt 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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBPerformance\fR: 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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBSelf\-testing\fR: 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 czmq_selftest application does this\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBMemory management\fR: CZMQ classes do not use any special memory management techiques to detect leaks\&. We\(cqve done this in the past but it makes the code relatively complex\&. Instead, we do memory leak testing using tools like valgrind\&. .RE .SH "UNDER THE HOOD" .SS "Adding a New Class" .sp If you define a new CZMQ class myclass you need to: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Write the zmyclass\&.c and zmyclass\&.h source files, in src and include respectively\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add`#include ` to include/czmq\&.h\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add the myclass header and test call to src/czmq_selftest\&.c\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add a reference documentation to \fIdoc/zmyclass\&.txt\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add myclass to \*(Aqsrc/Makefile\&.am` and doc/Makefile\&.am\&. .RE .sp The bin/newclass\&.sh shell script will automate these steps for you\&. .SS "Coding Style" .sp In general the zctx 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: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The // comment style\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Variables definitions placed in or before the code that uses them\&. .RE .sp So while ANSI C code might say: .sp .if n \{\ .RS 4 .\} .nf zblob_t *file_buffer; /* Buffer for our file */ \&.\&.\&. (100 lines of code) file_buffer = zblob_new (); \&.\&.\&. .fi .if n \{\ .RE .\} .sp The style in CZMQ would be: .sp .if n \{\ .RS 4 .\} .nf zblob_t *file_buffer = zblob_new (); .fi .if n \{\ .RE .\} .SS "Assertions" .sp We use assertions heavily to catch bad argument values\&. The CZMQ classes do not attempt to validate arguments and report errors; bad arguments are treated as fatal application programming errors\&. .sp 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)\&. .sp Assertion code should always take this form: .sp .if n \{\ .RS 4 .\} .nf int rc = some_function (arguments); assert (rc == 0); .fi .if n \{\ .RE .\} .sp Rather than the side\-effect form: .sp .if n \{\ .RS 4 .\} .nf assert (some_function (arguments) == 0); .fi .if n \{\ .RE .\} .sp Since assertions may be removed by an optimizing compiler\&. .SS "Documentation" .sp Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (\m[blue]\fBhttp://github\&.com/imatix/gitdown\fR\m[])\&. The header file for a class must wrap its interface as follows (example is from include/zclock\&.h): .sp .if n \{\ .RS 4 .\} .nf // @interface // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds int64_t zclock_time (void); // Self test of this class int zclock_test (Bool verbose); // @end .fi .if n \{\ .RE .\} .sp The source file for a class must provide documentation as follows: .sp .if n \{\ .RS 4 .\} .nf /* @header \&.\&.\&.short explanation of class\&.\&.\&. @discuss \&.\&.\&.longer discussion of how it works\&.\&.\&. @end */ .fi .if n \{\ .RE .\} .sp The source file for a class then provides the self test example as follows: .sp .if n \{\ .RS 4 .\} .nf // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () \- start) >= 10); // @end .fi .if n \{\ .RE .\} .sp The template for man pages is in doc/mkman\&. .SS "Development" .sp CZMQ is developed through a test\-driven process that guarantees no memory violations or leaks in the code: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Modify a class or method\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Update the test method for that class\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Run the \fIselftest\fR script, which uses the Valgrind memcheck tool\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Repeat until perfect\&. .RE .SS "Porting CZMQ" .sp When you try CZMQ on an OS that it\(cqs 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\&. .sp Before attempting to patch code for portability, please read the czmq_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: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Defining typedefs which are missing on that specific compiler: do this in czmq_prelude\&.h\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Defining macros that rename exotic library functions to more conventional names: do this in czmq_prelude\&.h\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .sp The canonical \fIstandard operating system\fR for all CZMQ code is Linux, gcc, POSIX\&. .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zstr.txt0000664000175000017500000000730312533132136014102 0ustar00phph00000000000000zstr(3) ======= NAME ---- zstr - sending and receiving strings SYNOPSIS -------- ---- // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. CZMQ_EXPORT char * zstr_recv (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". CZMQ_EXPORT int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. CZMQ_EXPORT int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. CZMQ_EXPORT int zstr_sendfm (void *dest, const char *format, ...); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. CZMQ_EXPORT int zstr_sendx (void *dest, const char *string, ...); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. CZMQ_EXPORT int zstr_recvx (void *source, char **string_p, ...); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zstr_free (char **string_p); // Self test of this class CZMQ_EXPORT void zstr_test (bool verbose); ---- DESCRIPTION ----------- The zstr class provides utility functions for sending and receiving C strings across 0MQ sockets. It sends strings without a terminating null, and appends a null byte on received strings. This class is for simple message sending. Memory Wire +-------------+---+ +---+-------------+ Send | S t r i n g | 0 | ----> | 6 | S t r i n g | +-------------+---+ +---+-------------+ Wire Heap +---+-------------+ +-------------+---+ Recv | 6 | S t r i n g | ----> | S t r i n g | 0 | +---+-------------+ +-------------+---+ EXAMPLE ------- .From zstr_test method ---- // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zstr.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zstr.test"); assert (input); // Send ten strings, five strings with MORE flag and then END int string_nbr; for (string_nbr = 0; string_nbr < 10; string_nbr++) zstr_sendf (output, "this is string %d", string_nbr); zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL); // Read and count until we receive END string_nbr = 0; for (string_nbr = 0;; string_nbr++) { char *string = zstr_recv (input); assert (string); if (streq (string, "END")) { zstr_free (&string); break; } zstr_free (&string); } assert (string_nbr == 15); zsock_destroy (&input); zsock_destroy (&output); ---- czmq-3.0.2/doc/zhash.30000664000175000017500000003413712533132175013550 0ustar00phph00000000000000'\" t .\" Title: zhash .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZHASH" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zhash \- simple generic hash container .SH "SYNOPSIS" .sp .nf // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // DEPRECATED as clumsy \-\- use zhash_first/_next instead typedef int (zhash_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhash_t * zhash_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhash_destroy (zhash_t **self_p); // Insert item into hash table with specified key and item\&. // If key is already present returns \-1 and leaves existing item unchanged // Returns 0 on success\&. CZMQ_EXPORT int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item\&. // If key is already present, destroys old item and inserts new one\&. // Use free_fn method to ensure deallocator is properly called on item\&. CZMQ_EXPORT void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table\&. If there was no such // item, this function does nothing\&. CZMQ_EXPORT void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null CZMQ_EXPORT void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key\&. If there was no such // item, does nothing\&. Returns 0 if successful, else \-1\&. CZMQ_EXPORT int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item\&. When the item is // destroyed, the free function, if any, is called on that item\&. // Use this when hash items are dynamically allocated, to ensure that // you don\*(Aqt have memory leaks\&. You can pass \*(Aqfree\*(Aq or NULL as a free_fn\&. // Returns the item, or NULL if there is no such item\&. CZMQ_EXPORT void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null\&. // Does not copy items themselves\&. Rebuilds new table so may be slow on // very large tables\&. NOTE: only works with item values that are strings // since there\*(Aqs no other way to know how to duplicate the item value\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty\&. This method is simpler to use than the // foreach() method, which is deprecated\&. To access the key for this item // use zhash_cursor()\&. NOTE: do NOT modify the table while iterating\&. CZMQ_EXPORT void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned\&. Use this together with // zhash_first() to process all items in a hash table\&. If you need the // items in sorted order, use zhash_keys() and then zlist_sort()\&. To // access the key for this item use zhash_cursor()\&. NOTE: do NOT modify // the table while iterating\&. CZMQ_EXPORT void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned\&. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash\&. After an // unsuccessful first/next, returns NULL\&. CZMQ_EXPORT const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk\&. You can add as many // comment lines as you like\&. These comment lines are discarded when loading // the file\&. If you use a null format, all comments are deleted\&. CZMQ_EXPORT void zhash_comment (zhash_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Serialize hash table to a binary frame that can be sent in a message\&. // The packed format is compatible with the \*(Aqdictionary\*(Aq type defined in // http://rfc\&.zeromq\&.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict\-count *( dict\-name dict\-value ) // dict\-count = number\-4 // dict\-value = longstr // dict\-name = string // // ; Strings are always length + text contents // longstr = number\-4 *VCHAR // string = number\-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number\-1 = 1OCTET // number\-4 = 4OCTET // // Comments are not included in the packed data\&. Item values MUST be // strings\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zhash_pack (zhash_t *self); // Unpack binary frame into a new hash table\&. Packed data must follow format // defined by zhash_pack\&. Hash table is set to autofree\&. An empty frame // unpacks to an empty hash table\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zhash_t * zhash_unpack (zframe_t *frame); // Save hash table to a text file in name=value format\&. Hash values must be // printable strings; keys may not contain \*(Aq=\*(Aq character\&. Returns 0 if OK, // else \-1 if a file error occurred\&. CZMQ_EXPORT int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist\&. Hash values must printable strings; keys may not contain // \*(Aq=\*(Aq character\&. Returns 0 if OK, else \-1 if a file was not readable\&. CZMQ_EXPORT int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i\&.e\&. not // still changing\&. Returns 0 if OK, \-1 if there was an error reloading the // file\&. CZMQ_EXPORT int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction CZMQ_EXPORT void zhash_autofree (zhash_t *self); // DEPRECATED as clumsy \-\- use zhash_first/_next instead // Apply function to each item in the hash table\&. Items are iterated in no // defined order\&. Stops if callback function returns non\-zero and returns // final return code from callback function (zero = success)\&. // Callback function for zhash_foreach method CZMQ_EXPORT int zhash_foreach (zhash_t *self, zhash_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhash_test (int verbose); .fi .SH "DESCRIPTION" .sp zhash is an expandable hash table container\&. This is a simple container\&. For heavy\-duty applications we recommend using zhashx\&. .sp Note that it\(cqs relatively slow (50K insertions/deletes per second), so don\(cqt do inserts/updates on the critical path for message I/O\&. It can do 2\&.5M lookups per second for 16\-char keys\&. Timed on a 1\&.6GHz CPU\&. .SH "EXAMPLE" .PP \fBFrom zhash_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zhash_t *hash = zhash_new (); assert (hash); assert (zhash_size (hash) == 0); assert (zhash_first (hash) == NULL); assert (zhash_cursor (hash) == NULL); // Insert some items int rc; rc = zhash_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhash_first (hash); assert (streq (zhash_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhash_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhash_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhash_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhash_size (hash) == 4); // Look for existing items item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhash_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhash_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non\-existent items item = (char *) zhash_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhash_insert (hash, "DEADBEEF", "foo"); assert (rc == \-1); item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non\-existent key rc = zhash_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == \-1); // Trying to rename an unknown item to an existing key rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == \-1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == \-1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlist_t *keys = zhash_keys (hash); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Test dup method zhash_t *copy = zhash_dup (hash); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test pack/unpack methods zframe_t *frame = zhash_pack (hash); copy = zhash_unpack (frame); zframe_destroy (&frame); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test save and load zhash_comment (hash, "This is a test file"); zhash_comment (hash, "Created by %s", "czmq_selftest"); zhash_save (hash, "\&.cache"); copy = zhash_new (); assert (copy); zhash_load (copy, "\&.cache"); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); zsys_file_delete ("\&.cache"); // Delete a item zhash_delete (hash, "LIVEBEEF"); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhash_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr]\&.exists) { item = (char *) zhash_lookup (hash, testset [testnbr]\&.name); assert (item); zhash_delete (hash, testset [testnbr]\&.name); testset [testnbr]\&.exists = false; } else { sprintf (testset [testnbr]\&.name, "%x\-%x", rand (), rand ()); if (zhash_insert (hash, testset [testnbr]\&.name, "") == 0) testset [testnbr]\&.exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhash_destroy (&hash); zhash_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhash_new (); assert (hash); zhash_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhash_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Inserting with the same key will fail"); rc = zhash_insert (hash, "key1", value); assert (rc == \-1); strcpy (value, "Ring a ding ding"); rc = zhash_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding")); zhash_destroy (&hash); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zlist.30000664000175000017500000002521412533132176013575 0ustar00phph00000000000000'\" t .\" Title: zlist .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZLIST" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zlist \- simple generic list container .SH "SYNOPSIS" .sp .nf // Comparison function e\&.g\&. for sorting and removing\&. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Create a new list container CZMQ_EXPORT zlist_t * zlist_new (); // Destroy a list container CZMQ_EXPORT void zlist_destroy (zlist_t **self_p); // Return the item at the head of list\&. If the list is empty, returns NULL\&. // Leaves cursor pointing at the head item, or NULL if the list is empty\&. CZMQ_EXPORT void * zlist_first (zlist_t *self); // Return the next item\&. If the list is empty, returns NULL\&. To move to // the start of the list call zlist_first ()\&. Advances the cursor\&. CZMQ_EXPORT void * zlist_next (zlist_t *self); // Return the item at the tail of list\&. If the list is empty, returns NULL\&. // Leaves cursor pointing at the tail item, or NULL if the list is empty\&. CZMQ_EXPORT void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_tail (zlist_t *self); // Return the current item of list\&. If the list is empty, returns NULL\&. // Leaves cursor pointing at the current item, or NULL if the list is empty\&. CZMQ_EXPORT void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or \-1 if this // failed for some reason (out of memory)\&. Note that if a duplicator has // been set, this method will also duplicate the item\&. CZMQ_EXPORT int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or \-1 if this // failed for some reason (out of memory)\&. Note that if a duplicator has // been set, this method will also duplicate the item\&. CZMQ_EXPORT int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any CZMQ_EXPORT void * zlist_pop (zlist_t *self); // Checks if an item already is present\&. Uses compare method to determine if // items are equal\&. If the compare method is NULL the check will only compare // pointers\&. Returns true if item is present else false\&. CZMQ_EXPORT bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present CZMQ_EXPORT void zlist_remove (zlist_t *self, void *item); // Make a copy of list\&. If the list has autofree set, the copied list will // duplicate all items, which must be strings\&. Otherwise, the list will hold // pointers back to the items in the original list\&. If list is null, returns // NULL\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlist_t * zlist_dup (zlist_t *self); // Purge all items from list CZMQ_EXPORT void zlist_purge (zlist_t *self); // Return number of items in the list CZMQ_EXPORT size_t zlist_size (zlist_t *self); // Sort the list by ascending key value using a straight ASCII comparison\&. // The sort is not stable, so may reorder items with the same keys\&. CZMQ_EXPORT void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings\&. // By default a list item refers to a value held elsewhere\&. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value\&. Then, when you destroy the list, it will free all // item values automatically\&. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list\&. // The usual technique is to pop list items and destroy them, until the // list is empty\&. CZMQ_EXPORT void zlist_autofree (zlist_t *self); // Sets a compare function for this list\&. The function compares two items\&. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item\&. // This function is used for sorting, removal and exists checking\&. CZMQ_EXPORT void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item\&. When the item is // destroyed, the free function, if any, is called on that item\&. // Use this when list items are dynamically allocated, to ensure that // you don\*(Aqt have memory leaks\&. You can pass \*(Aqfree\*(Aq or NULL as a free_fn\&. // Returns the item, or NULL if there is no such item\&. CZMQ_EXPORT void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class CZMQ_EXPORT void zlist_test (int verbose); .fi .SH "DESCRIPTION" .sp Provides a generic container implementing a fast singly\-linked list\&. You can use this to construct multi\-dimensional lists, and other structures together with other generic containers like zhash\&. This is a simple class\&. For demanding applications we recommend using zlistx\&. .sp To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration\&. .SH "EXAMPLE" .PP \fBFrom zlist_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zlist_t *list = zlist_new (); assert (list); assert (zlist_size (list) == 0); // Three items we\*(Aqll use as test data // List items are void *, not particularly strings char *cheese = "boursin"; char *bread = "baguette"; char *wine = "bordeaux"; zlist_append (list, cheese); assert (zlist_size (list) == 1); assert ( zlist_exists (list, cheese)); assert (!zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, bread); assert (zlist_size (list) == 2); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, wine); assert (zlist_size (list) == 3); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert ( zlist_exists (list, wine)); assert (zlist_head (list) == cheese); assert (zlist_next (list) == cheese); assert (zlist_first (list) == cheese); assert (zlist_tail (list) == wine); assert (zlist_next (list) == bread); assert (zlist_first (list) == cheese); assert (zlist_next (list) == bread); assert (zlist_next (list) == wine); assert (zlist_next (list) == NULL); // After we reach end of list, next wraps around assert (zlist_next (list) == cheese); assert (zlist_size (list) == 3); zlist_remove (list, wine); assert (zlist_size (list) == 2); assert (zlist_first (list) == cheese); zlist_remove (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == bread); zlist_remove (list, bread); assert (zlist_size (list) == 0); zlist_append (list, cheese); zlist_append (list, bread); assert (zlist_last (list) == bread); zlist_remove (list, bread); assert (zlist_last (list) == cheese); zlist_remove (list, cheese); assert (zlist_last (list) == NULL); zlist_push (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == cheese); zlist_push (list, bread); assert (zlist_size (list) == 2); assert (zlist_first (list) == bread); assert (zlist_item (list) == bread); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_first (list) == bread); zlist_t *sub_list = zlist_dup (list); assert (sub_list); assert (zlist_size (sub_list) == 3); zlist_sort (list, s_compare); char *item; item = (char *) zlist_pop (list); assert (item == bread); item = (char *) zlist_pop (list); assert (item == wine); item = (char *) zlist_pop (list); assert (item == cheese); assert (zlist_size (list) == 0); assert (zlist_size (sub_list) == 3); zlist_push (list, sub_list); zlist_t *sub_list_2 = zlist_dup (sub_list); zlist_append (list, sub_list_2); assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list); assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2); zlist_destroy (&list); // Test autofree functionality list = zlist_new (); assert (list); zlist_autofree (list); // Set equals function otherwise equals will not work as autofree copies strings zlist_comparefn (list, s_compare); zlist_push (list, bread); zlist_append (list, cheese); assert (zlist_size (list) == 2); zlist_append (list, wine); assert (zlist_exists (list, wine)); zlist_remove (list, wine); assert (!zlist_exists (list, wine)); assert (streq ((const char *) zlist_first (list), bread)); item = (char *) zlist_pop (list); assert (streq (item, bread)); free (item); item = (char *) zlist_pop (list); assert (streq (item, cheese)); free (item); zlist_destroy (&list); assert (list == NULL); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/ziflist.30000664000175000017500000001061512533132163014107 0ustar00phph00000000000000'\" t .\" Title: ziflist .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZIFLIST" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" ziflist \- List of network interfaces available on system .SH "SYNOPSIS" .sp .nf // Get a list of network interfaces currently defined on the system CZMQ_EXPORT ziflist_t * ziflist_new (); // Destroy a ziflist instance CZMQ_EXPORT void ziflist_destroy (ziflist_t **self_p); // Print properties of the ziflist object\&. CZMQ_EXPORT void ziflist_print (ziflist_t *self); // Reload network interfaces from system CZMQ_EXPORT void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system CZMQ_EXPORT size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none CZMQ_EXPORT const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one CZMQ_EXPORT const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string CZMQ_EXPORT const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string CZMQ_EXPORT const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string CZMQ_EXPORT const char * ziflist_netmask (ziflist_t *self); // Self test of this class\&. CZMQ_EXPORT void ziflist_test (bool verbose); .fi .SH "DESCRIPTION" .sp The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices)\&. The caller can then access the network interface information using an iterator that works like zlistx\&. Only stores those interfaces with broadcast capability, and ignores the loopback interface\&. .sp Please add @discuss section in \&.\&./src/ziflist\&.c\&. .SH "EXAMPLE" .PP \fBFrom ziflist_test method\fR. .sp .if n \{\ .RS 4 .\} .nf ziflist_t *iflist = ziflist_new (); assert (iflist); size_t items = ziflist_size (iflist); if (verbose) { // printf ("ziflist: interfaces=%zu\en", ziflist_size (iflist)); const char *name = ziflist_first (iflist); while (name) { printf (" \- name=%s address=%s netmask=%s broadcast=%s\en", name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist)); name = ziflist_next (iflist); } } ziflist_reload (iflist); assert (items == ziflist_size (iflist)); ziflist_destroy (&iflist); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/czmq.txt0000664000175000017500000004471012505070716014061 0ustar00phph00000000000000czmq(7) ======= NAME ---- czmq - high-level C binding for ZeroMQ SYNOPSIS -------- ---- #include cc ['flags'] 'files' -lzmq -lczmq ['libraries'] ---- DESCRIPTION ----------- Classes ~~~~~~~ These classes provide the main socket and message API: * linkczmq:zsock[3] - working with ZeroMQ sockets (high-level) * linkczmq:zstr[3] - sending and receiving strings * linkczmq:zmsg[3] - working with multipart messages * linkczmq:zframe[3] - working with single message frames * linkczmq:zactor[3] - Actor class (socket + thread) * linkczmq:zloop[3] - event-driven reactor * linkczmq:zpoller[3] - trivial socket poller class * linkczmq:zproxy[3] - proxy actor (like zmq_proxy_steerable) * linkczmq:zmonitor[3] - monitor events on ZeroMQ sockets These classes support authentication and encryption: * linkczmq:zauth[3] - authentication actor for ZeroMQ servers * linkczmq:zcert[3] - work with CURVE security certificates * linkczmq:zcertstore[3] - work with CURVE security certificate stores These classes provide generic containers: * linkczmq:zhash[3] - simple generic hash container * linkczmq:zhashx[3] - extended generic hash container * linkczmq:zlist[3] - simple generic list container * linkczmq:zlistx[3] - extended generic list container These classes wrap-up non-portable functionality: * linkczmq:zbeacon[3] - LAN discovery and presence * linkczmq:zclock[3] - millisecond clocks and delays * linkczmq:zdir[3] - work with file-system directories * linkczmq:zdir_patch[3] - work with directory differences * linkczmq:zfile[3] - work with file-system files * linkczmq:zsys[3] - system-level methods * linkczmq:zuuid[3] - UUID support class * linkczmq:ziflist[3] - list available network interfaces And these utility classes add value: * linkczmq:zchunk[3] - work with memory chunks * linkczmq:zconfig[3] - work with textual config files * linkczmq:zrex[3] - work with regular expressions * linkczmq:zgossip[3] - decentralized configuration management These classes are deprecated: * linkczmq:zctx[3] - working with ZeroMQ contexts * linkczmq:zsocket[3] - working with ZeroMQ sockets (low-level) * linkczmq:zsockopt[3] - get/set ZeroMQ socket options * linkczmq:zthread[3] - working with system threads * linkczmq:zauth_v2[3] - authentication for ZeroMQ servers * linkczmq:zbeacon_v2[3] - LAN discovery and presence * linkczmq:zmonitor_v2[3] - socket event monitor * linkczmq:zproxy_v2[3] - zmq_proxy wrapper Scope and Goals ~~~~~~~~~~~~~~~ CZMQ has these goals: * To wrap the ØMQ core API in semantics that are natural and lead to shorter, more readable applications. * To hide the differences between versions of ØMQ. * To provide a space for development of more sophisticated API semantics. Ownership and License ~~~~~~~~~~~~~~~~~~~~~ CZMQ is maintained by the ZeroMQ community at github.com/zeromq. Its other authors and contributors are listed in the AUTHORS file. The contributors are listed in AUTHORS. This project uses the MPL v2 license, see LICENSE. Contributing ~~~~~~~~~~~~ To submit an issue use the issue tracker at http://github.com/zeromq/czmq/issues. All discussion happens on the zeromq-dev 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 CZMQ 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 CZMQ ---------- Building and Installing ~~~~~~~~~~~~~~~~~~~~~~~ CZMQ uses autotools for packaging. To build from git (all example commands are for Linux): ---- git clone git://github.com/zeromq/czmq.git cd czmq 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 CZMQ selftests: ---- cd src ./czmq_selftest ---- Linking with an Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Include `czmq.h` in your application and link with CZMQ. Here is a typical gcc link command: ---- gcc -lczmq -lzmq myapp.c -o myapp ---- You should read `czmq.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 -lczmq -lzmq -l myapp ---- The Class Model ~~~~~~~~~~~~~~~ CZMQ consists of classes, each class consisting of a .h and a .c. Classes may depend on other classes. `czmq.h` includes all classes header files, all the time. For the user, CZMQ forms one single package. All classes start by including `czmq.h`. All applications that use CZMQ start by including `czmq.h`. `czmq.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`. Design Ideology --------------- 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. 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 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 CZMQ class): ---- zregexp_t *regexp = zregexp_new (regexp_string); if (!regexp) printf ("E: invalid regular expression: %s\n", regexp_string); else if (zregexp_match (regexp, input_buffer)) printf ("I: successful match for %s\n", input buffer); zregexp_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. Naming Style ~~~~~~~~~~~~ CZMQ 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: ---- zclassname_methodname ---- And the reader can easily parse this without needing special syntax to separate the class name from the method name. 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 zlist and zhash, 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. 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. czmq acts as 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 czmq_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 czmq_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 ---- CZMQ uses the GNU autotools system, so non-portable code can use the macros this defines. It can also use macros defined by the czmq_prelude.h header file. 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 `z`, 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 `czmq_selftest` application does this. * *Memory management*: CZMQ 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 valgrind. Under the Hood -------------- Adding a New Class ~~~~~~~~~~~~~~~~~~ If you define a new CZMQ class `myclass` you need to: * Write the `zmyclass.c` and `zmyclass.h` source files, in `src` and `include` respectively. * Add`#include ` to `include/czmq.h`. * Add the myclass header and test call to `src/czmq_selftest.c`. * Add a reference documentation to 'doc/zmyclass.txt'. * Add myclass to 'src/Makefile.am` and `doc/Makefile.am`. The `bin/newclass.sh` shell script will automate these steps for you. Coding Style ~~~~~~~~~~~~ In general the zctx 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: ---- zblob_t *file_buffer; /* Buffer for our file */ ... (100 lines of code) file_buffer = zblob_new (); ... ---- The style in CZMQ would be: ---- zblob_t *file_buffer = zblob_new (); ---- Assertions ~~~~~~~~~~ We use assertions heavily to catch bad argument values. The CZMQ 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. Documentation ~~~~~~~~~~~~~ Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (http://github.com/imatix/gitdown). The header file for a class must wrap its interface as follows (example is from include/zclock.h): ---- // @interface // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds int64_t zclock_time (void); // Self test of this class int zclock_test (Bool verbose); // @end ---- The source file for a class must provide documentation as follows: ---- /* @header ...short explanation of class... @discuss ...longer discussion of how it works... @end */ ---- The source file for a class then provides the self test example as follows: ---- // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); // @end ---- The template for man pages is in doc/mkman. Development ~~~~~~~~~~~ CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code: * Modify a class or method. * Update the test method for that class. * Run the 'selftest' script, which uses the Valgrind memcheck tool. * Repeat until perfect. Porting CZMQ ~~~~~~~~~~~~ When you try CZMQ 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 `czmq_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 czmq_prelude.h. * Defining macros that rename exotic library functions to more conventional names: do this in czmq_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 CZMQ code is Linux, gcc, POSIX. czmq-3.0.2/doc/zdir_patch.txt0000664000175000017500000000377312533132136015236 0ustar00phph00000000000000zdir_patch(3) ============= NAME ---- zdir_patch - work with directory patches SYNOPSIS -------- ---- typedef enum { ZDIR_PATCH_CREATE = 1, ZDIR_PATCH_DELETE = 2 } zdir_patch_op_t; // Create new patch CZMQ_EXPORT zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, zdir_patch_op_t op, const char *alias); // Destroy a patch CZMQ_EXPORT void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path CZMQ_EXPORT const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item CZMQ_EXPORT zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation CZMQ_EXPORT zdir_patch_op_t zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path CZMQ_EXPORT const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) CZMQ_EXPORT void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file CZMQ_EXPORT const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. CZMQ_EXPORT void zdir_patch_test (bool verbose); ---- DESCRIPTION ----------- The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time). Please add @discuss section in ../src/zdir_patch.c. EXAMPLE ------- .From zdir_patch_test method ---- zfile_t *file = zfile_new (".", "bilbo"); assert (file); zdir_patch_t *patch = zdir_patch_new (".", file, patch_create, "/"); assert (patch); zfile_destroy (&file); file = zdir_patch_file (patch); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (streq (zdir_patch_vpath (patch), "/bilbo")); zdir_patch_destroy (&patch); ---- czmq-3.0.2/doc/zbeacon.30000664000175000017500000002000312533132153014033 0ustar00phph00000000000000'\" t .\" Title: zbeacon .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZBEACON" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zbeacon \- LAN discovery and presence .SH "SYNOPSIS" .sp .nf // Create new zbeacon actor instance: // // zactor_t *beacon = zactor_new (zbeacon, NULL); // // Destroy zbeacon instance: // // zactor_destroy (&beacon); // // Enable verbose logging of commands and activity: // // zstr_send (beacon, "VERBOSE"); // // Configure beacon to run on specified UDP port, and return the name of // the host, which can be used as endpoint for incoming connections\&. To // force the beacon to operate on a given interface, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating // the beacon\&. If the system does not support UDP broadcasts (lacking a // workable interface), returns an empty hostname: // // // Pictures: \*(Aqs\*(Aq = C string, \*(Aqi\*(Aq = int // zsock_send (beacon, "si", "CONFIGURE", port_number); // char *hostname = zstr_recv (beacon); // // Start broadcasting a beacon at a specified interval in msec\&. The beacon // data can be at most UDP_FRAME_MAX bytes; this constant is defined in // zsys\&.h to be 255: // // // Pictures: \*(Aqb\*(Aq = byte * data + size_t size // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); // // Stop broadcasting the beacon: // // zstr_sendx (beacon, "SILENCE", NULL); // // Start listening to beacons from peers\&. The filter is used to do a prefix // match on received beacons, to remove junk\&. Note that any received data // that is identical to our broadcast beacon_data is discarded in any case\&. // If the filter size is zero, we get all peer beacons: // // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); // // Stop listening to other peers // // zstr_sendx (beacon, "UNSUBSCRIBE", NULL); // // Receive next beacon from a peer\&. Received beacons are always a 2\-frame // message containing the ipaddress of the sender, and then the binary // beacon data as published by the sender: // // zmsg_t *msg = zmsg_recv (beacon); // // This is the zbeacon constructor as a zactor_fn: CZMQ_EXPORT void zbeacon (zsock_t *pipe, void *unused); // Self test of this class CZMQ_EXPORT void zbeacon_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zbeacon class implements a peer\-to\-peer discovery service for local networks\&. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network\&. This implementation uses IPv4 UDP broadcasts\&. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons\&. Beacons are sent and received asynchronously in the background\&. .sp This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&. .SH "EXAMPLE" .PP \fBFrom zbeacon_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Test 1 \- two beacons, one speaking, one listening // Create speaker beacon to broadcast our service zactor_t *speaker = zactor_new (zbeacon, NULL); assert (speaker); if (verbose) zstr_sendx (speaker, "VERBOSE", NULL); zsock_send (speaker, "si", "CONFIGURE", 9999); char *hostname = zstr_recv (speaker); if (!*hostname) { printf ("OK (skipping test, no UDP broadcasting)\en"); zactor_destroy (&speaker); free (hostname); return; } free (hostname); // Create listener beacon on port 9999 to lookup service zactor_t *listener = zactor_new (zbeacon, NULL); assert (listener); if (verbose) zstr_sendx (listener, "VERBOSE", NULL); zsock_send (listener, "si", "CONFIGURE", 9999); hostname = zstr_recv (listener); assert (*hostname); free (hostname); // We will broadcast the magic value 0xCAFE byte announcement [2] = { 0xCA, 0xFE }; zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100); // We will listen to anything (empty subscription) zsock_send (listener, "sb", "SUBSCRIBE", "", 0); // Wait for at most 1/2 second if there\*(Aqs no broadcasting zsock_set_rcvtimeo (listener, 500); char *ipaddress = zstr_recv (listener); if (ipaddress) { zframe_t *content = zframe_recv (listener); assert (zframe_size (content) == 2); assert (zframe_data (content) [0] == 0xCA); assert (zframe_data (content) [1] == 0xFE); zframe_destroy (&content); zstr_free (&ipaddress); zstr_sendx (speaker, "SILENCE", NULL); } zactor_destroy (&listener); zactor_destroy (&speaker); // Test subscription filter using a 3\-node setup zactor_t *node1 = zactor_new (zbeacon, NULL); assert (node1); zsock_send (node1, "si", "CONFIGURE", 5670); hostname = zstr_recv (node1); assert (*hostname); free (hostname); zactor_t *node2 = zactor_new (zbeacon, NULL); assert (node2); zsock_send (node2, "si", "CONFIGURE", 5670); hostname = zstr_recv (node2); assert (*hostname); free (hostname); zactor_t *node3 = zactor_new (zbeacon, NULL); assert (node3); zsock_send (node3, "si", "CONFIGURE", 5670); hostname = zstr_recv (node3); assert (*hostname); free (hostname); zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250); zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250); zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250); zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new (node1, node2, node3, NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at \- zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == node1); char *ipaddress, *received; zstr_recvx (node1, &ipaddress, &received, NULL); assert (streq (received, "NODE/2")); zstr_free (&ipaddress); zstr_free (&received); } } zpoller_destroy (&poller); // Stop listening zstr_sendx (node1, "UNSUBSCRIBE", NULL); // Stop all node broadcasts zstr_sendx (node1, "SILENCE", NULL); zstr_sendx (node2, "SILENCE", NULL); zstr_sendx (node3, "SILENCE", NULL); // Destroy the test nodes zactor_destroy (&node1); zactor_destroy (&node2); zactor_destroy (&node3); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zpoller.30000664000175000017500000001463312533132165014120 0ustar00phph00000000000000'\" t .\" Title: zpoller .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZPOLLER" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zpoller \- trivial socket poller class .SH "SYNOPSIS" .sp .nf // Create new poller; the reader can be a libzmq socket (void *), a zsock_t // instance, or a zactor_t instance\&. CZMQ_EXPORT zpoller_t * zpoller_new (void *reader, \&.\&.\&.); // Destroy a poller CZMQ_EXPORT void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled\&. Returns 0 if OK, \-1 on failure\&. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance\&. CZMQ_EXPORT int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, \-1 on failure\&. The // reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t // instance\&. CZMQ_EXPORT int zpoller_remove (zpoller_t *self, void *reader); // Poll the registered readers for I/O, return first reader that has input\&. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add\&. The timeout should be // zero or greater, or \-1 to wait indefinitely\&. Socket priority is defined // by their order in the poll list\&. If you need a balanced poll, use the low // level zmq_poll method directly\&. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL\&. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated ()\&. The timeout is in msec\&. CZMQ_EXPORT void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error\&. CZMQ_EXPORT bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed\&. CZMQ_EXPORT bool zpoller_terminated (zpoller_t *self); // Ignore zsys_interrupted flag in this poller\&. By default, a zpoller_wait will // return immediately if detects zsys_interrupted is set to something other than // zero\&. Calling zpoller_ignore_interrupts will supress this behavior\&. CZMQ_EXPORT void zpoller_ignore_interrupts(zpoller_t *self); // Self test of this class CZMQ_EXPORT void zpoller_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zpoller class provides a minimalist interface to ZeroMQ\(cqs zmq_poll API, for the very common case of reading from a number of sockets\&. It does not provide polling for output, nor polling on file handles\&. If you need either of these, use the zmq_poll API directly\&. .sp Please add @discuss section in \&.\&./src/zpoller\&.c\&. .SH "EXAMPLE" .PP \fBFrom zpoller_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create a few sockets zsock_t *vent = zsock_new (ZMQ_PUSH); assert (vent); int port_nbr = zsock_bind (vent, "tcp://127\&.0\&.0\&.1:*"); assert (port_nbr != \-1); zsock_t *sink = zsock_new (ZMQ_PULL); assert (sink); int rc = zsock_connect (sink, "tcp://127\&.0\&.0\&.1:%d", port_nbr); assert (rc != \-1); zsock_t *bowl = zsock_new (ZMQ_PULL); assert (bowl); zsock_t *dish = zsock_new (ZMQ_PULL); assert (dish); // Set\-up poller zpoller_t *poller = zpoller_new (bowl, dish, NULL); assert (poller); // Add a reader to the existing poller rc = zpoller_add (poller, sink); assert (rc == 0); zstr_send (vent, "Hello, World"); // We expect a message only on the sink zsock_t *which = (zsock_t *) zpoller_wait (poller, \-1); assert (which == sink); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); char *message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); // Stop polling reader rc = zpoller_remove (poller, sink); assert (rc == 0); // Check we can poll an FD rc = zsock_connect (bowl, "tcp://127\&.0\&.0\&.1:%d", port_nbr); assert (rc != \-1); SOCKET fd = zsock_fd (bowl); rc = zpoller_add (poller, (void *) &fd); assert (rc != \-1); zstr_send (vent, "Hello again, world"); assert (zpoller_wait (poller, 500) == &fd); // Check whether poller properly ignores zsys_interrupted flag // when asked to zsys_interrupted = 1; zpoller_wait (poller, 0); assert (zpoller_terminated (poller)); zpoller_ignore_interrupts (poller); zpoller_wait (poller, 0); assert (!zpoller_terminated (poller)); zsys_interrupted = 0; // Destroy poller and sockets zpoller_destroy (&poller); zsock_destroy (&vent); zsock_destroy (&sink); zsock_destroy (&bowl); zsock_destroy (&dish); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zbeacon.txt0000664000175000017500000001366212533132136014526 0ustar00phph00000000000000zbeacon(3) ========== NAME ---- zbeacon - LAN discovery and presence SYNOPSIS -------- ---- // Create new zbeacon actor instance: // // zactor_t *beacon = zactor_new (zbeacon, NULL); // // Destroy zbeacon instance: // // zactor_destroy (&beacon); // // Enable verbose logging of commands and activity: // // zstr_send (beacon, "VERBOSE"); // // Configure beacon to run on specified UDP port, and return the name of // the host, which can be used as endpoint for incoming connections. To // force the beacon to operate on a given interface, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating // the beacon. If the system does not support UDP broadcasts (lacking a // workable interface), returns an empty hostname: // // // Pictures: 's' = C string, 'i' = int // zsock_send (beacon, "si", "CONFIGURE", port_number); // char *hostname = zstr_recv (beacon); // // Start broadcasting a beacon at a specified interval in msec. The beacon // data can be at most UDP_FRAME_MAX bytes; this constant is defined in // zsys.h to be 255: // // // Pictures: 'b' = byte * data + size_t size // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); // // Stop broadcasting the beacon: // // zstr_sendx (beacon, "SILENCE", NULL); // // Start listening to beacons from peers. The filter is used to do a prefix // match on received beacons, to remove junk. Note that any received data // that is identical to our broadcast beacon_data is discarded in any case. // If the filter size is zero, we get all peer beacons: // // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); // // Stop listening to other peers // // zstr_sendx (beacon, "UNSUBSCRIBE", NULL); // // Receive next beacon from a peer. Received beacons are always a 2-frame // message containing the ipaddress of the sender, and then the binary // beacon data as published by the sender: // // zmsg_t *msg = zmsg_recv (beacon); // // This is the zbeacon constructor as a zactor_fn: CZMQ_EXPORT void zbeacon (zsock_t *pipe, void *unused); // Self test of this class CZMQ_EXPORT void zbeacon_test (bool verbose); ---- DESCRIPTION ----------- The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). EXAMPLE ------- .From zbeacon_test method ---- // Test 1 - two beacons, one speaking, one listening // Create speaker beacon to broadcast our service zactor_t *speaker = zactor_new (zbeacon, NULL); assert (speaker); if (verbose) zstr_sendx (speaker, "VERBOSE", NULL); zsock_send (speaker, "si", "CONFIGURE", 9999); char *hostname = zstr_recv (speaker); if (!*hostname) { printf ("OK (skipping test, no UDP broadcasting)\n"); zactor_destroy (&speaker); free (hostname); return; } free (hostname); // Create listener beacon on port 9999 to lookup service zactor_t *listener = zactor_new (zbeacon, NULL); assert (listener); if (verbose) zstr_sendx (listener, "VERBOSE", NULL); zsock_send (listener, "si", "CONFIGURE", 9999); hostname = zstr_recv (listener); assert (*hostname); free (hostname); // We will broadcast the magic value 0xCAFE byte announcement [2] = { 0xCA, 0xFE }; zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100); // We will listen to anything (empty subscription) zsock_send (listener, "sb", "SUBSCRIBE", "", 0); // Wait for at most 1/2 second if there's no broadcasting zsock_set_rcvtimeo (listener, 500); char *ipaddress = zstr_recv (listener); if (ipaddress) { zframe_t *content = zframe_recv (listener); assert (zframe_size (content) == 2); assert (zframe_data (content) [0] == 0xCA); assert (zframe_data (content) [1] == 0xFE); zframe_destroy (&content); zstr_free (&ipaddress); zstr_sendx (speaker, "SILENCE", NULL); } zactor_destroy (&listener); zactor_destroy (&speaker); // Test subscription filter using a 3-node setup zactor_t *node1 = zactor_new (zbeacon, NULL); assert (node1); zsock_send (node1, "si", "CONFIGURE", 5670); hostname = zstr_recv (node1); assert (*hostname); free (hostname); zactor_t *node2 = zactor_new (zbeacon, NULL); assert (node2); zsock_send (node2, "si", "CONFIGURE", 5670); hostname = zstr_recv (node2); assert (*hostname); free (hostname); zactor_t *node3 = zactor_new (zbeacon, NULL); assert (node3); zsock_send (node3, "si", "CONFIGURE", 5670); hostname = zstr_recv (node3); assert (*hostname); free (hostname); zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250); zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250); zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250); zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new (node1, node2, node3, NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == node1); char *ipaddress, *received; zstr_recvx (node1, &ipaddress, &received, NULL); assert (streq (received, "NODE/2")); zstr_free (&ipaddress); zstr_free (&received); } } zpoller_destroy (&poller); // Stop listening zstr_sendx (node1, "UNSUBSCRIBE", NULL); // Stop all node broadcasts zstr_sendx (node1, "SILENCE", NULL); zstr_sendx (node2, "SILENCE", NULL); zstr_sendx (node3, "SILENCE", NULL); // Destroy the test nodes zactor_destroy (&node1); zactor_destroy (&node2); zactor_destroy (&node3); ---- czmq-3.0.2/doc/zpoller.txt0000664000175000017500000001045712533132136014573 0ustar00phph00000000000000zpoller(3) ========== NAME ---- zpoller - trivial socket poller class SYNOPSIS -------- ---- // Create new poller; the reader can be a libzmq socket (void *), a zsock_t // instance, or a zactor_t instance. CZMQ_EXPORT zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller CZMQ_EXPORT void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. CZMQ_EXPORT int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The // reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t // instance. CZMQ_EXPORT int zpoller_remove (zpoller_t *self, void *reader); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. CZMQ_EXPORT void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. CZMQ_EXPORT bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. CZMQ_EXPORT bool zpoller_terminated (zpoller_t *self); // Ignore zsys_interrupted flag in this poller. By default, a zpoller_wait will // return immediately if detects zsys_interrupted is set to something other than // zero. Calling zpoller_ignore_interrupts will supress this behavior. CZMQ_EXPORT void zpoller_ignore_interrupts(zpoller_t *self); // Self test of this class CZMQ_EXPORT void zpoller_test (bool verbose); ---- DESCRIPTION ----------- The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll API, for the very common case of reading from a number of sockets. It does not provide polling for output, nor polling on file handles. If you need either of these, use the zmq_poll API directly. Please add @discuss section in ../src/zpoller.c. EXAMPLE ------- .From zpoller_test method ---- // Create a few sockets zsock_t *vent = zsock_new (ZMQ_PUSH); assert (vent); int port_nbr = zsock_bind (vent, "tcp://127.0.0.1:*"); assert (port_nbr != -1); zsock_t *sink = zsock_new (ZMQ_PULL); assert (sink); int rc = zsock_connect (sink, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zsock_t *bowl = zsock_new (ZMQ_PULL); assert (bowl); zsock_t *dish = zsock_new (ZMQ_PULL); assert (dish); // Set-up poller zpoller_t *poller = zpoller_new (bowl, dish, NULL); assert (poller); // Add a reader to the existing poller rc = zpoller_add (poller, sink); assert (rc == 0); zstr_send (vent, "Hello, World"); // We expect a message only on the sink zsock_t *which = (zsock_t *) zpoller_wait (poller, -1); assert (which == sink); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); char *message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); // Stop polling reader rc = zpoller_remove (poller, sink); assert (rc == 0); // Check we can poll an FD rc = zsock_connect (bowl, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); SOCKET fd = zsock_fd (bowl); rc = zpoller_add (poller, (void *) &fd); assert (rc != -1); zstr_send (vent, "Hello again, world"); assert (zpoller_wait (poller, 500) == &fd); // Check whether poller properly ignores zsys_interrupted flag // when asked to zsys_interrupted = 1; zpoller_wait (poller, 0); assert (zpoller_terminated (poller)); zpoller_ignore_interrupts (poller); zpoller_wait (poller, 0); assert (!zpoller_terminated (poller)); zsys_interrupted = 0; // Destroy poller and sockets zpoller_destroy (&poller); zsock_destroy (&vent); zsock_destroy (&sink); zsock_destroy (&bowl); zsock_destroy (&dish); ---- czmq-3.0.2/doc/zsocket.txt0000664000175000017500000001230712533132136014562 0ustar00phph00000000000000zsocket(3) ========== NAME ---- zsocket - working with 0MQ sockets (deprecated) SYNOPSIS -------- ---- // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding. #define ZSOCKET_DYNFROM 0xc000 #define ZSOCKET_DYNTO 0xffff // Callback function for zero-copy methods typedef void (zsocket_free_fn) (void *data, void *arg); // Create a new socket within our CZMQ context, replaces zmq_socket. // Use this to get automatic management of the socket at shutdown. // Note: SUB sockets do not automatically subscribe to everything; you // must set filters explicitly. CZMQ_EXPORT void * zsocket_new (zctx_t *self, int type); // Destroy a socket within our CZMQ context, replaces zmq_close. CZMQ_EXPORT void zsocket_destroy (zctx_t *ctx, void *self); // Bind a socket to a formatted endpoint. If the port is specified as // '*', binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO // and returns the actual port number used. Otherwise asserts that the // bind succeeded with the specified port number. Always returns the // port number if successful. CZMQ_EXPORT int zsocket_bind (void *self, const char *format, ...); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsocket_unbind (void *self, const char *format, ...); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsocket_connect (void *self, const char *format, ...); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsocket_disconnect (void *self, const char *format, ...); // Poll for input events on the socket. Returns TRUE if there is input // ready on the socket, else FALSE. CZMQ_EXPORT bool zsocket_poll (void *self, int msecs); // Returns socket type as printable constant string CZMQ_EXPORT const char * zsocket_type_str (void *self); // Send data over a socket as a single message frame. // Accepts these flags: ZFRAME_MORE and ZFRAME_DONTWAIT. // Returns -1 on error, 0 on success CZMQ_EXPORT int zsocket_sendmem (void *self, const void *data, size_t size, int flags); // Send a signal over a socket. A signal is a zero-byte message. // Signals are used primarily between threads, over pipe sockets. // Returns -1 if there was an error sending the signal. CZMQ_EXPORT int zsocket_signal (void *self); // Wait on a signal. Use this to coordinate between threads, over // pipe pairs. Returns -1 on error, 0 on success. CZMQ_EXPORT int zsocket_wait (void *self); // Self test of this class CZMQ_EXPORT void zsocket_test (bool verbose); ---- DESCRIPTION ----------- The zsocket class provides helper functions for 0MQ sockets. It doesn't wrap the 0MQ socket type, to avoid breaking all libzmq socket-related calls. Please add @discuss section in ../src/zsocket.c. EXAMPLE ------- .From zsocket_test method ---- zctx_t *ctx = zctx_new (); assert (ctx); // Create a detached thread, let it run char *interf = "127.0.0.1"; char *domain = "localhost"; int service = 5560; void *writer = zsocket_new (ctx, ZMQ_PUSH); assert (writer); void *reader = zsocket_new (ctx, ZMQ_PULL); assert (reader); assert (streq (zsocket_type_str (writer), "PUSH")); assert (streq (zsocket_type_str (reader), "PULL")); int rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsocket_unbind (writer, "tcp://%s:%d", interf, service); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #endif rc = zsocket_connect (reader, "tcp://%s:%d", domain, service); assert (rc == 0); zstr_send (writer, "HELLO"); char *message = zstr_recv (reader); assert (message); assert (streq (message, "HELLO")); free (message); // Test binding to ports int port = zsocket_bind (writer, "tcp://%s:*", interf); assert (port >= ZSOCKET_DYNFROM && port <= ZSOCKET_DYNTO); assert (zsocket_poll (writer, 100) == false); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsocket_connect (reader, "txp://%s:%d", domain, service); assert (rc == -1); // Test sending frames to socket rc = zsocket_sendmem (writer, "ABC", 3, ZFRAME_MORE); assert (rc == 0); rc = zsocket_sendmem (writer, "DEFG", 4, 0); assert (rc == 0); zframe_t *frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "ABC")); assert (zframe_more (frame)); zframe_destroy (&frame); frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "DEFG")); assert (!zframe_more (frame)); zframe_destroy (&frame); rc = zsocket_signal (writer); assert (rc == 0); rc = zsocket_wait (reader); assert (rc == 0); zsocket_destroy (ctx, reader); zsocket_destroy (ctx, writer); zctx_destroy (&ctx); ---- czmq-3.0.2/doc/asciidoc.conf0000664000175000017500000000432612535241705014773 0ustar00phph00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ [paradef-default] literal-style=template="literalparagraph" [macros] (?su)[\\]?(?Plinkczmq):(?P\S*?)\[(?P.*?)\]= ifdef::backend-docbook[] [linkczmq-inlinemacro] {0%{target}} {0#} {0#{target}{0}} {0#} endif::backend-docbook[] ifdef::backend-xhtml11[] [linkczmq-inlinemacro] {target}{0?({0})} endif::backend-xhtml11[] ifdef::doctype-manpage[] ifdef::backend-docbook[] [header] template::[header-declarations] {mantitle} {manvolnum} CZMQ {czmq_version} CZMQ Manual {manname} {manpurpose} [footer] AUTHORS The czmq manual was written by the authors in the AUTHORS file. RESOURCES Main web site: Report bugs to the email <zeromq-dev@lists.zeromq.org> COPYRIGHT Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. LICENSE included with the czmq distribution. endif::backend-docbook[] endif::doctype-manpage[] czmq-3.0.2/doc/zconfig.30000664000175000017500000002437712533132156014076 0ustar00phph00000000000000'\" t .\" Title: zconfig .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZCONFIG" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zconfig \- work with config files written in rfc\&.zeromq\&.org/spec:4/ZPL\&. .SH "SYNOPSIS" .sp .nf // Function that executes config typedef int (zconfig_fct) (zconfig_t *self, void *arg, int level); // Create new config item CZMQ_EXPORT zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children CZMQ_EXPORT void zconfig_destroy (zconfig_t **self_p); // Return name of config item CZMQ_EXPORT char * zconfig_name (zconfig_t *self); // Return value of config item CZMQ_EXPORT char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value CZMQ_EXPORT void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value\&. CZMQ_EXPORT void zconfig_putf (zconfig_t *self, const char *path, const char *format, \&.\&.\&.); // Get value for config item into a string value; leading slash is optional // and ignored\&. CZMQ_EXPORT char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item\&. The new value may be a string, a printf // format, or NULL\&. Note that if string may possibly contain \*(Aq%\*(Aq, or if it // comes from an insecure source, you must use \*(Aq%s\*(Aq as the format, followed // by the string\&. CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, \&.\&.\&.); // Find our first child, if any CZMQ_EXPORT zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any CZMQ_EXPORT zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored\&. CZMQ_EXPORT zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth CZMQ_EXPORT zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else \-1\&. CZMQ_EXPORT int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk\&. You can add as many // comment lines as you like\&. If you use a null format, all comments are // deleted\&. CZMQ_EXPORT void zconfig_set_comment (zconfig_t *self, const char *format, \&.\&.\&.); // Return comments of config item, as zlist\&. CZMQ_EXPORT zlist_t * zconfig_comments (zconfig_t *self); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable\&. Returns NULL // if the file does not exist\&. CZMQ_EXPORT zconfig_t * zconfig_load (const char *filename); // Save a config tree to a specified ZPL text file, where a filename // "\-" means dump to standard output\&. CZMQ_EXPORT int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename\&. CZMQ_EXPORT zconfig_t * zconfig_loadf (const char *format, \&.\&.\&.); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename\&. CZMQ_EXPORT int zconfig_savef (zconfig_t *self, const char *format, \&.\&.\&.); // Report filename used during zconfig_load, or NULL if none CZMQ_EXPORT const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from\&. // Returns 0 if OK, \-1 if there was an error (and then does not change // existing data)\&. CZMQ_EXPORT int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk CZMQ_EXPORT zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk CZMQ_EXPORT zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null\-terminated string CZMQ_EXPORT zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string CZMQ_EXPORT char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded\&. CZMQ_EXPORT bool zconfig_has_changed (zconfig_t *self); // Print the config file to open stream CZMQ_EXPORT void zconfig_fprint (zconfig_t *self, FILE *file); // Print the config file to stdout CZMQ_EXPORT void zconfig_print (zconfig_t *self); .fi .SH "DESCRIPTION" .sp Lets applications load, work with, and save configuration files\&. This implements rfc\&.zeromq\&.org/spec:4/ZPL, which is a simple structured text format for configuration files\&. .sp Here is an example ZPL stream and corresponding config structure: .sp .if n \{\ .RS 4 .\} .nf context iothreads = 1 verbose = 1 # Ask for a trace main type = zqueue # ZMQ_DEVICE type frontend option hwm = 1000 swap = 25000000 # 25MB bind = \*(Aqinproc://addr1\*(Aq bind = \*(Aqipc://addr2\*(Aq backend bind = inproc://addr3 .fi .if n \{\ .RE .\} .sp .if n \{\ .RS 4 .\} .nf root Down = child | Across = next v context\-\->main | | | v | type=queue\-\->frontend\-\->backend | | | | | v | | bind=inproc://addr3 | v | option\-\->bind=inproc://addr1\-\->bind=ipc://addr2 | | | v | hwm=1000\-\->swap=25000000 v iothreads=1\-\->verbose=false .fi .if n \{\ .RE .\} .SH "EXAMPLE" .PP \fBFrom zconfig_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create temporary directory for test files # define TESTDIR "\&.test_zconfig" zsys_dir_create (TESTDIR); zconfig_t *root = zconfig_new ("root", NULL); assert (root); zconfig_t *section, *item; section = zconfig_new ("headers", root); assert (section); item = zconfig_new ("email", section); assert (item); zconfig_set_value (item, "some@random\&.com"); item = zconfig_new ("name", section); assert (item); zconfig_set_value (item, "Justin Kayce"); zconfig_putf (root, "/curve/secret\-key", "%s", "Top Secret"); zconfig_set_comment (root, " CURVE certificate"); zconfig_set_comment (root, " \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-"); assert (zconfig_comments (root)); zconfig_save (root, TESTDIR "/test\&.cfg"); zconfig_destroy (&root); root = zconfig_load (TESTDIR "/test\&.cfg"); if (verbose) zconfig_save (root, "\-"); assert (streq (zconfig_filename (root), TESTDIR "/test\&.cfg")); char *email = zconfig_get (root, "/headers/email", NULL); assert (email); assert (streq (email, "some@random\&.com")); char *passwd = zconfig_get (root, "/curve/secret\-key", NULL); assert (passwd); assert (streq (passwd, "Top Secret")); zconfig_savef (root, "%s/%s", TESTDIR, "test\&.cfg"); assert (!zconfig_has_changed (root)); int rc = zconfig_reload (&root); assert (rc == 0); assert (!zconfig_has_changed (root)); zconfig_destroy (&root); // Test chunk load/save root = zconfig_new ("root", NULL); assert (root); section = zconfig_new ("section", root); assert (section); item = zconfig_new ("value", section); assert (item); zconfig_set_value (item, "somevalue"); zconfig_t *search = zconfig_locate (root, "section/value"); assert (search == item); zchunk_t *chunk = zconfig_chunk_save (root); assert (strlen ((char *) zchunk_data (chunk)) == 32); char *string = zconfig_str_save (root); assert (string); assert (streq (string, (char *) zchunk_data (chunk))); free (string); assert (chunk); zconfig_destroy (&root); root = zconfig_chunk_load (chunk); assert (root); char *value = zconfig_get (root, "/section/value", NULL); assert (value); assert (streq (value, "somevalue")); // Test config can\*(Aqt be saved to a file in a path that doesn\*(Aqt // exist or isn\*(Aqt writable rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", TESTDIR, "test\&.cfg"); assert (rc == \-1); zconfig_destroy (&root); zchunk_destroy (&chunk); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zuuid.txt0000664000175000017500000000647312533132136014247 0ustar00phph00000000000000zuuid(3) ======== NAME ---- zuuid - UUID support class SYNOPSIS -------- ---- // Constructor CZMQ_EXPORT zuuid_t * zuuid_new (void); // Destructor CZMQ_EXPORT void zuuid_destroy (zuuid_t **self_p); // Create UUID object from supplied ZUUID_LEN-octet value CZMQ_EXPORT zuuid_t * zuuid_new_from (const byte *source); // Set UUID to new supplied ZUUID_LEN-octet value CZMQ_EXPORT void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. CZMQ_EXPORT int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data CZMQ_EXPORT const byte * zuuid_data (zuuid_t *self); // Return UUID binary size CZMQ_EXPORT size_t zuuid_size (zuuid_t *self); // Returns UUID as string CZMQ_EXPORT const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier CZMQ_EXPORT const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array CZMQ_EXPORT void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value CZMQ_EXPORT bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value CZMQ_EXPORT bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. CZMQ_EXPORT zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class CZMQ_EXPORT void zuuid_test (bool verbose); ---- DESCRIPTION ----------- The zuuid class generates UUIDs and provides methods for working with them. If you build CZMQ with libuuid, on Unix/Linux, it will use that library. On Windows it will use UuidCreate(). Otherwise it will use a random number generator to produce convincing imitations of uuids. Please add @discuss section in ../src/zuuid.c. EXAMPLE ------- .From zuuid_test method ---- // Simple create/destroy test assert (ZUUID_LEN == 16); assert (ZUUID_STR_LEN == 32); zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == ZUUID_LEN); assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN); zuuid_t *copy = zuuid_dup (uuid); assert (streq (zuuid_str (uuid), zuuid_str (copy))); // Check set/set_str/export methods const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38"; const char *myuuid2 = "8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38"; const char *myuuid3 = "{8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38}"; const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838"; int rc = zuuid_set_str (uuid, myuuid); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid2); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid3); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid4); assert (rc == -1); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the canonical string format assert (streq (zuuid_str_canonical (uuid), "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38")); zuuid_destroy (&uuid); zuuid_destroy (©); ---- czmq-3.0.2/doc/zauth_v2.30000664000175000017500000002211312533132173014162 0ustar00phph00000000000000'\" t .\" Title: zauth_v2 .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZAUTH_V2" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zauth_v2 \- authentication for ZeroMQ servers (deprecated) .SH "SYNOPSIS" .sp .nf #ifndef CURVE_ALLOW_ANY # define CURVE_ALLOW_ANY "*" #endif // Constructor // Install authentication for the specified context\&. Returns a new zauth // object that you can use to configure authentication\&. Note that until you // add policies, all incoming NULL connections are allowed (classic ZeroMQ // behaviour), and all PLAIN and CURVE connections are denied\&. If there was // an error during initialization, returns NULL\&. CZMQ_EXPORT zauth_t * zauth_new (zctx_t *ctx); // Destructor CZMQ_EXPORT void zauth_destroy (zauth_t **self_p); // Allow (whitelist) a single IP address\&. For NULL, all clients from this // address will be accepted\&. For PLAIN and CURVE, they will be allowed to // continue with authentication\&. You can call this method multiple times // to whitelist multiple IP addresses\&. If you whitelist a single address, // any non\-whitelisted addresses are treated as blacklisted\&. CZMQ_EXPORT void zauth_allow (zauth_t *self, const char *address); // Deny (blacklist) a single IP address\&. For all security mechanisms, this // rejects the connection without any further authentication\&. Use either a // whitelist, or a blacklist, not not both\&. If you define both a whitelist // and a blacklist, only the whitelist takes effect\&. CZMQ_EXPORT void zauth_deny (zauth_t *self, const char *address); // Configure PLAIN authentication for a given domain\&. PLAIN authentication // uses a plain\-text password file\&. To cover all domains, use "*"\&. You can // modify the password file at any time; it is reloaded automatically\&. CZMQ_EXPORT void zauth_configure_plain (zauth_t *self, const char *domain, const char *filename); // Configure CURVE authentication for a given domain\&. CURVE authentication // uses a directory that holds all public client certificates, i\&.e\&. their // public keys\&. The certificates must be in zcert_save () format\&. To cover // all domains, use "*"\&. You can add and remove certificates in that // directory at any time\&. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the location\&. CZMQ_EXPORT void zauth_configure_curve (zauth_t *self, const char *domain, const char *location); // Configure GSSAPI authentication for a given domain\&. GSSAPI authentication // uses an underlying mechanism (usually Kerberos) to establish a secure // context and perform mutual authentication\&. To cover all domains, use "*"\&. CZMQ_EXPORT void zauth_configure_gssapi (zauth_t *self, char *domain); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zauth_set_verbose (zauth_t *self, bool verbose); // Selftest CZMQ_EXPORT void zauth_v2_test (bool verbose); .fi .SH "DESCRIPTION" .sp A zauth object takes over authentication for all incoming connections in its context\&. .sp This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes\&. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets\&. .SH "EXAMPLE" .PP \fBFrom zauth_v2_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create temporary directory for test files # define TESTDIR "\&.test_zauth" zsys_dir_create (TESTDIR); // Install the authenticator zctx_t *ctx = zctx_new (); assert (ctx); zauth_t *auth = zauth_new (ctx); assert (auth); zauth_set_verbose (auth, verbose); // A default NULL connection should always success, and not // go through our authentication infrastructure at all\&. void *server = zsocket_new (ctx, ZMQ_PUSH); assert (server); void *client = zsocket_new (ctx, ZMQ_PULL); assert (client); bool success = s_can_connect (ctx, &server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed\&. zsocket_set_zap_domain (server, "global"); success = s_can_connect (ctx, &server, &client); assert (success); // Blacklist 127\&.0\&.0\&.1, connection should fail zsocket_set_zap_domain (server, "global"); zauth_deny (auth, "127\&.0\&.0\&.1"); success = s_can_connect (ctx, &server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsocket_set_zap_domain (server, "global"); zauth_allow (auth, "127\&.0\&.0\&.1"); success = s_can_connect (ctx, &server, &client); assert (success); // Try PLAIN authentication zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); success = s_can_connect (ctx, &server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password\-file", "w"); assert (password); fprintf (password, "admin=Password\en"); fclose (password); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); zauth_configure_plain (auth, "*", TESTDIR "/password\-file"); success = s_can_connect (ctx, &server, &client); assert (success); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Bogus"); success = s_can_connect (ctx, &server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We\*(Aqll create two new certificates and save the client public // certificate on disk; in a real case we\*(Aqd transfer this securely // from the client machine to the server machine\&. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting\-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); success = s_can_connect (ctx, &server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zauth_configure_curve (auth, "*", CURVE_ALLOW_ANY); success = s_can_connect (ctx, &server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert\&.txt"); zauth_configure_curve (auth, "*", TESTDIR); success = s_can_connect (ctx, &server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zauth_destroy (&auth); success = s_can_connect (ctx, &server, &client); assert (success); zctx_destroy (&ctx); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zlistx.txt0000664000175000017500000002426312533132136014441 0ustar00phph00000000000000zlistx(3) ========= NAME ---- zlistx - extended generic list container SYNOPSIS -------- ---- // Create a new, empty list. CZMQ_EXPORT zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. CZMQ_EXPORT void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list CZMQ_EXPORT size_t zlistx_size (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). CZMQ_EXPORT void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). CZMQ_EXPORT void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. CZMQ_EXPORT void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. CZMQ_EXPORT void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. CZMQ_EXPORT int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. CZMQ_EXPORT void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. CZMQ_EXPORT void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. CZMQ_EXPORT void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. CZMQ_EXPORT void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. CZMQ_EXPORT void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. CZMQ_EXPORT void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. CZMQ_EXPORT zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. CZMQ_EXPORT void zlistx_set_destructor (zlistx_t *self, czmq_destructor destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. CZMQ_EXPORT void zlistx_set_duplicator (zlistx_t *self, czmq_duplicator duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. CZMQ_EXPORT void zlistx_set_comparator (zlistx_t *self, czmq_comparator comparator); // Runs selftest of class CZMQ_EXPORT void zlistx_test (int verbose); ---- DESCRIPTION ----------- Provides a generic doubly-linked list container. This container provides hooks for duplicator, comparator, and destructor functions. These tie into CZMQ and standard C semantics, so e.g. for string items you can use strdup, strcmp, and zstr_free. To store custom objects, define your own duplicator and comparator, and use the standard object destructor. This is a reworking of the simpler zlist container. It is faster to insert and delete items anywhere in the list, and to keep ordered lists. EXAMPLE ------- .From zlistx_test method ---- zlistx_t *list = zlistx_new (); assert (list); assert (zlistx_size (list) == 0); // Test operations on an empty list assert (zlistx_first (list) == NULL); assert (zlistx_last (list) == NULL); assert (zlistx_next (list) == NULL); assert (zlistx_prev (list) == NULL); assert (zlistx_find (list, "hello") == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); zlistx_purge (list); zlistx_sort (list); // Use item handlers zlistx_set_destructor (list, (czmq_destructor *) zstr_free); zlistx_set_duplicator (list, (czmq_duplicator *) strdup); zlistx_set_comparator (list, (czmq_comparator *) strcmp); // Try simple insert/sort/delete/next assert (zlistx_next (list) == NULL); zlistx_add_end (list, "world"); assert (streq ((char *) zlistx_next (list), "world")); zlistx_add_end (list, "hello"); assert (streq ((char *) zlistx_prev (list), "hello")); zlistx_sort (list); assert (zlistx_size (list) == 2); void *handle = zlistx_find (list, "hello"); char *item1 = (char *) zlistx_item (list); char *item2 = (char *) zlistx_handle_item (handle); assert (item1 == item2); assert (streq (item1, "hello")); zlistx_delete (list, handle); assert (zlistx_size (list) == 1); char *string = (char *) zlistx_detach (list, NULL); assert (streq (string, "world")); free (string); assert (zlistx_size (list) == 0); // Check next/back work // Now populate the list with items zlistx_add_start (list, "five"); zlistx_add_end (list, "six"); zlistx_add_start (list, "four"); zlistx_add_end (list, "seven"); zlistx_add_start (list, "three"); zlistx_add_end (list, "eight"); zlistx_add_start (list, "two"); zlistx_add_end (list, "nine"); zlistx_add_start (list, "one"); zlistx_add_end (list, "ten"); // Test our navigation skills assert (zlistx_size (list) == 10); assert (streq ((char *) zlistx_last (list), "ten")); assert (streq ((char *) zlistx_prev (list), "nine")); assert (streq ((char *) zlistx_prev (list), "eight")); assert (streq ((char *) zlistx_prev (list), "seven")); assert (streq ((char *) zlistx_prev (list), "six")); assert (streq ((char *) zlistx_prev (list), "five")); assert (streq ((char *) zlistx_first (list), "one")); assert (streq ((char *) zlistx_next (list), "two")); assert (streq ((char *) zlistx_next (list), "three")); assert (streq ((char *) zlistx_next (list), "four")); // Sort by alphabetical order zlistx_sort (list); assert (streq ((char *) zlistx_first (list), "eight")); assert (streq ((char *) zlistx_last (list), "two")); // Moving items around handle = zlistx_find (list, "six"); zlistx_move_start (list, handle); assert (streq ((char *) zlistx_first (list), "six")); zlistx_move_end (list, handle); assert (streq ((char *) zlistx_last (list), "six")); zlistx_sort (list); assert (streq ((char *) zlistx_last (list), "two")); // Copying a list zlistx_t *copy = zlistx_dup (list); assert (copy); assert (zlistx_size (copy) == 10); assert (streq ((char *) zlistx_first (copy), "eight")); assert (streq ((char *) zlistx_last (copy), "two")); zlistx_destroy (©); // Delete items while iterating string = (char *) zlistx_first (list); assert (streq (string, "eight")); string = (char *) zlistx_next (list); assert (streq (string, "five")); zlistx_delete (list, zlistx_cursor (list)); string = (char *) zlistx_next (list); assert (streq (string, "four")); zlistx_purge (list); zlistx_destroy (&list); ---- czmq-3.0.2/doc/zbeacon_v2.txt0000664000175000017500000001302212533132136015123 0ustar00phph00000000000000zbeacon_v2(3) ============= NAME ---- zbeacon_v2 - LAN discovery and presence (deprecated) SYNOPSIS -------- ---- // Create a new beacon on a certain UDP port. If the system does not // support UDP broadcasts (lacking a useful interface), returns NULL. // To force the beacon to operate on a given port, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() beforehand. // If you are using the new zsock API then pass NULL as the ctx here. CZMQ_EXPORT zbeacon_t * zbeacon_new (zctx_t *ctx, int port_nbr); // Destroy a beacon CZMQ_EXPORT void zbeacon_destroy (zbeacon_t **self_p); // Return our own IP address as printable string CZMQ_EXPORT char * zbeacon_hostname (zbeacon_t *self); // Set broadcast interval in milliseconds (default is 1000 msec) CZMQ_EXPORT void zbeacon_set_interval (zbeacon_t *self, int interval); // Filter out any beacon that looks exactly like ours CZMQ_EXPORT void zbeacon_noecho (zbeacon_t *self); // Start broadcasting beacon to peers at the specified interval CZMQ_EXPORT void zbeacon_publish (zbeacon_t *self, byte *transmit, size_t size); // Stop broadcasting beacons CZMQ_EXPORT void zbeacon_silence (zbeacon_t *self); // Start listening to other peers; zero-sized filter means get everything CZMQ_EXPORT void zbeacon_subscribe (zbeacon_t *self, byte *filter, size_t size); // Stop listening to other peers CZMQ_EXPORT void zbeacon_unsubscribe (zbeacon_t *self); // Get beacon ZeroMQ socket, for polling or receiving messages CZMQ_EXPORT void * zbeacon_socket (zbeacon_t *self); // Self test of this class CZMQ_EXPORT void zbeacon_v2_test (bool verbose); ---- DESCRIPTION ----------- The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. The zbeacon API provides a incoming beacons on a ZeroMQ socket (the pipe) that you can configure, poll on, and receive messages on. Incoming beacons are always delivered as two frames: the ipaddress of the sender (a string), and the beacon data itself (binary, as published). This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets. EXAMPLE ------- .From zbeacon_v2_test method ---- // Create beacon to broadcast our service zctx_t *ctx = zctx_new (); assert (ctx); zbeacon_t *service_beacon = zbeacon_new (ctx, 9999); if (service_beacon == NULL) { printf ("OK (skipping test, no UDP discovery)\n"); return; } // Create a service socket and bind to an ephemeral port zsock_t *service = zsock_new (ZMQ_PUB); assert (service); int port_nbr = zsock_bind (service, "tcp://127.0.0.1:*"); byte announcement [2] = { (port_nbr >> 8) & 0xFF, port_nbr & 0xFF }; zbeacon_set_interval (service_beacon, 100); zbeacon_publish (service_beacon, announcement, 2); // Create beacon to lookup service zbeacon_t *client_beacon = zbeacon_new (ctx, 9999); assert (client_beacon); zbeacon_subscribe (client_beacon, NULL, 0); // Wait for at most 1/2 second if there's no broadcast networking zsocket_set_rcvtimeo (zbeacon_socket (client_beacon), 500); char *ipaddress = zstr_recv (zbeacon_socket (client_beacon)); if (ipaddress) { zframe_t *content = zframe_recv (zbeacon_socket (client_beacon)); int received_port = (zframe_data (content) [0] << 8) + zframe_data (content) [1]; assert (received_port == port_nbr); zframe_destroy (&content); zbeacon_silence (service_beacon); zstr_free (&ipaddress); } zbeacon_destroy (&client_beacon); zbeacon_destroy (&service_beacon); zbeacon_t *node1 = zbeacon_new (ctx, 5670); assert (node1); zbeacon_t *node2 = zbeacon_new (ctx, 5670); assert (node2); zbeacon_t *node3 = zbeacon_new (ctx, 5670); assert (node3); assert (*zbeacon_hostname (node1)); assert (*zbeacon_hostname (node2)); assert (*zbeacon_hostname (node3)); zbeacon_set_interval (node1, 250); zbeacon_set_interval (node2, 250); zbeacon_set_interval (node3, 250); zbeacon_noecho (node1); zbeacon_publish (node1, (byte *) "NODE/1", 6); zbeacon_publish (node2, (byte *) "NODE/2", 6); zbeacon_publish (node3, (byte *) "GARBAGE", 7); zbeacon_subscribe (node1, (byte *) "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new ( zbeacon_socket (node1), zbeacon_socket (node2), zbeacon_socket (node3), NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == zbeacon_socket (node1)); char *ipaddress, *beacon; zstr_recvx (zbeacon_socket (node1), &ipaddress, &beacon, NULL); assert (streq (beacon, "NODE/2")); zstr_free (&ipaddress); zstr_free (&beacon); } } zpoller_destroy (&poller); // Stop listening zbeacon_unsubscribe (node1); // Stop all node broadcasts zbeacon_silence (node1); zbeacon_silence (node2); zbeacon_silence (node3); // Destroy the test nodes zbeacon_destroy (&node1); zbeacon_destroy (&node2); zbeacon_destroy (&node3); zsock_destroy (&service); zctx_destroy (&ctx); ---- czmq-3.0.2/doc/zsockopt.30000664000175000017500000011022512533132200014265 0ustar00phph00000000000000'\" t .\" Title: zsockopt .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZSOCKOPT" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zsockopt \- get/set 0MQ socket options (deprecated) .SH "SYNOPSIS" .sp .nf #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsocket_tos (void *zocket); CZMQ_EXPORT char * zsocket_zap_domain (void *zocket); CZMQ_EXPORT int zsocket_mechanism (void *zocket); CZMQ_EXPORT int zsocket_plain_server (void *zocket); CZMQ_EXPORT char * zsocket_plain_username (void *zocket); CZMQ_EXPORT char * zsocket_plain_password (void *zocket); CZMQ_EXPORT int zsocket_curve_server (void *zocket); CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket); CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket); CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket); CZMQ_EXPORT int zsocket_gssapi_server (void *zocket); CZMQ_EXPORT int zsocket_gssapi_plaintext (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_principal (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_service_principal (void *zocket); CZMQ_EXPORT int zsocket_ipv6 (void *zocket); CZMQ_EXPORT int zsocket_immediate (void *zocket); CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_tos (void *zocket, int tos); CZMQ_EXPORT void zsocket_set_router_handover (void *zocket, int router_handover); CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory); CZMQ_EXPORT void zsocket_set_probe_router (void *zocket, int probe_router); CZMQ_EXPORT void zsocket_set_req_relaxed (void *zocket, int req_relaxed); CZMQ_EXPORT void zsocket_set_req_correlate (void *zocket, int req_correlate); CZMQ_EXPORT void zsocket_set_conflate (void *zocket, int conflate); CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain); CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server); CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username); CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password); CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server); CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey); CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey); CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey); CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey); CZMQ_EXPORT void zsocket_set_gssapi_server (void *zocket, int gssapi_server); CZMQ_EXPORT void zsocket_set_gssapi_plaintext (void *zocket, int gssapi_plaintext); CZMQ_EXPORT void zsocket_set_gssapi_principal (void *zocket, const char * gssapi_principal); CZMQ_EXPORT void zsocket_set_gssapi_service_principal (void *zocket, const char * gssapi_service_principal); CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6); CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate); CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsocket_hwm (void *zocket); CZMQ_EXPORT int zsocket_swap (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *zocket); CZMQ_EXPORT int zsocket_mcast_loop (void *zocket); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); # endif CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); CZMQ_EXPORT void zsocket_set_swap (void *zocket, int swap); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec); CZMQ_EXPORT void zsocket_set_mcast_loop (void *zocket, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); # endif CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsockopt_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zsockopt class provides access to the 0MQ getsockopt/setsockopt API\&. .sp This class is generated, using the GSL code generator\&. See the sockopts XML file, which provides the metadata, and the zsockopt\&.gsl template, which does the work\&. .SH "EXAMPLE" .PP \fBFrom zsockopt_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zctx_t *ctx = zctx_new (); assert (ctx); void *zocket; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_tos (zocket, 1); assert (zsocket_tos (zocket) == 1); zsocket_tos (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_HANDOVER) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_handover (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_MANDATORY) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_mandatory (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PROBE_ROUTER) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_probe_router (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_RELAXED) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_relaxed (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_CORRELATE) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_correlate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_CONFLATE) zocket = zsocket_new (ctx, ZMQ_PUSH); assert (zocket); zsocket_set_conflate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ZAP_DOMAIN) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_zap_domain (zocket, "test"); char *zap_domain = zsocket_zap_domain (zocket); assert (zap_domain); free (zap_domain); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MECHANISM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_mechanism (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_SERVER) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_plain_server (zocket, 1); assert (zsocket_plain_server (zocket) == 1); zsocket_plain_server (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_USERNAME) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_username (zocket, "test"); char *plain_username = zsocket_plain_username (zocket); assert (plain_username); free (plain_username); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_PASSWORD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_password (zocket, "test"); char *plain_password = zsocket_plain_password (zocket); assert (plain_password); free (plain_password); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV6) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv6 (zocket, 1); assert (zsocket_ipv6 (zocket) == 1); zsocket_ipv6 (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IMMEDIATE) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_immediate (zocket, 1); assert (zsocket_immediate (zocket) == 1); zsocket_immediate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127\&.0\&.0\&.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127\&.0\&.0\&.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_hwm (zocket, 1); assert (zsocket_hwm (zocket) == 1); zsocket_hwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SWAP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_swap (zocket, 1); assert (zsocket_swap (zocket) == 1); zsocket_swap (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl_msec (zocket, 1); assert (zsocket_recovery_ivl_msec (zocket) == 1); zsocket_recovery_ivl_msec (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MCAST_LOOP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_mcast_loop (zocket, 1); assert (zsocket_mcast_loop (zocket) == 1); zsocket_mcast_loop (zocket); zsocket_destroy (ctx, zocket); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif #endif zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zproxy.30000664000175000017500000001516012533132165014000 0ustar00phph00000000000000'\" t .\" Title: zproxy .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZPROXY" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zproxy \- run a steerable proxy in the background .SH "SYNOPSIS" .sp .nf // Create new zproxy actor instance\&. The proxy switches messages between // a frontend socket and a backend socket; use the FRONTEND and BACKEND // commands to configure these: // // zactor_t *proxy = zactor_new (zproxy, NULL); // // Destroy zproxy instance\&. This destroys the two sockets and stops any // message flow between them: // // zactor_destroy (&proxy); // // Note that all zproxy commands are synchronous, so your application always // waits for a signal from the actor after each command\&. // // Enable verbose logging of commands and activity: // // zstr_send (proxy, "VERBOSE"); // zsock_wait (proxy); // // Specify frontend socket type \-\- see zsock_type_str () \-\- and attach to // endpoints, see zsock_attach ()\&. Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); // zsock_wait (proxy); // // Specify backend socket type \-\- see zsock_type_str () \-\- and attach to // endpoints, see zsock_attach ()\&. Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); // zsock_wait (proxy); // // Capture all proxied messages; these are delivered to the application // via an inproc PULL socket that you have already bound to the specified // endpoint: // // zstr_sendx (proxy, "CAPTURE", endpoint, NULL); // zsock_wait (proxy); // // Pause the proxy\&. A paused proxy will cease processing messages, causing // them to be queued up and potentially hit the high\-water mark on the // frontend or backend socket, causing messages to be dropped, or writing // applications to block: // // zstr_sendx (proxy, "PAUSE", NULL); // zsock_wait (proxy); // // Resume the proxy\&. Note that the proxy starts automatically as soon as it // has a properly attached frontend and backend socket: // // zstr_sendx (proxy, "RESUME", NULL); // zsock_wait (proxy); // // This is the zproxy constructor as a zactor_fn; the argument is a // character string specifying frontend and backend socket types as two // uppercase strings separated by a hyphen: CZMQ_EXPORT void zproxy (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zproxy_test (bool verbose); .fi .SH "DESCRIPTION" .sp A zproxy actor switches messages between a frontend and a backend socket\&. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ\(cqs facilities, to be somewhat simpler to set\-up\&. .sp This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&. .SH "EXAMPLE" .PP \fBFrom zproxy_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create and configure our proxy zactor_t *proxy = zactor_new (zproxy, NULL); assert (proxy); if (verbose) { zstr_sendx (proxy, "VERBOSE", NULL); zsock_wait (proxy); } zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL); zsock_wait (proxy); // Connect application sockets to proxy zsock_t *faucet = zsock_new_push (">inproc://frontend"); assert (faucet); zsock_t *sink = zsock_new_pull (">inproc://backend"); assert (sink); // Send some messages and check they arrived char *hello, *world; zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test pause/resume functionality zstr_sendx (proxy, "PAUSE", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zsock_set_rcvtimeo (sink, 100); zstr_recvx (sink, &hello, &world, NULL); assert (!hello && !world); zstr_sendx (proxy, "RESUME", NULL); zsock_wait (proxy); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test capture functionality zsock_t *capture = zsock_new_pull ("inproc://capture"); assert (capture); // Switch on capturing, check that it works zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zstr_recvx (capture, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zsock_destroy (&faucet); zsock_destroy (&sink); zsock_destroy (&capture); zactor_destroy (&proxy); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zloop.txt0000664000175000017500000002001512533132136014236 0ustar00phph00000000000000zloop(3) ======== NAME ---- zloop - event-driven reactor SYNOPSIS -------- ---- // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Create a new zloop reactor CZMQ_EXPORT zloop_t * zloop_new (); // Destroy a reactor CZMQ_EXPORT void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. CZMQ_EXPORT int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. CZMQ_EXPORT void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. CZMQ_EXPORT int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. CZMQ_EXPORT void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. CZMQ_EXPORT int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). CZMQ_EXPORT int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. CZMQ_EXPORT void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. CZMQ_EXPORT void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. CZMQ_EXPORT void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. CZMQ_EXPORT void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. CZMQ_EXPORT void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off CZMQ_EXPORT void zloop_set_verbose (zloop_t *self, bool verbose); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if cancelled by a handler. CZMQ_EXPORT int zloop_start (zloop_t *self); // Ignore zsys_interrupted flag in this loop. By default, a zloop_start will // exit as soon as it detects zsys_interrupted is set to something other than // zero. Calling zloop_ignore_interrupts will supress this behavior. CZMQ_EXPORT void zloop_ignore_interrupts (zloop_t *self); // Self test of this class CZMQ_EXPORT void zloop_test (bool verbose); ---- DESCRIPTION ----------- The zloop class provides an event-driven reactor pattern. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once-off or repeated timers. Its resolution is 1 msec. It uses a tickless timer to reduce CPU interrupts in inactive processes. Please add @discuss section in ../src/zloop.c. EXAMPLE ------- .From zloop_test method ---- // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); zsock_bind (output, "inproc://zloop.test"); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); zsock_connect (input, "inproc://zloop.test"); zloop_t *loop = zloop_new (); assert (loop); zloop_set_verbose (loop, verbose); // Create a timer that will be cancelled int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL); zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id); // After 20 msecs, send a ping message to output3 zloop_timer (loop, 20, 1, s_timer_event, output); // Set up some tickets that will never expire zloop_set_ticket_delay (loop, 10000); void *ticket1 = zloop_ticket (loop, s_timer_event, NULL); void *ticket2 = zloop_ticket (loop, s_timer_event, NULL); void *ticket3 = zloop_ticket (loop, s_timer_event, NULL); // When we get the ping message, end the reactor rc = zloop_reader (loop, input, s_socket_event, NULL); assert (rc == 0); zloop_reader_set_tolerant (loop, input); zloop_start (loop); zloop_ticket_delete (loop, ticket1); zloop_ticket_delete (loop, ticket2); zloop_ticket_delete (loop, ticket3); // Check whether loop properly ignores zsys_interrupted flag // when asked to zloop_destroy (&loop); loop = zloop_new (); bool timer_event_called = false; zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called); zsys_interrupted = 1; zloop_start (loop); // zloop returns immediately without giving any handler a chance to run assert (!timer_event_called); zloop_ignore_interrupts (loop); zloop_start (loop); // zloop runs the handler which will terminate the loop assert (timer_event_called); zsys_interrupted = 0; // cleanup zloop_destroy (&loop); assert (loop == NULL); zsock_destroy (&input); zsock_destroy (&output); ---- czmq-3.0.2/doc/zlistx.30000664000175000017500000003054312533132163013762 0ustar00phph00000000000000'\" t .\" Title: zlistx .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZLISTX" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zlistx \- extended generic list container .SH "SYNOPSIS" .sp .nf // Create a new, empty list\&. CZMQ_EXPORT zlistx_t * zlistx_new (void); // Destroy a list\&. If an item destructor was specified, all items in the // list are automatically destroyed as well\&. CZMQ_EXPORT void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list\&. Calls the item duplicator, if any, // on the item\&. Resets cursor to list head\&. Returns an item handle on // success, NULL if memory was exhausted\&. CZMQ_EXPORT void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list\&. Calls the item duplicator, if any, // on the item\&. Resets cursor to list head\&. Returns an item handle on // success, NULL if memory was exhausted\&. CZMQ_EXPORT void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list CZMQ_EXPORT size_t zlistx_size (zlistx_t *self); // Return the item at the head of list\&. If the list is empty, returns NULL\&. // Leaves cursor pointing at the head item, or NULL if the list is empty\&. CZMQ_EXPORT void * zlistx_first (zlistx_t *self); // Return the next item\&. At the end of the list (or in an empty list), // returns NULL\&. Use repeated zlistx_next () calls to work through the list // from zlistx_first ()\&. First time, acts as zlistx_first()\&. CZMQ_EXPORT void * zlistx_next (zlistx_t *self); // Return the previous item\&. At the start of the list (or in an empty list), // returns NULL\&. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last ()\&. First time, acts as zlistx_last()\&. CZMQ_EXPORT void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list\&. If the list is empty, returns NULL\&. // Leaves cursor pointing at the tail item, or NULL if the list is empty\&. CZMQ_EXPORT void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item\&. CZMQ_EXPORT void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item\&. CZMQ_EXPORT void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL\&. Asserts that the passed in handle points to a list element\&. CZMQ_EXPORT void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start\&. Uses the item // comparator, if any, else compares item values directly\&. Returns the // item handle found, or NULL\&. Sets the cursor to the found item, if any\&. CZMQ_EXPORT void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle\&. The item is not modified, // and the caller is responsible for destroying it if necessary\&. If handle is // null, detaches the first item on the list\&. Returns item that was detached, // or null if none was\&. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list\&. CZMQ_EXPORT void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list\&. The item is not modified, // and the caller is responsible for destroying it as necessary\&. Returns item // that was detached, or null if none was\&. Moves cursor to previous item, so // you can detach items while iterating forwards through a list\&. CZMQ_EXPORT void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle\&. Calls the item destructor is any is // set\&. If handle is null, deletes the first item on the list\&. Returns 0 // if an item was deleted, \-1 if not\&. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list\&. CZMQ_EXPORT int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle\&. CZMQ_EXPORT void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle\&. CZMQ_EXPORT void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set\&. CZMQ_EXPORT void zlistx_purge (zlistx_t *self); // Sort the list\&. If an item comparator was set, calls that to compare // items, otherwise compares on item value\&. The sort is not stable, so may // reorder equal items\&. CZMQ_EXPORT void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list\&. Calls the item // duplicator, if any, on the item\&. If low_value is true, starts searching // from the start of the list, otherwise searches from the end\&. Use the item // comparator, if any, to find where to place the new node\&. Returns a handle // to the new node, or NULL if memory was exhausted\&. Resets the cursor to the // list head\&. CZMQ_EXPORT void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list\&. Uses // the item comparator, if any, to determine the new location\&. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end\&. CZMQ_EXPORT void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not\&. Copying a null reference returns a null // reference\&. CZMQ_EXPORT zlistx_t * zlistx_dup (zlistx_t *self); // Set a user\-defined deallocator for list items; by default items are not // freed when the list is destroyed\&. CZMQ_EXPORT void zlistx_set_destructor (zlistx_t *self, czmq_destructor destructor); // Set a user\-defined duplicator for list items; by default items are not // copied when the list is duplicated\&. CZMQ_EXPORT void zlistx_set_duplicator (zlistx_t *self, czmq_duplicator duplicator); // Set a user\-defined comparator for zlistx_find and zlistx_sort; the method // must return \-1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2\&. CZMQ_EXPORT void zlistx_set_comparator (zlistx_t *self, czmq_comparator comparator); // Runs selftest of class CZMQ_EXPORT void zlistx_test (int verbose); .fi .SH "DESCRIPTION" .sp Provides a generic doubly\-linked list container\&. This container provides hooks for duplicator, comparator, and destructor functions\&. These tie into CZMQ and standard C semantics, so e\&.g\&. for string items you can use strdup, strcmp, and zstr_free\&. To store custom objects, define your own duplicator and comparator, and use the standard object destructor\&. .sp This is a reworking of the simpler zlist container\&. It is faster to insert and delete items anywhere in the list, and to keep ordered lists\&. .SH "EXAMPLE" .PP \fBFrom zlistx_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zlistx_t *list = zlistx_new (); assert (list); assert (zlistx_size (list) == 0); // Test operations on an empty list assert (zlistx_first (list) == NULL); assert (zlistx_last (list) == NULL); assert (zlistx_next (list) == NULL); assert (zlistx_prev (list) == NULL); assert (zlistx_find (list, "hello") == NULL); assert (zlistx_delete (list, NULL) == \-1); assert (zlistx_detach (list, NULL) == NULL); assert (zlistx_delete (list, NULL) == \-1); assert (zlistx_detach (list, NULL) == NULL); zlistx_purge (list); zlistx_sort (list); // Use item handlers zlistx_set_destructor (list, (czmq_destructor *) zstr_free); zlistx_set_duplicator (list, (czmq_duplicator *) strdup); zlistx_set_comparator (list, (czmq_comparator *) strcmp); // Try simple insert/sort/delete/next assert (zlistx_next (list) == NULL); zlistx_add_end (list, "world"); assert (streq ((char *) zlistx_next (list), "world")); zlistx_add_end (list, "hello"); assert (streq ((char *) zlistx_prev (list), "hello")); zlistx_sort (list); assert (zlistx_size (list) == 2); void *handle = zlistx_find (list, "hello"); char *item1 = (char *) zlistx_item (list); char *item2 = (char *) zlistx_handle_item (handle); assert (item1 == item2); assert (streq (item1, "hello")); zlistx_delete (list, handle); assert (zlistx_size (list) == 1); char *string = (char *) zlistx_detach (list, NULL); assert (streq (string, "world")); free (string); assert (zlistx_size (list) == 0); // Check next/back work // Now populate the list with items zlistx_add_start (list, "five"); zlistx_add_end (list, "six"); zlistx_add_start (list, "four"); zlistx_add_end (list, "seven"); zlistx_add_start (list, "three"); zlistx_add_end (list, "eight"); zlistx_add_start (list, "two"); zlistx_add_end (list, "nine"); zlistx_add_start (list, "one"); zlistx_add_end (list, "ten"); // Test our navigation skills assert (zlistx_size (list) == 10); assert (streq ((char *) zlistx_last (list), "ten")); assert (streq ((char *) zlistx_prev (list), "nine")); assert (streq ((char *) zlistx_prev (list), "eight")); assert (streq ((char *) zlistx_prev (list), "seven")); assert (streq ((char *) zlistx_prev (list), "six")); assert (streq ((char *) zlistx_prev (list), "five")); assert (streq ((char *) zlistx_first (list), "one")); assert (streq ((char *) zlistx_next (list), "two")); assert (streq ((char *) zlistx_next (list), "three")); assert (streq ((char *) zlistx_next (list), "four")); // Sort by alphabetical order zlistx_sort (list); assert (streq ((char *) zlistx_first (list), "eight")); assert (streq ((char *) zlistx_last (list), "two")); // Moving items around handle = zlistx_find (list, "six"); zlistx_move_start (list, handle); assert (streq ((char *) zlistx_first (list), "six")); zlistx_move_end (list, handle); assert (streq ((char *) zlistx_last (list), "six")); zlistx_sort (list); assert (streq ((char *) zlistx_last (list), "two")); // Copying a list zlistx_t *copy = zlistx_dup (list); assert (copy); assert (zlistx_size (copy) == 10); assert (streq ((char *) zlistx_first (copy), "eight")); assert (streq ((char *) zlistx_last (copy), "two")); zlistx_destroy (©); // Delete items while iterating string = (char *) zlistx_first (list); assert (streq (string, "eight")); string = (char *) zlistx_next (list); assert (streq (string, "five")); zlistx_delete (list, zlistx_cursor (list)); string = (char *) zlistx_next (list); assert (streq (string, "four")); zlistx_purge (list); zlistx_destroy (&list); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zmonitor_v2.30000664000175000017500000001135112533132176014715 0ustar00phph00000000000000'\" t .\" Title: zmonitor_v2 .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZMONITOR_V2" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zmonitor_v2 \- socket event monitor (deprecated) .SH "SYNOPSIS" .sp .nf // This code needs backporting to work with ZMQ v3\&.2 #if (ZMQ_VERSION_MAJOR == 4) // Create a new socket monitor CZMQ_EXPORT zmonitor_t * zmonitor_new (zctx_t *ctx, void *socket, int events); // Destroy a socket monitor CZMQ_EXPORT void zmonitor_destroy (zmonitor_t **self_p); // Receive a status message from the monitor; if no message arrives within // 500 msec, or the call was interrupted, returns NULL\&. CZMQ_EXPORT zmsg_t * zmonitor_recv (zmonitor_t *self); // Get the ZeroMQ socket, for polling CZMQ_EXPORT void * zmonitor_socket (zmonitor_t *self); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zmonitor_set_verbose (zmonitor_t *self, bool verbose); #endif // ZeroMQ 4\&.0 or later // Self test of this class CZMQ_EXPORT void zmonitor_v2_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zmonitor class provides an API for obtaining socket events such as connected, listen, disconnected, etc\&. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints\&. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details\&. Currently this class requires libzmq v4\&.0 or later and is empty on older versions of libzmq\&. .sp This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes\&. New applications should use the V3 zmonitor interface, based on zactor, together with the zsock class for sockets\&. .SH "EXAMPLE" .PP \fBFrom zmonitor_v2_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zctx_t *ctx = zctx_new (); assert (ctx); bool result; void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); zmonitor_t *sinkmon = zmonitor_new (ctx, sink, ZMQ_EVENT_LISTENING | ZMQ_EVENT_ACCEPTED); assert (sinkmon); zmonitor_set_verbose (sinkmon, verbose); // Check sink is now listening int port_nbr = zsocket_bind (sink, "tcp://127\&.0\&.0\&.1:*"); assert (port_nbr != \-1); result = s_check_event (sinkmon, ZMQ_EVENT_LISTENING); assert (result); void *source = zsocket_new (ctx, ZMQ_PUSH); assert (source); zmonitor_t *sourcemon = zmonitor_new (ctx, source, ZMQ_EVENT_CONNECTED | ZMQ_EVENT_DISCONNECTED); assert (sourcemon); zmonitor_set_verbose (sourcemon, verbose); zsocket_connect (source, "tcp://127\&.0\&.0\&.1:%d", port_nbr); // Check source connected to sink result = s_check_event (sourcemon, ZMQ_EVENT_CONNECTED); assert (result); // Check sink accepted connection result = s_check_event (sinkmon, ZMQ_EVENT_ACCEPTED); assert (result); zmonitor_destroy (&sinkmon); zmonitor_destroy (&sourcemon); zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zarmour.txt0000664000175000017500000002624412533132136014604 0ustar00phph00000000000000zarmour(3) ========== NAME ---- zarmour - armoured text encoding and decoding SYNOPSIS -------- ---- // Enumeration defining different encoding modes typedef enum { ZARMOUR_MODE_BASE64_STD // Standard base 64 , ZARMOUR_MODE_BASE64_URL // URL and filename friendly base 64 , ZARMOUR_MODE_BASE32_STD // Standard base 32 , ZARMOUR_MODE_BASE32_HEX // Extended hex base 32 , ZARMOUR_MODE_BASE16 // Standard base 16 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 3, 0)) , ZARMOUR_MODE_Z85 // Z85 from ZeroMQ RFC 32 #endif } zarmour_mode_t; // Create a new zarmour CZMQ_EXPORT zarmour_t * zarmour_new (); // Destroy the zarmour CZMQ_EXPORT void zarmour_destroy (zarmour_t **self_p); // Print properties of object CZMQ_EXPORT void zarmour_print (zarmour_t *self); // Get printable string for mode CZMQ_EXPORT const char * zarmour_mode_str (zarmour_t *self); // Encode a stream of bytes into an armoured string. CZMQ_EXPORT char * zarmour_encode (zarmour_t *self, const byte *data, size_t data_size); // Decode an armoured string into a string of bytes. // The decoded output is null-terminated, so it may be treated // as a string, if that's what it was prior to encoding. CZMQ_EXPORT byte * zarmour_decode (zarmour_t *self, const char *data, size_t *decode_size); // Get/set the mode property CZMQ_EXPORT zarmour_mode_t zarmour_mode (zarmour_t *self); CZMQ_EXPORT void zarmour_set_mode (zarmour_t *self, zarmour_mode_t mode); // Get/set the pad property CZMQ_EXPORT bool zarmour_pad (zarmour_t *self); CZMQ_EXPORT void zarmour_set_pad (zarmour_t *self, bool pad); // Get/set the pad_char property CZMQ_EXPORT char zarmour_pad_char (zarmour_t *self); CZMQ_EXPORT void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Get/set the line_breaks property CZMQ_EXPORT bool zarmour_line_breaks (zarmour_t *self); CZMQ_EXPORT void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get/set the line_length property CZMQ_EXPORT size_t zarmour_line_length (zarmour_t *self); CZMQ_EXPORT void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Self test of this class CZMQ_EXPORT int zarmour_test (bool verbose); ---- DESCRIPTION ----------- zarmour - armoured text encoding and decoding The zarmour class implements encoding and decoding of armoured text data. The following codecs are implemented: * RFC 4648 (http://www.ietf.org/rfc/rfc4648.txt) - base64 - base64url - base32 - base32hex - base16 * Z85 (http://rfc.zeromq.org/spec:32) All RFC4648 base64 and base32 variants support padding the output. The pad character is configurable. Default is padding on, with character '='. Additionally, in some cases (e.g. MIME), splitting the output into lines of a specific length is required. This feature is also supported, though turned off by default. The z85 mode does neither padding nor line breaks; it is merely a wrapping of the corresponding libzmq methods. Encoding will assert if input length is not divisible by 4 and decoding will assert if input length is not divisible by 5. EXAMPLE ------- .From zarmour_test method ---- zarmour_t *self = zarmour_new (); assert (self); zarmour_mode_t mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_STD); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_URL); assert (zarmour_pad (self)); zarmour_set_pad (self, false); assert (!zarmour_pad (self)); assert (zarmour_pad_char (self) == '='); zarmour_set_pad_char (self, '!'); assert (zarmour_pad_char (self) == '!'); zarmour_set_pad_char (self, '='); assert (zarmour_pad_char (self) == '='); assert (!zarmour_line_breaks (self)); zarmour_set_line_breaks (self, true); assert (zarmour_line_breaks (self)); assert (zarmour_line_length (self) == 72); zarmour_set_line_length (self, 64); assert (zarmour_line_length (self) == 64); // Test against test vectors from RFC4648. zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY", verbose); s_armour_test (self, "fo", "MZXQ", verbose); s_armour_test (self, "foo", "MZXW6", verbose); s_armour_test (self, "foob", "MZXW6YQ", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI", verbose); s_armour_decode (self, "my", "f", verbose); s_armour_decode (self, "mzxq", "fo", verbose); s_armour_decode (self, "mzxw6", "foo", verbose); s_armour_decode (self, "mzxw6yq", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY======", verbose); s_armour_test (self, "fo", "MZXQ====", verbose); s_armour_test (self, "foo", "MZXW6===", verbose); s_armour_test (self, "foob", "MZXW6YQ=", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI======", verbose); s_armour_decode (self, "my======", "f", verbose); s_armour_decode (self, "mzxq====", "fo", verbose); s_armour_decode (self, "mzxw6===", "foo", verbose); s_armour_decode (self, "mzxw6yq=", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi======", "foobar", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO", verbose); s_armour_test (self, "fo", "CPNG", verbose); s_armour_test (self, "foo", "CPNMU", verbose); s_armour_test (self, "foob", "CPNMUOG", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8", verbose); s_armour_decode (self, "co", "f", verbose); s_armour_decode (self, "cpng", "fo", verbose); s_armour_decode (self, "cpnmu", "foo", verbose); s_armour_decode (self, "cpnmuog", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO======", verbose); s_armour_test (self, "fo", "CPNG====", verbose); s_armour_test (self, "foo", "CPNMU===", verbose); s_armour_test (self, "foob", "CPNMUOG=", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8======", verbose); s_armour_decode (self, "co======", "f", verbose); s_armour_decode (self, "cpng====", "fo", verbose); s_armour_decode (self, "cpnmu===", "foo", verbose); s_armour_decode (self, "cpnmuog=", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8======", "foobar", verbose); zarmour_set_pad (self, true); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "66", verbose); s_armour_test (self, "fo", "666F", verbose); s_armour_test (self, "foo", "666F6F", verbose); s_armour_test (self, "foob", "666F6F62", verbose); s_armour_test (self, "fooba", "666F6F6261", verbose); s_armour_test (self, "foobar", "666F6F626172", verbose); s_armour_decode (self, "666f", "fo", verbose); s_armour_decode (self, "666f6f", "foo", verbose); s_armour_decode (self, "666f6f62", "foob", verbose); s_armour_decode (self, "666f6f6261", "fooba", verbose); s_armour_decode (self, "666f6f626172", "foobar", verbose); #ifdef _INCLUDE_Z85 // Z85 test is homemade; using 0, 4 and 8 bytes, with precalculated // test vectors created with a libzmq test. // ---------------------------------------------------------------- // Make a fake curve key from hex (base16) string, making sure // there are no null bytes inside, so we can use our test utility zarmour_set_mode (self, ZARMOUR_MODE_BASE16); zarmour_set_line_breaks (self, false); size_t key_len; byte *key_data = zarmour_decode (self, "4E6F87E2FB6EB22A1EF5E257B75D79124949565F0B8B36A878A4F03111C96E0B", &key_len); zarmour_set_mode (self, ZARMOUR_MODE_Z85); // Z85 mode does not support padding or line breaks zarmour_set_pad (self, false); // so these two are superfluous; zarmour_set_line_breaks (self, false); // just for consistency if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "foob", "w]zP%", verbose); s_armour_test (self, "foobar!!", "w]zP%vr9Im", verbose); s_armour_test (self, (char *) key_data, "ph+{E}!&X?9}!I]W{sm(nL8@&3Yu{wC+<*-5Y[[#", verbose); free (key_data); #endif // Armouring longer byte array to test line breaks zarmour_set_pad (self, true); zarmour_set_line_breaks (self, true); byte test_data[256]; int i; for (i = 0; i < 256; ++i) { test_data[i] = i; } zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); s_armour_test_long (self, test_data, 256, verbose); #ifdef _INCLUDE_Z85 zarmour_set_mode (self, ZARMOUR_MODE_Z85); s_armour_test_long (self, test_data, 256, verbose); #endif zarmour_destroy (&self); ---- czmq-3.0.2/doc/makecert.10000664000175000017500000000465112533132151014214 0ustar00phph00000000000000'\" t .\" Title: makecert .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "MAKECERT" "1" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" makecert \- no title found .SH "SYNOPSIS" .sp .nf Please add @interface section in \&.\&./src/makecert\&.c\&. .fi .SH "DESCRIPTION" .sp Please add @header section in \&.\&./src/makecert\&.c\&. .sp Please add @discuss section in \&.\&./src/makecert\&.c\&. .SH "EXAMPLE" .PP \fBFrom makecert_test method\fR. .sp .if n \{\ .RS 4 .\} .nf Please add @selftest section in \&.\&./src/makecert\&.c\&. .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zctx.30000664000175000017500000001615712533132175013425 0ustar00phph00000000000000'\" t .\" Title: zctx .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZCTX" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zctx \- working with 0MQ contexts (deprecated) .SH "SYNOPSIS" .sp .nf // Create new context, returns context object, replaces zmq_init CZMQ_EXPORT zctx_t * zctx_new (void); // Destroy context and all sockets in it, replaces zmq_term CZMQ_EXPORT void zctx_destroy (zctx_t **self_p); // Create new shadow context, returns context object CZMQ_EXPORT zctx_t * zctx_shadow (zctx_t *self); // Raise default I/O threads from 1, for crazy heavy applications // The rule of thumb is one I/O thread per gigabyte of traffic in // or out\&. Call this method before creating any sockets on the context, // or calling zctx_shadow, or the setting will have no effect\&. CZMQ_EXPORT void zctx_set_iothreads (zctx_t *self, int iothreads); // Set msecs to flush sockets when closing them, see the ZMQ_LINGER // man page section for more details\&. By default, set to zero, so // any in\-transit messages are discarded when you destroy a socket or // a context\&. CZMQ_EXPORT void zctx_set_linger (zctx_t *self, int linger); // Set initial high\-water mark for inter\-thread pipe sockets\&. Note that // this setting is separate from the default for normal sockets\&. You // should change the default for pipe sockets *with care*\&. Too low values // will cause blocked threads, and an infinite setting can cause memory // exhaustion\&. The default, no matter the underlying ZeroMQ version, is // 1,000\&. CZMQ_EXPORT void zctx_set_pipehwm (zctx_t *self, int pipehwm); // Set initial send HWM for all new normal sockets created in context\&. // You can set this per\-socket after the socket is created\&. // The default, no matter the underlying ZeroMQ version, is 1,000\&. CZMQ_EXPORT void zctx_set_sndhwm (zctx_t *self, int sndhwm); // Set initial receive HWM for all new normal sockets created in context\&. // You can set this per\-socket after the socket is created\&. // The default, no matter the underlying ZeroMQ version, is 1,000\&. CZMQ_EXPORT void zctx_set_rcvhwm (zctx_t *self, int rcvhwm); // Return low\-level 0MQ context object, will be NULL before first socket // is created\&. Use with care\&. CZMQ_EXPORT void * zctx_underlying (zctx_t *self); // Self test of this class CZMQ_EXPORT void zctx_test (bool verbose); .fi .SH "DESCRIPTION" .sp 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 (interrupt) handling for the process\&. .sp The zctx class has these main features: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Tracks all open sockets and automatically closes them before calling zmq_term()\&. This avoids an infinite wait on open sockets\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Automatically configures sockets with a ZMQ_LINGER timeout you can define, and which defaults to zero\&. The default behavior of zctx is therefore like 0MQ/2\&.0, immediate termination with loss of any pending messages\&. You can set any linger timeout you like by calling the zctx_set_linger() method\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Moves the iothreads configuration to a separate method, so that default usage is 1 I/O thread\&. Lets you configure this value\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Sets up signal (SIGINT and SIGTERM) handling so that blocking calls such as zmq_recv() and zmq_poll() will return when the user presses Ctrl\-C\&. .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp this class is deprecated in favor of zsock, which does not expose contexts in the API at all\&. All zsock instances use the same global context\&. .sp .5v .RE .SH "EXAMPLE" .PP \fBFrom zctx_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create and destroy a context without using it zctx_t *ctx = zctx_new (); assert (ctx); zctx_destroy (&ctx); assert (ctx == NULL); // Create a context with many busy sockets, destroy it ctx = zctx_new (); assert (ctx); zctx_set_iothreads (ctx, 1); zctx_set_linger (ctx, 5); // 5 msecs void *s1 = zctx__socket_new (ctx, ZMQ_PAIR); assert (s1); void *s2 = zctx__socket_new (ctx, ZMQ_XREQ); assert (s2); void *s3 = zctx__socket_new (ctx, ZMQ_REQ); assert (s3); void *s4 = zctx__socket_new (ctx, ZMQ_REP); assert (s4); void *s5 = zctx__socket_new (ctx, ZMQ_PUB); assert (s5); void *s6 = zctx__socket_new (ctx, ZMQ_SUB); assert (s6); int rc = zsocket_connect (s1, "tcp://127\&.0\&.0\&.1:5555"); assert (rc == 0); rc = zsocket_connect (s2, "tcp://127\&.0\&.0\&.1:5555"); assert (rc == 0); rc = zsocket_connect (s3, "tcp://127\&.0\&.0\&.1:5555"); assert (rc == 0); rc = zsocket_connect (s4, "tcp://127\&.0\&.0\&.1:5555"); assert (rc == 0); rc = zsocket_connect (s5, "tcp://127\&.0\&.0\&.1:5555"); assert (rc == 0); rc = zsocket_connect (s6, "tcp://127\&.0\&.0\&.1:5555"); assert (rc == 0); assert (zctx_underlying (ctx)); zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zdir.30000664000175000017500000002213312533132156013373 0ustar00phph00000000000000'\" t .\" Title: zdir .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZDIR" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zdir \- work with file\-system directories .SH "SYNOPSIS" .sp .nf // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path\&. If parent is "\-", then // loads only the top\-level directory, and does not use parent as a path\&. CZMQ_EXPORT zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains\&. CZMQ_EXPORT void zdir_destroy (zdir_t **self_p); // Return directory path CZMQ_EXPORT const char * zdir_path (zdir_t *self); // Return last modification time for directory\&. CZMQ_EXPORT time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree\&. CZMQ_EXPORT off_t zdir_cursize (zdir_t *self); // Return directory count CZMQ_EXPORT size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree\&. Do not destroy the // original zdir tree until you are done with this list\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels\&. If force is false, will only remove the directory if empty\&. // If force is true, will remove all files and all subdirectories\&. CZMQ_EXPORT void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree\&. // Returns a list of zdir_patch_t patches\&. Either older or newer may // be null, indicating the directory is empty/absent\&. If alias is set, // generates virtual filename (minus path, plus alias)\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA\-1 digests // of every file in the tree\&. The cache is saved between runs in \&.cache\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream CZMQ_EXPORT void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout CZMQ_EXPORT void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data\&. // free (path); // zlist_destroy (&patches); CZMQ_EXPORT void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class\&. CZMQ_EXPORT void zdir_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zdir class gives access to the file system index\&. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure\&. It exists mainly to wrap non\-portable OS functions to do this\&. .sp Please add @discuss section in \&.\&./src/zdir\&.c\&. .SH "EXAMPLE" .PP \fBFrom zdir_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zdir_t *older = zdir_new ("\&.", NULL); assert (older); if (verbose) { printf ("\en"); zdir_dump (older, 0); } zdir_t *newer = zdir_new ("\&.\&.", NULL); assert (newer); zlist_t *patches = zdir_diff (older, newer, "/"); assert (patches); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); zdir_patch_destroy (&patch); } zlist_destroy (&patches); zdir_destroy (&older); zdir_destroy (&newer); zdir_t *nosuch = zdir_new ("does\-not\-exist", NULL); assert (nosuch == NULL); // zdir_watch test: zactor_t *watch = zactor_new (zdir_watch, NULL); assert (watch); if (verbose) { zsock_send (watch, "s", "VERBOSE"); assert (zsock_wait (watch) == 0); } // need to create a file in the test directory we\*(Aqre watching // in order to ensure the directory exists zfile_t *initfile = zfile_new ("\&./zdir\-test\-dir", "initial_file"); assert (initfile); zfile_output (initfile); fprintf (zfile_handle (initfile), "initial file\en"); zfile_close (initfile); zfile_destroy (&initfile); zclock_sleep (1001); // wait for initial file to become \*(Aqstable\*(Aq zsock_send (watch, "si", "TIMEOUT", 100); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir\-test\-dir"); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "UNSUBSCRIBE", "zdir\-test\-dir"); assert (zsock_wait (watch) == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir\-test\-dir"); assert (zsock_wait (watch) == 0); zfile_t *newfile = zfile_new ("zdir\-test\-dir", "test_abc"); zfile_output (newfile); fprintf (zfile_handle (newfile), "test file\en"); zfile_close (newfile); zpoller_t *watch_poll = zpoller_new (watch, NULL); // poll for a certain timeout before giving up and failing the test\&. assert(zpoller_wait (watch_poll, 1001) == watch); // wait for notification of the file being added char *path; int rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir\-test\-dir")); free (path); assert (zlist_size (patches) == 1); zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir\-test\-dir")); zfile_t *patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir\-test\-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); // remove the file zfile_remove (newfile); zfile_destroy (&newfile); // poll for a certain timeout before giving up and failing the test\&. assert(zpoller_wait (watch_poll, 1001) == watch); // wait for notification of the file being removed rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir\-test\-dir")); free (path); assert (zlist_size (patches) == 1); patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir\-test\-dir")); patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir\-test\-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); zpoller_destroy (&watch_poll); zactor_destroy (&watch); // clean up by removing the test directory\&. zdir_t *testdir = zdir_new ("zdir\-test\-dir", NULL); zdir_remove (testdir, true); zdir_destroy (&testdir); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zproxy.txt0000664000175000017500000001107312533132136014452 0ustar00phph00000000000000zproxy(3) ========= NAME ---- zproxy - run a steerable proxy in the background SYNOPSIS -------- ---- // Create new zproxy actor instance. The proxy switches messages between // a frontend socket and a backend socket; use the FRONTEND and BACKEND // commands to configure these: // // zactor_t *proxy = zactor_new (zproxy, NULL); // // Destroy zproxy instance. This destroys the two sockets and stops any // message flow between them: // // zactor_destroy (&proxy); // // Note that all zproxy commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity: // // zstr_send (proxy, "VERBOSE"); // zsock_wait (proxy); // // Specify frontend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); // zsock_wait (proxy); // // Specify backend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); // zsock_wait (proxy); // // Capture all proxied messages; these are delivered to the application // via an inproc PULL socket that you have already bound to the specified // endpoint: // // zstr_sendx (proxy, "CAPTURE", endpoint, NULL); // zsock_wait (proxy); // // Pause the proxy. A paused proxy will cease processing messages, causing // them to be queued up and potentially hit the high-water mark on the // frontend or backend socket, causing messages to be dropped, or writing // applications to block: // // zstr_sendx (proxy, "PAUSE", NULL); // zsock_wait (proxy); // // Resume the proxy. Note that the proxy starts automatically as soon as it // has a properly attached frontend and backend socket: // // zstr_sendx (proxy, "RESUME", NULL); // zsock_wait (proxy); // // This is the zproxy constructor as a zactor_fn; the argument is a // character string specifying frontend and backend socket types as two // uppercase strings separated by a hyphen: CZMQ_EXPORT void zproxy (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zproxy_test (bool verbose); ---- DESCRIPTION ----------- A zproxy actor switches messages between a frontend and a backend socket. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ's facilities, to be somewhat simpler to set-up. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). EXAMPLE ------- .From zproxy_test method ---- // Create and configure our proxy zactor_t *proxy = zactor_new (zproxy, NULL); assert (proxy); if (verbose) { zstr_sendx (proxy, "VERBOSE", NULL); zsock_wait (proxy); } zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL); zsock_wait (proxy); // Connect application sockets to proxy zsock_t *faucet = zsock_new_push (">inproc://frontend"); assert (faucet); zsock_t *sink = zsock_new_pull (">inproc://backend"); assert (sink); // Send some messages and check they arrived char *hello, *world; zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test pause/resume functionality zstr_sendx (proxy, "PAUSE", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zsock_set_rcvtimeo (sink, 100); zstr_recvx (sink, &hello, &world, NULL); assert (!hello && !world); zstr_sendx (proxy, "RESUME", NULL); zsock_wait (proxy); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test capture functionality zsock_t *capture = zsock_new_pull ("inproc://capture"); assert (capture); // Switch on capturing, check that it works zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zstr_recvx (capture, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zsock_destroy (&faucet); zsock_destroy (&sink); zsock_destroy (&capture); zactor_destroy (&proxy); ---- czmq-3.0.2/doc/zauth_v2.txt0000664000175000017500000001574112533132136014647 0ustar00phph00000000000000zauth_v2(3) =========== NAME ---- zauth_v2 - authentication for ZeroMQ servers (deprecated) SYNOPSIS -------- ---- #ifndef CURVE_ALLOW_ANY # define CURVE_ALLOW_ANY "*" #endif // Constructor // Install authentication for the specified context. Returns a new zauth // object that you can use to configure authentication. Note that until you // add policies, all incoming NULL connections are allowed (classic ZeroMQ // behaviour), and all PLAIN and CURVE connections are denied. If there was // an error during initialization, returns NULL. CZMQ_EXPORT zauth_t * zauth_new (zctx_t *ctx); // Destructor CZMQ_EXPORT void zauth_destroy (zauth_t **self_p); // Allow (whitelist) a single IP address. For NULL, all clients from this // address will be accepted. For PLAIN and CURVE, they will be allowed to // continue with authentication. You can call this method multiple times // to whitelist multiple IP addresses. If you whitelist a single address, // any non-whitelisted addresses are treated as blacklisted. CZMQ_EXPORT void zauth_allow (zauth_t *self, const char *address); // Deny (blacklist) a single IP address. For all security mechanisms, this // rejects the connection without any further authentication. Use either a // whitelist, or a blacklist, not not both. If you define both a whitelist // and a blacklist, only the whitelist takes effect. CZMQ_EXPORT void zauth_deny (zauth_t *self, const char *address); // Configure PLAIN authentication for a given domain. PLAIN authentication // uses a plain-text password file. To cover all domains, use "*". You can // modify the password file at any time; it is reloaded automatically. CZMQ_EXPORT void zauth_configure_plain (zauth_t *self, const char *domain, const char *filename); // Configure CURVE authentication for a given domain. CURVE authentication // uses a directory that holds all public client certificates, i.e. their // public keys. The certificates must be in zcert_save () format. To cover // all domains, use "*". You can add and remove certificates in that // directory at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the location. CZMQ_EXPORT void zauth_configure_curve (zauth_t *self, const char *domain, const char *location); // Configure GSSAPI authentication for a given domain. GSSAPI authentication // uses an underlying mechanism (usually Kerberos) to establish a secure // context and perform mutual authentication. To cover all domains, use "*". CZMQ_EXPORT void zauth_configure_gssapi (zauth_t *self, char *domain); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zauth_set_verbose (zauth_t *self, bool verbose); // Selftest CZMQ_EXPORT void zauth_v2_test (bool verbose); ---- DESCRIPTION ----------- A zauth object takes over authentication for all incoming connections in its context. This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets. EXAMPLE ------- .From zauth_v2_test method ---- // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Install the authenticator zctx_t *ctx = zctx_new (); assert (ctx); zauth_t *auth = zauth_new (ctx); assert (auth); zauth_set_verbose (auth, verbose); // A default NULL connection should always success, and not // go through our authentication infrastructure at all. void *server = zsocket_new (ctx, ZMQ_PUSH); assert (server); void *client = zsocket_new (ctx, ZMQ_PULL); assert (client); bool success = s_can_connect (ctx, &server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsocket_set_zap_domain (server, "global"); success = s_can_connect (ctx, &server, &client); assert (success); // Blacklist 127.0.0.1, connection should fail zsocket_set_zap_domain (server, "global"); zauth_deny (auth, "127.0.0.1"); success = s_can_connect (ctx, &server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsocket_set_zap_domain (server, "global"); zauth_allow (auth, "127.0.0.1"); success = s_can_connect (ctx, &server, &client); assert (success); // Try PLAIN authentication zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); success = s_can_connect (ctx, &server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Password"); zauth_configure_plain (auth, "*", TESTDIR "/password-file"); success = s_can_connect (ctx, &server, &client); assert (success); zsocket_set_plain_server (server, 1); zsocket_set_plain_username (client, "admin"); zsocket_set_plain_password (client, "Bogus"); success = s_can_connect (ctx, &server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); success = s_can_connect (ctx, &server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zauth_configure_curve (auth, "*", CURVE_ALLOW_ANY); success = s_can_connect (ctx, &server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsocket_set_curve_server (server, 1); zsocket_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zauth_configure_curve (auth, "*", TESTDIR); success = s_can_connect (ctx, &server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zauth_destroy (&auth); success = s_can_connect (ctx, &server, &client); assert (success); zctx_destroy (&ctx); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); ---- czmq-3.0.2/doc/zcertstore.txt0000664000175000017500000000753412533132136015312 0ustar00phph00000000000000zcertstore(3) ============= NAME ---- zcertstore - work with CURVE security certificate stores SYNOPSIS -------- ---- // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. CZMQ_EXPORT zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. CZMQ_EXPORT void zcertstore_destroy (zcertstore_t **self_p); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. CZMQ_EXPORT zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. CZMQ_EXPORT void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Print list of certificates in store to logging facility CZMQ_EXPORT void zcertstore_print (zcertstore_t *self); // DEPRECATED as incompatible with centralized logging // Print list of certificates in store to open stream CZMQ_EXPORT void zcertstore_fprint (zcertstore_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcertstore_test (bool verbose); ---- DESCRIPTION ----------- To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client's public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. The zcert class does the work of managing a single certificate. The certificate store can be memory-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically. In most applications you won't use this class directly but through the zauth class, which provides a high-level API for authentication (and manages certificate stores for you). To actually create certificates on disk, use the zcert class in code, or the tools/makecert.c command line tool, or any text editor. The format of a certificate file is defined in the zcert man page. EXAMPLE ------- .From zcertstore_test method ---- // Create temporary directory for test files # define TESTDIR ".test_zcertstore" zsys_dir_create (TESTDIR); // Load certificate store from disk; it will be empty zcertstore_t *certstore = zcertstore_new (TESTDIR); assert (certstore); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); assert (cert); char *client_key = strdup (zcert_public_txt (cert)); assert (client_key); zcert_set_meta (cert, "name", "John Doe"); zcert_save (cert, TESTDIR "/mycert.txt"); zcert_destroy (&cert); // Check that certificate store refreshes as expected cert = zcertstore_lookup (certstore, client_key); assert (cert); assert (streq (zcert_meta (cert, "name"), "John Doe")); free (client_key); if (verbose) zcertstore_print (certstore); zcertstore_destroy (&certstore); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); ---- czmq-3.0.2/doc/zclock.30000664000175000017500000000771212533132156013716 0ustar00phph00000000000000'\" t .\" Title: zclock .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZCLOCK" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zclock \- millisecond clocks and delays .SH "SYNOPSIS" .sp .nf // Sleep for a number of milliseconds CZMQ_EXPORT void zclock_sleep (int msecs); // Return current system clock as milliseconds\&. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets\&. Use zclock_mono for that instead\&. CZMQ_EXPORT int64_t zclock_time (void); // Return current monotonic clock in milliseconds\&. Use this when you compute // time offsets\&. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock\&. CZMQ_EXPORT int64_t zclock_mono (void); // Return current monotonic clock in microseconds\&. Use this when you compute // time offsets\&. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock\&. CZMQ_EXPORT int64_t zclock_usecs (void); // Return formatted date/time as fresh string\&. Free using zstr_free()\&. CZMQ_EXPORT char * zclock_timestr (void); // Self test of this class CZMQ_EXPORT void zclock_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling\&. Wraps the non\-portable system calls in a simple portable API\&. .sp The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity\&. .SH "EXAMPLE" .PP \fBFrom zclock_test method\fR. .sp .if n \{\ .RS 4 .\} .nf int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () \- start) >= 10); start = zclock_mono (); int64_t usecs = zclock_usecs (); zclock_sleep (10); assert ((zclock_mono () \- start) >= 10); assert ((zclock_usecs () \- usecs) >= 10000); char *timestr = zclock_timestr (); if (verbose) puts (timestr); free (timestr); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/Makefile.am0000664000175000017500000000621712535241705014403 0ustar00phph00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ MAN1 = makecert.1 MAN3 = zactor.3 zauth.3 zarmour.3 zbeacon.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zgossip.3 zhashx.3 ziflist.3 zlistx.3 zloop.3 zmonitor.3 zmsg.3 zpoller.3 zproxy.3 zrex.3 zsock.3 zsock_option.3 zstr.3 zsys.3 zuuid.3 zauth_v2.3 zbeacon_v2.3 zctx.3 zhash.3 zlist.3 zmonitor_v2.3 zmutex.3 zproxy_v2.3 zsocket.3 zsockopt.3 zthread.3 MAN7 = czmq.7 MAN_DOC = $(MAN1) $(MAN3) $(MAN7) MAN_TXT = $(MAN1:%.1=%.txt) MAN_TXT += $(MAN3:%.3=%.txt) MAN_TXT += $(MAN7:%.7=%.txt) EXTRA_DIST = asciidoc.conf $(MAN_TXT) if BUILD_DOC if INSTALL_MAN dist_man_MANS = $(MAN_DOC) endif MAINTAINERCLEANFILES = $(MAN_DOC) dist-hook : $(MAN_DOC) SUFFIXES=.txt .xml .1 .3 .7 .txt.xml: asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< .xml.1: xmlto man $< .xml.3: xmlto man $< .xml.7: xmlto man $< zactor.txt: zproject_mkman $@ zauth.txt: zproject_mkman $@ zarmour.txt: zproject_mkman $@ zbeacon.txt: zproject_mkman $@ zcert.txt: zproject_mkman $@ zcertstore.txt: zproject_mkman $@ zchunk.txt: zproject_mkman $@ zclock.txt: zproject_mkman $@ zconfig.txt: zproject_mkman $@ zdigest.txt: zproject_mkman $@ zdir.txt: zproject_mkman $@ zdir_patch.txt: zproject_mkman $@ zfile.txt: zproject_mkman $@ zframe.txt: zproject_mkman $@ zgossip.txt: zproject_mkman $@ zhashx.txt: zproject_mkman $@ ziflist.txt: zproject_mkman $@ zlistx.txt: zproject_mkman $@ zloop.txt: zproject_mkman $@ zmonitor.txt: zproject_mkman $@ zmsg.txt: zproject_mkman $@ zpoller.txt: zproject_mkman $@ zproxy.txt: zproject_mkman $@ zrex.txt: zproject_mkman $@ zsock.txt: zproject_mkman $@ zsock_option.txt: zproject_mkman $@ zstr.txt: zproject_mkman $@ zsys.txt: zproject_mkman $@ zuuid.txt: zproject_mkman $@ zauth_v2.txt: zproject_mkman $@ zbeacon_v2.txt: zproject_mkman $@ zctx.txt: zproject_mkman $@ zhash.txt: zproject_mkman $@ zlist.txt: zproject_mkman $@ zmonitor_v2.txt: zproject_mkman $@ zmutex.txt: zproject_mkman $@ zproxy_v2.txt: zproject_mkman $@ zsocket.txt: zproject_mkman $@ zsockopt.txt: zproject_mkman $@ zthread.txt: zproject_mkman $@ makecert.txt: zproject_mkman $@ clean: rm -f *.1 *.3 zproject_mkman zactor zauth zarmour zbeacon zcert zcertstore zchunk zclock zconfig zdigest zdir zdir_patch zfile zframe zgossip zhashx ziflist zlistx zloop zmonitor zmsg zpoller zproxy zrex zsock zsock_option zstr zsys zuuid zauth_v2 zbeacon_v2 zctx zhash zlist zmonitor_v2 zmutex zproxy_v2 zsocket zsockopt zthread makecert endif ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/doc/makecert.txt0000664000175000017500000000056512533132136014676 0ustar00phph00000000000000makecert(1) =========== NAME ---- makecert - no title found SYNOPSIS -------- ---- Please add @interface section in ../src/makecert.c. ---- DESCRIPTION ----------- Please add @header section in ../src/makecert.c. Please add @discuss section in ../src/makecert.c. EXAMPLE ------- .From makecert_test method ---- Please add @selftest section in ../src/makecert.c. ---- czmq-3.0.2/doc/zclock.txt0000664000175000017500000000362612533132136014371 0ustar00phph00000000000000zclock(3) ========= NAME ---- zclock - millisecond clocks and delays SYNOPSIS -------- ---- // Sleep for a number of milliseconds CZMQ_EXPORT void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. CZMQ_EXPORT int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). CZMQ_EXPORT char * zclock_timestr (void); // Self test of this class CZMQ_EXPORT void zclock_test (bool verbose); ---- DESCRIPTION ----------- The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling. Wraps the non-portable system calls in a simple portable API. The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity. EXAMPLE ------- .From zclock_test method ---- int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); start = zclock_mono (); int64_t usecs = zclock_usecs (); zclock_sleep (10); assert ((zclock_mono () - start) >= 10); assert ((zclock_usecs () - usecs) >= 10000); char *timestr = zclock_timestr (); if (verbose) puts (timestr); free (timestr); ---- czmq-3.0.2/doc/zsock_option.30000664000175000017500000010142712533132170015144 0ustar00phph00000000000000'\" t .\" Title: zsock_option .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZSOCK_OPTION" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zsock_option \- get/set 0MQ socket options .SH "SYNOPSIS" .sp .nf #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsock_tos (void *self); CZMQ_EXPORT char * zsock_zap_domain (void *self); CZMQ_EXPORT int zsock_mechanism (void *self); CZMQ_EXPORT int zsock_plain_server (void *self); CZMQ_EXPORT char * zsock_plain_username (void *self); CZMQ_EXPORT char * zsock_plain_password (void *self); CZMQ_EXPORT int zsock_curve_server (void *self); CZMQ_EXPORT char * zsock_curve_publickey (void *self); CZMQ_EXPORT char * zsock_curve_secretkey (void *self); CZMQ_EXPORT char * zsock_curve_serverkey (void *self); CZMQ_EXPORT int zsock_gssapi_server (void *self); CZMQ_EXPORT int zsock_gssapi_plaintext (void *self); CZMQ_EXPORT char * zsock_gssapi_principal (void *self); CZMQ_EXPORT char * zsock_gssapi_service_principal (void *self); CZMQ_EXPORT int zsock_ipv6 (void *self); CZMQ_EXPORT int zsock_immediate (void *self); CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_tos (void *self, int tos); CZMQ_EXPORT void zsock_set_router_handover (void *self, int router_handover); CZMQ_EXPORT void zsock_set_router_mandatory (void *self, int router_mandatory); CZMQ_EXPORT void zsock_set_probe_router (void *self, int probe_router); CZMQ_EXPORT void zsock_set_req_relaxed (void *self, int req_relaxed); CZMQ_EXPORT void zsock_set_req_correlate (void *self, int req_correlate); CZMQ_EXPORT void zsock_set_conflate (void *self, int conflate); CZMQ_EXPORT void zsock_set_zap_domain (void *self, const char * zap_domain); CZMQ_EXPORT void zsock_set_plain_server (void *self, int plain_server); CZMQ_EXPORT void zsock_set_plain_username (void *self, const char * plain_username); CZMQ_EXPORT void zsock_set_plain_password (void *self, const char * plain_password); CZMQ_EXPORT void zsock_set_curve_server (void *self, int curve_server); CZMQ_EXPORT void zsock_set_curve_publickey (void *self, const char * curve_publickey); CZMQ_EXPORT void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); CZMQ_EXPORT void zsock_set_curve_secretkey (void *self, const char * curve_secretkey); CZMQ_EXPORT void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); CZMQ_EXPORT void zsock_set_curve_serverkey (void *self, const char * curve_serverkey); CZMQ_EXPORT void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); CZMQ_EXPORT void zsock_set_gssapi_server (void *self, int gssapi_server); CZMQ_EXPORT void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); CZMQ_EXPORT void zsock_set_gssapi_principal (void *self, const char * gssapi_principal); CZMQ_EXPORT void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal); CZMQ_EXPORT void zsock_set_ipv6 (void *self, int ipv6); CZMQ_EXPORT void zsock_set_immediate (void *self, int immediate); CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsock_hwm (void *self); CZMQ_EXPORT int zsock_swap (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_recovery_ivl_msec (void *self); CZMQ_EXPORT int zsock_mcast_loop (void *self); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_rcvtimeo (void *self); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_sndtimeo (void *self); # endif CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); // Set socket options CZMQ_EXPORT void zsock_set_hwm (void *self, int hwm); CZMQ_EXPORT void zsock_set_swap (void *self, int swap); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); CZMQ_EXPORT void zsock_set_mcast_loop (void *self, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); # endif CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsock_option_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zsock_option class provides access to the 0MQ getsockopt/setsockopt API\&. All methods in this class take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_r reference, or a libzmq void *\&. .sp This class is generated, using the GSL code generator\&. See the sockopts XML file, which provides the metadata, and the sock_option\&.gsl template, which does the work\&. .SH "EXAMPLE" .PP \fBFrom zsock_option_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zsock_t *self; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_tos (self, 1); assert (zsock_tos (self) == 1); zsock_tos (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_HANDOVER) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_handover (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_MANDATORY) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_mandatory (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_PROBE_ROUTER) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_probe_router (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_RELAXED) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_relaxed (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_CORRELATE) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_correlate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONFLATE) self = zsock_new (ZMQ_PUSH); assert (self); zsock_set_conflate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ZAP_DOMAIN) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_zap_domain (self, "test"); char *zap_domain = zsock_zap_domain (self); assert (zap_domain); free (zap_domain); zsock_destroy (&self); # endif # if defined (ZMQ_MECHANISM) self = zsock_new (ZMQ_SUB); assert (self); zsock_mechanism (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_SERVER) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_plain_server (self, 1); assert (zsock_plain_server (self) == 1); zsock_plain_server (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_USERNAME) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_username (self, "test"); char *plain_username = zsock_plain_username (self); assert (plain_username); free (plain_username); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_PASSWORD) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_password (self, "test"); char *plain_password = zsock_plain_password (self); assert (plain_password); free (plain_password); zsock_destroy (&self); # endif # if defined (ZMQ_IPV6) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv6 (self, 1); assert (zsock_ipv6 (self) == 1); zsock_ipv6 (self); zsock_destroy (&self); # endif # if defined (ZMQ_IMMEDIATE) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_immediate (self, 1); assert (zsock_immediate (self) == 1); zsock_immediate (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127\&.0\&.0\&.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127\&.0\&.0\&.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_hwm (self, 1); assert (zsock_hwm (self) == 1); zsock_hwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_SWAP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_swap (self, 1); assert (zsock_swap (self) == 1); zsock_swap (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl_msec (self, 1); assert (zsock_recovery_ivl_msec (self) == 1); zsock_recovery_ivl_msec (self); zsock_destroy (&self); # endif # if defined (ZMQ_MCAST_LOOP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_mcast_loop (self, 1); assert (zsock_mcast_loop (self) == 1); zsock_mcast_loop (self); zsock_destroy (&self); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif #endif .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zmutex.txt0000664000175000017500000000214512533132136014433 0ustar00phph00000000000000zmutex(3) ========= NAME ---- zmutex - working with mutexes (deprecated) SYNOPSIS -------- ---- // Create a new mutex container CZMQ_EXPORT zmutex_t * zmutex_new (void); // Destroy a mutex container CZMQ_EXPORT void zmutex_destroy (zmutex_t **self_p); // Lock mutex CZMQ_EXPORT void zmutex_lock (zmutex_t *self); // Unlock mutex CZMQ_EXPORT void zmutex_unlock (zmutex_t *self); // Try to lock mutex CZMQ_EXPORT int zmutex_try_lock (zmutex_t *self); // Self test of this class CZMQ_EXPORT void zmutex_test (bool verbose); ---- DESCRIPTION ----------- The zmutex class provides a portable wrapper for mutexes. Please do not use this class to do multi-threading. It is for the rare case where you absolutely need thread-safe global state. This should happen in system code only. DO NOT USE THIS TO SHARE SOCKETS BETWEEN THREADS, OR DARK THINGS WILL HAPPEN TO YOUR CODE. Please add @discuss section in ../src/zmutex.c. EXAMPLE ------- .From zmutex_test method ---- zmutex_t *mutex = zmutex_new (); assert (mutex); zmutex_lock (mutex); zmutex_unlock (mutex); zmutex_destroy (&mutex); ---- czmq-3.0.2/doc/zauth.txt0000664000175000017500000001637312533132136014242 0ustar00phph00000000000000zauth(3) ======== NAME ---- zauth - authentication for ZeroMQ security mechanisms SYNOPSIS -------- ---- #define CURVE_ALLOW_ANY "*" // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated). // // Create new zauth actor instance. This installs authentication on all // zsock sockets. Until you add policies, all incoming NULL connections are // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections // are denied: // // zactor_t *auth = zactor_new (zauth, NULL); // // Destroy zauth instance. This removes authentication and allows all // connections to pass, without authentication: // // zactor_destroy (&auth); // // Note that all zauth commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity. Verbose logging can help // debug non-trivial authentication policies: // // zstr_send (auth, "VERBOSE"); // zsock_wait (auth); // // Allow (whitelist) a list of IP addresses. For NULL, all clients from // these addresses will be accepted. For PLAIN and CURVE, they will be // allowed to continue with authentication. You can call this method // multiple times to whitelist more IP addresses. If you whitelist one // or nmore addresses, any non-whitelisted addresses are treated as // blacklisted: // // zstr_sendx (auth, "ALLOW", "127.0.0.1", "127.0.0.2", NULL); // zsock_wait (auth); // // Deny (blacklist) a list of IP addresses. For all security mechanisms, // this rejects the connection without any further authentication. Use // either a whitelist, or a blacklist, not not both. If you define both // a whitelist and a blacklist, only the whitelist takes effect: // // zstr_sendx (auth, "DENY", "192.168.0.1", "192.168.0.2", NULL); // zsock_wait (auth); // // Configure PLAIN authentication using a plain-text password file. You can // modify the password file at any time; zauth will reload it automatically // if modified externally: // // zstr_sendx (auth, "PLAIN", filename, NULL); // zsock_wait (auth); // // Configure CURVE authentication, using a directory that holds all public // client certificates, i.e. their public keys. The certificates must be in // zcert_save format. You can add and remove certificates in that directory // at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the directory name: // // zstr_sendx (auth, "CURVE", directory, NULL); // zsock_wait (auth); // // Configure GSSAPI authentication, using an underlying mechanism (usually // Kerberos) to establish a secure context and perform mutual authentication: // // zstr_sendx (auth, "GSSAPI", NULL); // zsock_wait (auth); // // This is the zauth constructor as a zactor_fn: CZMQ_EXPORT void zauth (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zauth_test (bool verbose); ---- DESCRIPTION ----------- A zauth actor takes over authentication for all incoming connections in its context. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections. This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). EXAMPLE ------- .From zauth_test method ---- // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Check there's no authentication zsock_t *server = zsock_new (ZMQ_PUSH); assert (server); zsock_t *client = zsock_new (ZMQ_PULL); assert (client); bool success = s_can_connect (&server, &client); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server success = s_can_connect (&server, &client); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client); assert (success); // Blacklist 127.0.0.1, connection should fail zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (!success); // Whitelist our address, which overrides the blacklist zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Try PLAIN authentication zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); success = s_can_connect (&server, &client); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); zstr_sendx (auth, "PLAIN", TESTDIR "/password-file", NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Bogus"); success = s_can_connect (&server, &client); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); success = s_can_connect (&server, &client); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); // Test full client authentication using certificates zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zstr_sendx (auth, "CURVE", TESTDIR, NULL); zsock_wait (auth); success = s_can_connect (&server, &client); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); success = s_can_connect (&server, &client); assert (success); zsock_destroy (&client); zsock_destroy (&server); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); ---- czmq-3.0.2/doc/zframe.30000664000175000017500000002001312533132160013675 0ustar00phph00000000000000'\" t .\" Title: zframe .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZFRAME" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zframe \- working with single message frames .SH "SYNOPSIS" .sp .nf #define ZFRAME_MORE 1 // #define ZFRAME_REUSE 2 // #define ZFRAME_DONTWAIT 4 // // Create a new frame\&. If size is not null, allocates the frame data // to the specified size\&. If additionally, data is not null, copies // size octets from the specified data into the frame body\&. CZMQ_EXPORT zframe_t * zframe_new (const void *data, size_t size); // Destroy a frame CZMQ_EXPORT void zframe_destroy (zframe_t **self_p); // Create an empty (zero\-sized) frame // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zframe_new_empty (); // Create a frame with a specified string content\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted\&. Does a blocking recv, if you want to not block then use // zpoller or zloop\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending\&. // Return \-1 on error, 0 on success\&. CZMQ_EXPORT int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data CZMQ_EXPORT size_t zframe_size (zframe_t *self); // Return address of frame data CZMQ_EXPORT byte * zframe_data (zframe_t *self); // Create a new frame that duplicates an existing frame\&. If frame is null, // or memory was exhausted, returns null\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs\&. // Caller must free string when finished with it\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator CZMQ_EXPORT bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method CZMQ_EXPORT int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0)\&. Note this is NOT used when sending // frame to socket, you have to specify flag explicitly\&. CZMQ_EXPORT void zframe_set_more (zframe_t *self, int more); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false\&. CZMQ_EXPORT bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame CZMQ_EXPORT void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream)\&. Prefix shows before frame, if not null\&. CZMQ_EXPORT void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t\&. CZMQ_EXPORT bool zframe_is (void *self); // Self test of this class CZMQ_EXPORT void zframe_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zframe class provides methods to send and receive single message frames across 0MQ sockets\&. A \fIframe\fR corresponds to one zmq_msg_t\&. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message\&. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times\&. Frames are binary, and this class has no special support for text data\&. .sp Please add @discuss section in \&.\&./src/zframe\&.c\&. .SH "EXAMPLE" .PP \fBFrom zframe_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zframe\&.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zframe\&.test"); assert (input); // Send five different frames, test ZFRAME_MORE int frame_nbr; for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, ZFRAME_MORE); assert (rc == 0); } // Send same frame five times, test ZFRAME_REUSE frame = zframe_new ("Hello", 5); assert (frame); for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE); assert (rc == 0); } assert (frame); zframe_t *copy = zframe_dup (frame); assert (zframe_eq (frame, copy)); zframe_destroy (&frame); assert (!zframe_eq (frame, copy)); assert (zframe_size (copy) == 5); zframe_destroy (©); assert (!zframe_eq (frame, copy)); // Test zframe_new_empty frame = zframe_new_empty (); assert (frame); assert (zframe_size (frame) == 0); zframe_destroy (&frame); // Send END frame frame = zframe_new ("NOT", 3); assert (frame); zframe_reset (frame, "END", 3); char *string = zframe_strhex (frame); assert (streq (string, "454E44")); free (string); string = zframe_strdup (frame); assert (streq (string, "END")); free (string); rc = zframe_send (&frame, output, 0); assert (rc == 0); // Read and count until we receive END frame_nbr = 0; for (frame_nbr = 0;; frame_nbr++) { zframe_t *frame = zframe_recv (input); if (zframe_streq (frame, "END")) { zframe_destroy (&frame); break; } assert (zframe_more (frame)); zframe_set_more (frame, 0); assert (zframe_more (frame) == 0); zframe_destroy (&frame); } assert (frame_nbr == 10); zsock_destroy (&input); zsock_destroy (&output); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zlist.txt0000664000175000017500000002146012533132136014245 0ustar00phph00000000000000zlist(3) ======== NAME ---- zlist - simple generic list container SYNOPSIS -------- ---- // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Create a new list container CZMQ_EXPORT zlist_t * zlist_new (); // Destroy a list container CZMQ_EXPORT void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any CZMQ_EXPORT void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. CZMQ_EXPORT bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present CZMQ_EXPORT void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zlist_dup (zlist_t *self); // Purge all items from list CZMQ_EXPORT void zlist_purge (zlist_t *self); // Return number of items in the list CZMQ_EXPORT size_t zlist_size (zlist_t *self); // Sort the list by ascending key value using a straight ASCII comparison. // The sort is not stable, so may reorder items with the same keys. CZMQ_EXPORT void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. CZMQ_EXPORT void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. CZMQ_EXPORT void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class CZMQ_EXPORT void zlist_test (int verbose); ---- DESCRIPTION ----------- Provides a generic container implementing a fast singly-linked list. You can use this to construct multi-dimensional lists, and other structures together with other generic containers like zhash. This is a simple class. For demanding applications we recommend using zlistx. To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration. EXAMPLE ------- .From zlist_test method ---- zlist_t *list = zlist_new (); assert (list); assert (zlist_size (list) == 0); // Three items we'll use as test data // List items are void *, not particularly strings char *cheese = "boursin"; char *bread = "baguette"; char *wine = "bordeaux"; zlist_append (list, cheese); assert (zlist_size (list) == 1); assert ( zlist_exists (list, cheese)); assert (!zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, bread); assert (zlist_size (list) == 2); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, wine); assert (zlist_size (list) == 3); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert ( zlist_exists (list, wine)); assert (zlist_head (list) == cheese); assert (zlist_next (list) == cheese); assert (zlist_first (list) == cheese); assert (zlist_tail (list) == wine); assert (zlist_next (list) == bread); assert (zlist_first (list) == cheese); assert (zlist_next (list) == bread); assert (zlist_next (list) == wine); assert (zlist_next (list) == NULL); // After we reach end of list, next wraps around assert (zlist_next (list) == cheese); assert (zlist_size (list) == 3); zlist_remove (list, wine); assert (zlist_size (list) == 2); assert (zlist_first (list) == cheese); zlist_remove (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == bread); zlist_remove (list, bread); assert (zlist_size (list) == 0); zlist_append (list, cheese); zlist_append (list, bread); assert (zlist_last (list) == bread); zlist_remove (list, bread); assert (zlist_last (list) == cheese); zlist_remove (list, cheese); assert (zlist_last (list) == NULL); zlist_push (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == cheese); zlist_push (list, bread); assert (zlist_size (list) == 2); assert (zlist_first (list) == bread); assert (zlist_item (list) == bread); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_first (list) == bread); zlist_t *sub_list = zlist_dup (list); assert (sub_list); assert (zlist_size (sub_list) == 3); zlist_sort (list, s_compare); char *item; item = (char *) zlist_pop (list); assert (item == bread); item = (char *) zlist_pop (list); assert (item == wine); item = (char *) zlist_pop (list); assert (item == cheese); assert (zlist_size (list) == 0); assert (zlist_size (sub_list) == 3); zlist_push (list, sub_list); zlist_t *sub_list_2 = zlist_dup (sub_list); zlist_append (list, sub_list_2); assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list); assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2); zlist_destroy (&list); // Test autofree functionality list = zlist_new (); assert (list); zlist_autofree (list); // Set equals function otherwise equals will not work as autofree copies strings zlist_comparefn (list, s_compare); zlist_push (list, bread); zlist_append (list, cheese); assert (zlist_size (list) == 2); zlist_append (list, wine); assert (zlist_exists (list, wine)); zlist_remove (list, wine); assert (!zlist_exists (list, wine)); assert (streq ((const char *) zlist_first (list), bread)); item = (char *) zlist_pop (list); assert (streq (item, bread)); free (item); item = (char *) zlist_pop (list); assert (streq (item, cheese)); free (item); zlist_destroy (&list); assert (list == NULL); ---- czmq-3.0.2/doc/zsocket.30000664000175000017500000001654612533132200014106 0ustar00phph00000000000000'\" t .\" Title: zsocket .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZSOCKET" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zsocket \- working with 0MQ sockets (deprecated) .SH "SYNOPSIS" .sp .nf // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding\&. #define ZSOCKET_DYNFROM 0xc000 #define ZSOCKET_DYNTO 0xffff // Callback function for zero\-copy methods typedef void (zsocket_free_fn) (void *data, void *arg); // Create a new socket within our CZMQ context, replaces zmq_socket\&. // Use this to get automatic management of the socket at shutdown\&. // Note: SUB sockets do not automatically subscribe to everything; you // must set filters explicitly\&. CZMQ_EXPORT void * zsocket_new (zctx_t *self, int type); // Destroy a socket within our CZMQ context, replaces zmq_close\&. CZMQ_EXPORT void zsocket_destroy (zctx_t *ctx, void *self); // Bind a socket to a formatted endpoint\&. If the port is specified as // \*(Aq*\*(Aq, binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO // and returns the actual port number used\&. Otherwise asserts that the // bind succeeded with the specified port number\&. Always returns the // port number if successful\&. CZMQ_EXPORT int zsocket_bind (void *self, const char *format, \&.\&.\&.); // Unbind a socket from a formatted endpoint\&. // Returns 0 if OK, \-1 if the endpoint was invalid or the function // isn\*(Aqt supported\&. CZMQ_EXPORT int zsocket_unbind (void *self, const char *format, \&.\&.\&.); // Connect a socket to a formatted endpoint // Returns 0 if OK, \-1 if the endpoint was invalid\&. CZMQ_EXPORT int zsocket_connect (void *self, const char *format, \&.\&.\&.); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, \-1 if the endpoint was invalid or the function // isn\*(Aqt supported\&. CZMQ_EXPORT int zsocket_disconnect (void *self, const char *format, \&.\&.\&.); // Poll for input events on the socket\&. Returns TRUE if there is input // ready on the socket, else FALSE\&. CZMQ_EXPORT bool zsocket_poll (void *self, int msecs); // Returns socket type as printable constant string CZMQ_EXPORT const char * zsocket_type_str (void *self); // Send data over a socket as a single message frame\&. // Accepts these flags: ZFRAME_MORE and ZFRAME_DONTWAIT\&. // Returns \-1 on error, 0 on success CZMQ_EXPORT int zsocket_sendmem (void *self, const void *data, size_t size, int flags); // Send a signal over a socket\&. A signal is a zero\-byte message\&. // Signals are used primarily between threads, over pipe sockets\&. // Returns \-1 if there was an error sending the signal\&. CZMQ_EXPORT int zsocket_signal (void *self); // Wait on a signal\&. Use this to coordinate between threads, over // pipe pairs\&. Returns \-1 on error, 0 on success\&. CZMQ_EXPORT int zsocket_wait (void *self); // Self test of this class CZMQ_EXPORT void zsocket_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zsocket class provides helper functions for 0MQ sockets\&. It doesn\(cqt wrap the 0MQ socket type, to avoid breaking all libzmq socket\-related calls\&. .sp Please add @discuss section in \&.\&./src/zsocket\&.c\&. .SH "EXAMPLE" .PP \fBFrom zsocket_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zctx_t *ctx = zctx_new (); assert (ctx); // Create a detached thread, let it run char *interf = "127\&.0\&.0\&.1"; char *domain = "localhost"; int service = 5560; void *writer = zsocket_new (ctx, ZMQ_PUSH); assert (writer); void *reader = zsocket_new (ctx, ZMQ_PULL); assert (reader); assert (streq (zsocket_type_str (writer), "PUSH")); assert (streq (zsocket_type_str (reader), "PULL")); int rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsocket_unbind (writer, "tcp://%s:%d", interf, service); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error\&. // Even a short sleep allows the OS to release the port for reuse\&. zclock_sleep (100); // Bind again rc = zsocket_bind (writer, "tcp://%s:%d", interf, service); assert (rc == service); #endif rc = zsocket_connect (reader, "tcp://%s:%d", domain, service); assert (rc == 0); zstr_send (writer, "HELLO"); char *message = zstr_recv (reader); assert (message); assert (streq (message, "HELLO")); free (message); // Test binding to ports int port = zsocket_bind (writer, "tcp://%s:*", interf); assert (port >= ZSOCKET_DYNFROM && port <= ZSOCKET_DYNTO); assert (zsocket_poll (writer, 100) == false); // Test error state when connecting to an invalid socket type // (\*(Aqtxp://\*(Aq instead of \*(Aqtcp://\*(Aq, typo intentional) rc = zsocket_connect (reader, "txp://%s:%d", domain, service); assert (rc == \-1); // Test sending frames to socket rc = zsocket_sendmem (writer, "ABC", 3, ZFRAME_MORE); assert (rc == 0); rc = zsocket_sendmem (writer, "DEFG", 4, 0); assert (rc == 0); zframe_t *frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "ABC")); assert (zframe_more (frame)); zframe_destroy (&frame); frame = zframe_recv (reader); assert (frame); assert (zframe_streq (frame, "DEFG")); assert (!zframe_more (frame)); zframe_destroy (&frame); rc = zsocket_signal (writer); assert (rc == 0); rc = zsocket_wait (reader); assert (rc == 0); zsocket_destroy (ctx, reader); zsocket_destroy (ctx, writer); zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zframe.txt0000664000175000017500000001421112533132136014360 0ustar00phph00000000000000zframe(3) ========= NAME ---- zframe - working with single message frames SYNOPSIS -------- ---- #define ZFRAME_MORE 1 // #define ZFRAME_REUSE 2 // #define ZFRAME_DONTWAIT 4 // // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. CZMQ_EXPORT zframe_t * zframe_new (const void *data, size_t size); // Destroy a frame CZMQ_EXPORT void zframe_destroy (zframe_t **self_p); // Create an empty (zero-sized) frame // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_new_empty (); // Create a frame with a specified string content. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data CZMQ_EXPORT size_t zframe_size (zframe_t *self); // Return address of frame data CZMQ_EXPORT byte * zframe_data (zframe_t *self); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator CZMQ_EXPORT bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method CZMQ_EXPORT int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. CZMQ_EXPORT void zframe_set_more (zframe_t *self, int more); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. CZMQ_EXPORT bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame CZMQ_EXPORT void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. CZMQ_EXPORT void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. CZMQ_EXPORT bool zframe_is (void *self); // Self test of this class CZMQ_EXPORT void zframe_test (bool verbose); ---- DESCRIPTION ----------- The zframe class provides methods to send and receive single message frames across 0MQ sockets. A 'frame' corresponds to one zmq_msg_t. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times. Frames are binary, and this class has no special support for text data. Please add @discuss section in ../src/zframe.c. EXAMPLE ------- .From zframe_test method ---- // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zframe.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zframe.test"); assert (input); // Send five different frames, test ZFRAME_MORE int frame_nbr; for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, ZFRAME_MORE); assert (rc == 0); } // Send same frame five times, test ZFRAME_REUSE frame = zframe_new ("Hello", 5); assert (frame); for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE); assert (rc == 0); } assert (frame); zframe_t *copy = zframe_dup (frame); assert (zframe_eq (frame, copy)); zframe_destroy (&frame); assert (!zframe_eq (frame, copy)); assert (zframe_size (copy) == 5); zframe_destroy (©); assert (!zframe_eq (frame, copy)); // Test zframe_new_empty frame = zframe_new_empty (); assert (frame); assert (zframe_size (frame) == 0); zframe_destroy (&frame); // Send END frame frame = zframe_new ("NOT", 3); assert (frame); zframe_reset (frame, "END", 3); char *string = zframe_strhex (frame); assert (streq (string, "454E44")); free (string); string = zframe_strdup (frame); assert (streq (string, "END")); free (string); rc = zframe_send (&frame, output, 0); assert (rc == 0); // Read and count until we receive END frame_nbr = 0; for (frame_nbr = 0;; frame_nbr++) { zframe_t *frame = zframe_recv (input); if (zframe_streq (frame, "END")) { zframe_destroy (&frame); break; } assert (zframe_more (frame)); zframe_set_more (frame, 0); assert (zframe_more (frame) == 0); zframe_destroy (&frame); } assert (frame_nbr == 10); zsock_destroy (&input); zsock_destroy (&output); ---- czmq-3.0.2/doc/zdir_patch.30000664000175000017500000000775612533132160014563 0ustar00phph00000000000000'\" t .\" Title: zdir_patch .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZDIR_PATCH" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zdir_patch \- work with directory patches .SH "SYNOPSIS" .sp .nf typedef enum { ZDIR_PATCH_CREATE = 1, ZDIR_PATCH_DELETE = 2 } zdir_patch_op_t; // Create new patch CZMQ_EXPORT zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, zdir_patch_op_t op, const char *alias); // Destroy a patch CZMQ_EXPORT void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch\&. If the patch is null, or memory was exhausted, // returns null\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path CZMQ_EXPORT const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item CZMQ_EXPORT zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation CZMQ_EXPORT zdir_patch_op_t zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path CZMQ_EXPORT const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) CZMQ_EXPORT void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file CZMQ_EXPORT const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class\&. CZMQ_EXPORT void zdir_patch_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time)\&. .sp Please add @discuss section in \&.\&./src/zdir_patch\&.c\&. .SH "EXAMPLE" .PP \fBFrom zdir_patch_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zfile_t *file = zfile_new ("\&.", "bilbo"); assert (file); zdir_patch_t *patch = zdir_patch_new ("\&.", file, patch_create, "/"); assert (patch); zfile_destroy (&file); file = zdir_patch_file (patch); assert (file); assert (streq (zfile_filename (file, "\&."), "bilbo")); assert (streq (zdir_patch_vpath (patch), "/bilbo")); zdir_patch_destroy (&patch); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zcertstore.30000664000175000017500000001364212533132153014631 0ustar00phph00000000000000'\" t .\" Title: zcertstore .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZCERTSTORE" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zcertstore \- work with CURVE security certificate stores .SH "SYNOPSIS" .sp .nf // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location\&. The directory itself may be // absent, and created later, or modified at any time\&. The certificate store // is automatically refreshed on any zcertstore_lookup() call\&. If the // location is specified as NULL, creates a pure\-memory store, which you // can work with by inserting certificates at runtime\&. CZMQ_EXPORT zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory\&. Does not affect anything // stored on disk\&. CZMQ_EXPORT void zcertstore_destroy (zcertstore_t **self_p); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL\&. The public key is provided in Z85 text format\&. CZMQ_EXPORT zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory\&. Note that this // does not save the certificate to disk\&. To do that, use zcert_save() // directly on the certificate\&. Takes ownership of zcert_t object\&. CZMQ_EXPORT void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Print list of certificates in store to logging facility CZMQ_EXPORT void zcertstore_print (zcertstore_t *self); // DEPRECATED as incompatible with centralized logging // Print list of certificates in store to open stream CZMQ_EXPORT void zcertstore_fprint (zcertstore_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcertstore_test (bool verbose); .fi .SH "DESCRIPTION" .sp To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client\(cqs public key matches a key we know and accept\&. There are numerous ways to store accepted client public keys\&. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory)\&. This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not\&. The zcert class does the work of managing a single certificate\&. .sp The certificate store can be memory\-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically\&. In most applications you won\(cqt use this class directly but through the zauth class, which provides a high\-level API for authentication (and manages certificate stores for you)\&. To actually create certificates on disk, use the zcert class in code, or the tools/makecert\&.c command line tool, or any text editor\&. The format of a certificate file is defined in the zcert man page\&. .SH "EXAMPLE" .PP \fBFrom zcertstore_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create temporary directory for test files # define TESTDIR "\&.test_zcertstore" zsys_dir_create (TESTDIR); // Load certificate store from disk; it will be empty zcertstore_t *certstore = zcertstore_new (TESTDIR); assert (certstore); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); assert (cert); char *client_key = strdup (zcert_public_txt (cert)); assert (client_key); zcert_set_meta (cert, "name", "John Doe"); zcert_save (cert, TESTDIR "/mycert\&.txt"); zcert_destroy (&cert); // Check that certificate store refreshes as expected cert = zcertstore_lookup (certstore, client_key); assert (cert); assert (streq (zcert_meta (cert, "name"), "John Doe")); free (client_key); if (verbose) zcertstore_print (certstore); zcertstore_destroy (&certstore); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zsock.30000664000175000017500000005610412533132170013555 0ustar00phph00000000000000'\" t .\" Title: zsock .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZSOCK" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zsock \- high\-level socket API that hides libzmq contexts and sockets .SH "SYNOPSIS" .sp .nf // Create a new socket\&. Returns the new socket, or NULL if the new socket // could not be created\&. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection\&. This can have // performance implications if you use a LOT of sockets\&. To turn off this // redirection behaviour, define ZSOCK_NOCHECK\&. CZMQ_EXPORT zsock_t * zsock_new (int type); // Destroy the socket\&. You must use this for any socket created via the // zsock_new method\&. CZMQ_EXPORT void zsock_destroy (zsock_t **self_p); // Create a PUB socket\&. Default action is bind\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string\&. Default // action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket\&. Default action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket\&. Default action is bind\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket\&. Default action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket\&. Default action is bind\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket\&. Default action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket\&. Default action is bind\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket\&. Default action is bind\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket\&. Default action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket\&. Default action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket\&. Default action is connect\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zsock_t * zsock_new_stream (const char *endpoint); // Bind a socket to a formatted endpoint\&. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*"\&. By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535)\&. // To override this range, follow the "*" with "[first\-last]"\&. Either or // both first and last may be empty\&. To bind to a random port within the // range, use "!" in place of "*"\&. // // Examples: // tcp://127\&.0\&.0\&.1:* bind to first free port from C000 up // tcp://127\&.0\&.0\&.1:! bind to random port from C000 to FFFF // tcp://127\&.0\&.0\&.1:*[60000\-] bind to first free port from 60000 up // tcp://127\&.0\&.0\&.1:![\-60000] bind to random port from C000 to 60000 // tcp://127\&.0\&.0\&.1:![55000\-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports\&. On failure, returns \-1\&. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware\&. Protocols that run on ephemeral ports should take // this into account\&. CZMQ_EXPORT int zsock_bind (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Returns last bound endpoint, if any\&. CZMQ_EXPORT const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint\&. // Returns 0 if OK, \-1 if the endpoint was invalid or the function // isn\*(Aqt supported\&. CZMQ_EXPORT int zsock_unbind (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Connect a socket to a formatted endpoint // Returns 0 if OK, \-1 if the endpoint was invalid\&. CZMQ_EXPORT int zsock_connect (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, \-1 if the endpoint was invalid or the function // isn\*(Aqt supported\&. CZMQ_EXPORT int zsock_disconnect (zsock_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Attach a socket to zero or more endpoints\&. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // \*(Aq@\*(Aq (to bind the socket) or \*(Aq>\*(Aq (to connect the socket)\&. Returns 0 if all // endpoints were valid, or \-1 if there was a syntax error\&. If the endpoint // does not start with \*(Aq@\*(Aq or \*(Aq>\*(Aq, the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false)\&. CZMQ_EXPORT int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string\&. CZMQ_EXPORT const char * zsock_type_str (zsock_t *self); // Send a \*(Aqpicture\*(Aq message to the socket (or actor)\&. The picture is a // string that defines the type of each frame\&. This makes it easy to send // a complex multiframe message in one call\&. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero\-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe\&. Does not change or take ownership of // any arguments\&. Returns 0 if successful, \-1 if sending failed for any // reason\&. CZMQ_EXPORT int zsock_send (void *self, const char *picture, \&.\&.\&.); // Send a \*(Aqpicture\*(Aq message to the socket (or actor)\&. This is a va_list // version of zsock_send (), so please consult its documentation for the // details\&. CZMQ_EXPORT int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a \*(Aqpicture\*(Aq message to the socket (or actor)\&. See zsock_send for // the format and meaning of the picture\&. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32\-bit unsigned integer) // 8 = uint64_t * (stores 64\-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them\&. The supplied pointers do not need // to be initialized\&. Returns 0 if successful, or \-1 if it failed to recv // a message, in which case the pointers are not modified\&. When message // frames are truncated (a short message), sets return values to zero/null\&. // If an argument pointer is NULL, does not store any value (skips it)\&. // An \*(Aqn\*(Aq picture matches an empty frame; if the message does not match, // the method will return \-1\&. CZMQ_EXPORT int zsock_recv (void *self, const char *picture, \&.\&.\&.); // Receive a \*(Aqpicture\*(Aq message from the socket (or actor)\&. This is a // va_list version of zsock_recv (), so please consult its documentation // for the details\&. CZMQ_EXPORT int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded \*(Aqpicture\*(Aq message to the socket (or actor)\&. This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations\&. The pattern argument is a string that defines the // type of each argument\&. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0\-255 chars type = "string" // S char *, 0\-2^32\-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments\&. Returns 0 if // successful, \-1 if sending failed for any reason\&. CZMQ_EXPORT int zsock_bsend (void *self, const char *picture, \&.\&.\&.); // Receive a binary encoded \*(Aqpicture\*(Aq message from the socket (or actor)\&. // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations\&. The pattern argument is a string that defines // the type of each argument\&. See zsock_bsend for the supported argument // types\&. All arguments must be pointers; this call sets them to point to // values held on a per\-socket basis\&. Do not modify or destroy the returned // values\&. Returns 0 if successful, or \-1 if it failed to read a message\&. CZMQ_EXPORT int zsock_brecv (void *self, const char *picture, \&.\&.\&.); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory\&. This method works // across all versions of ZeroMQ\&. Takes a polymorphic socket reference\&. CZMQ_EXPORT void zsock_set_unbounded (void *self); // Send a signal over a socket\&. A signal is a short message carrying a // success/failure code (by convention, 0 means OK)\&. Signals are encoded // to be distinguishable from "normal" messages\&. Accepts a zock_t or a // zactor_t argument, and returns 0 if successful, \-1 if the signal could // not be sent\&. Takes a polymorphic socket reference\&. CZMQ_EXPORT int zsock_signal (void *self, byte status); // Wait on a signal\&. Use this to coordinate between threads, over pipe // pairs\&. Blocks until the signal is received\&. Returns \-1 on error, 0 or // greater on success\&. Accepts a zsock_t or a zactor_t as argument\&. // Takes a polymorphic socket reference\&. CZMQ_EXPORT int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it\&. This is useful when reading partial messages, to get specific // message types\&. CZMQ_EXPORT void zsock_flush (void *self); // Probe the supplied object, and report if it looks like a zsock_t\&. // Takes a polymorphic socket reference\&. CZMQ_EXPORT bool zsock_is (void *self); // Probe the supplied reference\&. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value\&. Takes a polymorphic socket reference\&. CZMQ_EXPORT void * zsock_resolve (void *self); // Self test of this class CZMQ_EXPORT void zsock_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction\&. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *\&. .sp Please add @discuss section in \&.\&./src/zsock\&.c\&. .SH "EXAMPLE" .PP \fBFrom zsock_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zsock_t *writer = zsock_new_push ("@tcp://127\&.0\&.0\&.1:5560"); assert (writer); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsock_unbind (writer, "tcp://127\&.0\&.0\&.1:%d", 5560); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error\&. // Even a short sleep allows the OS to release the port for reuse\&. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:%d", 5560); assert (rc == 5560); assert (streq (zsock_endpoint (writer), "tcp://127\&.0\&.0\&.1:5560")); #endif zsock_t *reader = zsock_new_pull (">tcp://127\&.0\&.0\&.1:5560"); assert (reader); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); // Basic Hello, World zstr_send (writer, "Hello, World"); zmsg_t *msg = zmsg_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); free (string); zmsg_destroy (&msg); // Test resolve FD SOCKET fd = zsock_fd (reader); assert (zsock_resolve ((void *) &fd) == NULL); // Test binding to ephemeral ports, sequential and random int port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*[50000\-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*[\-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:*[60000\-60050]"); assert (port >= 60000 && port <= 60050); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:![50000\-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:![\-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127\&.0\&.0\&.1:![60000\-60050]"); assert (port >= 60000 && port <= 60050); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127\&.0\&.0\&.1:5556,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == \-1); zsock_destroy (&server); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test\&.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test\&.writer")); // Test error state when connecting to an invalid socket type // (\*(Aqtxp://\*(Aq instead of \*(Aqtcp://\*(Aq, typo intentional) rc = zsock_connect (reader, "txp://127\&.0\&.0\&.1:5560"); assert (rc == \-1); // Test signal/wait methods rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); // Test zsock_send/recv pictures uint8_t number1 = 123; uint16_t number2 = 123 * 123; uint32_t number4 = 123 * 123 * 123; uint64_t number8 = 123 * 123 * 123 * 123; zchunk_t *chunk = zchunk_new ("HELLO", 5); assert (chunk); zframe_t *frame = zframe_new ("WORLD", 5); assert (frame); zhashx_t *hash = zhashx_new (); assert (hash); zuuid_t *uuid = zuuid_new (); assert (uuid); zhashx_autofree (hash); zhashx_insert (hash, "1", "value A"); zhashx_insert (hash, "2", "value B"); char *original = "pointer"; // Test zsock_recv into each supported type zsock_send (writer, "i1248zsbcfUhp", \-12345, number1, number2, number4, number8, "This is a string", "ABCDE", 5, chunk, frame, uuid, hash, original); char *uuid_str = strdup (zuuid_str (uuid)); zchunk_destroy (&chunk); zframe_destroy (&frame); zuuid_destroy (&uuid); zhashx_destroy (&hash); int integer; byte *data; size_t size; char *pointer; number8 = number4 = number2 = number1 = 0; rc = zsock_recv (reader, "i1248zsbcfUhp", &integer, &number1, &number2, &number4, &number8, &string, &data, &size, &chunk, &frame, &uuid, &hash, &pointer); assert (rc == 0); assert (integer == \-12345); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "This is a string")); assert (memcmp (data, "ABCDE", 5) == 0); assert (size == 5); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); assert (streq (uuid_str, zuuid_str (uuid))); assert (memcmp (zframe_data (frame), "WORLD", 5) == 0); assert (zframe_size (frame) == 5); char *value = (char *) zhashx_lookup (hash, "1"); assert (streq (value, "value A")); value = (char *) zhashx_lookup (hash, "2"); assert (streq (value, "value B")); assert (original == pointer); free (string); free (data); free (uuid_str); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); // Test zsock_recv of short message; this lets us return a failure // with a status code and then nothing else; the receiver will get // the status code and NULL/zero for all other values zsock_send (writer, "i", \-1); zsock_recv (reader, "izsbcfp", &integer, &string, &data, &size, &chunk, &frame, &pointer); assert (integer == \-1); assert (string == NULL); assert (data == NULL); assert (size == 0); assert (chunk == NULL); assert (frame == NULL); assert (pointer == NULL); msg = zmsg_new (); zmsg_addstr (msg, "frame 1"); zmsg_addstr (msg, "frame 2"); zsock_send (writer, "szm", "header", msg); zmsg_destroy (&msg); zsock_recv (reader, "szm", &string, &msg); assert (streq ("header", string)); assert (zmsg_size (msg) == 2); assert (zframe_streq (zmsg_first (msg), "frame 1")); assert (zframe_streq (zmsg_next (msg), "frame 2")); zstr_free (&string); zmsg_destroy (&msg); // Test zsock_recv with null arguments chunk = zchunk_new ("HELLO", 5); assert (chunk); frame = zframe_new ("WORLD", 5); assert (frame); zsock_send (writer, "izsbcfp", \-12345, "This is a string", "ABCDE", 5, chunk, frame, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL); assert (integer == \-12345); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); zchunk_destroy (&chunk); // Test zsock_bsend/brecv pictures with binary encoding frame = zframe_new ("Hello", 5); chunk = zchunk_new ("World", 5); msg = zmsg_new (); zmsg_addstr (msg, "Hello"); zmsg_addstr (msg, "World"); zsock_bsend (writer, "1248sSpcfm", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk, frame, msg); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); number8 = number4 = number2 = number1 = 0; char *longstr; zsock_brecv (reader, "1248sSpcfm", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk, &frame, &msg); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); zstr_free (&longstr); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); // Check that we can send a zproto format message zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234); zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_recv (gossip, reader); assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH); zgossip_msg_destroy (&gossip); zsock_destroy (&reader); zsock_destroy (&writer); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zcert.30000664000175000017500000001672312533132153013557 0ustar00phph00000000000000'\" t .\" Title: zcert .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZCERT" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zcert \- work with CURVE security certificates .SH "SYNOPSIS" .sp .nf // Create and initialize a new certificate in memory CZMQ_EXPORT zcert_t * zcert_new (void); // Constructor, accepts public/secret key pair from caller CZMQ_EXPORT zcert_t * zcert_new_from (byte *public_key, byte *secret_key); // Destroy a certificate in memory CZMQ_EXPORT void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32\-byte binary string CZMQ_EXPORT byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32\-byte binary string CZMQ_EXPORT byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string\&. CZMQ_EXPORT void zcert_set_meta (zcert_t *self, const char *name, const char *format, \&.\&.\&.); // Get metadata value from certificate; if the metadata value doesn\*(Aqt // exist, returns NULL\&. CZMQ_EXPORT char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate\&. Caller is responsible for // destroying list\&. Caller should not modify the values of list items\&. CZMQ_EXPORT zlist_t * zcert_meta_keys (zcert_t *self); // Load certificate from file (constructor) CZMQ_EXPORT zcert_t * zcert_load (const char *filename); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret")\&. CZMQ_EXPORT int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i\&.e\&. use for CURVE security on socket\&. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully\&. CZMQ_EXPORT void zcert_apply (zcert_t *self, void *zocket); // Return copy of certificate; if certificate is null or we exhausted // heap memory, returns null\&. CZMQ_EXPORT zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys CZMQ_EXPORT bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout CZMQ_EXPORT void zcert_print (zcert_t *self); // DEPRECATED as incompatible with centralized logging // Print certificate contents to open stream CZMQ_EXPORT void zcert_fprint (zcert_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcert_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism\&. A certificate contains a public + secret key pair, plus metadata\&. It can be used as a temporary object in memory, or persisted to disk\&. On disk, a certificate is stored as two files\&. One is public and contains only the public key\&. The second is secret and contains both keys\&. The two have the same filename, with the secret file adding "_secret"\&. To exchange certificates, send the public file via some secure route\&. Certificates are not signed but are text files that can be verified by eye\&. .sp Certificates are stored in the ZPL (ZMQ RFC 4) format\&. They have two sections, "metadata" and "curve"\&. The first contains a list of \fIname = value\fR pairs, one per line\&. Values may be enclosed in quotes\&. The curve section has a \fIpublic\-key = keyvalue\fR and, for secret certificates, a \fIsecret\-key = keyvalue\fR line\&. The keyvalue is a Z85\-encoded CURVE key\&. .SH "EXAMPLE" .PP \fBFrom zcert_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create temporary directory for test files # define TESTDIR "\&.test_zcert" zsys_dir_create (TESTDIR); // Create a simple certificate with metadata zcert_t *cert = zcert_new (); assert (cert); zcert_set_meta (cert, "email", "ph@imatix\&.com"); zcert_set_meta (cert, "name", "Pieter Hintjens"); zcert_set_meta (cert, "organization", "iMatix Corporation"); zcert_set_meta (cert, "version", "%d", 1); assert (streq (zcert_meta (cert, "email"), "ph@imatix\&.com")); zlist_t *keys = zcert_meta_keys (cert); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Check the dup and eq methods zcert_t *shadow = zcert_dup (cert); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Check we can save and load certificate zcert_save (cert, TESTDIR "/mycert\&.txt"); assert (zsys_file_exists (TESTDIR "/mycert\&.txt")); assert (zsys_file_exists (TESTDIR "/mycert\&.txt_secret")); // Load certificate, will in fact load secret one shadow = zcert_load (TESTDIR "/mycert\&.txt"); assert (shadow); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Delete secret certificate, load public one int rc = zsys_file_delete (TESTDIR "/mycert\&.txt_secret"); assert (rc == 0); shadow = zcert_load (TESTDIR "/mycert\&.txt"); // 32\-byte null key encodes as 40 \*(Aq0\*(Aq characters assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES)); zcert_destroy (&shadow); zcert_destroy (&cert); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zrex.txt0000664000175000017500000001163312533132136014071 0ustar00phph00000000000000zrex(3) ======= NAME ---- zrex - work with regular expressions SYNOPSIS -------- ---- // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. CZMQ_EXPORT zrex_t * zrex_new (const char *expression); // Destructor CZMQ_EXPORT void zrex_destroy (zrex_t **self_p); // Return true if the expression was valid and compiled without errors. CZMQ_EXPORT bool zrex_valid (zrex_t *self); // Return the error message generated during compilation of the expression. CZMQ_EXPORT const char * zrex_strerror (zrex_t *self); // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. CZMQ_EXPORT bool zrex_matches (zrex_t *self, const char *text); // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. CZMQ_EXPORT bool zrex_eq (zrex_t *self, const char *text, const char *expression); // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). CZMQ_EXPORT int zrex_hits (zrex_t *self); // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. CZMQ_EXPORT const char * zrex_hit (zrex_t *self, uint index); // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. CZMQ_EXPORT int zrex_fetch (zrex_t *self, const char **string_p, ...); // Self test of this class CZMQ_EXPORT void zrex_test (bool verbose); ---- DESCRIPTION ----------- Wraps a very simple regular expression library (SLRE) as a CZMQ class. Supports this syntax: ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ Please add @discuss section in ../src/zrex.c. EXAMPLE ------- .From zrex_test method ---- // This shows the pattern of matching many lines to a single pattern zrex_t *rex = zrex_new ("\\d+-\\d+-\\d+"); assert (rex); assert (zrex_valid (rex)); bool matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 1); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (zrex_hit (rex, 1) == NULL); zrex_destroy (&rex); // Here we pick out hits using capture groups rex = zrex_new ("(\\d+)-(\\d+)-(\\d+)"); assert (rex); assert (zrex_valid (rex)); matches = zrex_matches (rex, "123-456-ABC"); assert (!matches); matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 4); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (streq (zrex_hit (rex, 1), "123")); assert (streq (zrex_hit (rex, 2), "456")); assert (streq (zrex_hit (rex, 3), "789")); zrex_destroy (&rex); // This shows the pattern of matching one line against many // patterns and then handling the case when it hits rex = zrex_new (NULL); // No initial pattern assert (rex); char *input = "Mechanism: CURVE"; matches = zrex_eq (rex, input, "Version: (.+)"); assert (!matches); assert (zrex_hits (rex) == 0); matches = zrex_eq (rex, input, "Mechanism: (.+)"); assert (matches); assert (zrex_hits (rex) == 2); const char *mechanism; zrex_fetch (rex, &mechanism, NULL); assert (streq (zrex_hit (rex, 1), "CURVE")); assert (streq (mechanism, "CURVE")); zrex_destroy (&rex); ---- czmq-3.0.2/doc/zrex.30000664000175000017500000001600112533132170013404 0ustar00phph00000000000000'\" t .\" Title: zrex .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZREX" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zrex \- work with regular expressions .SH "SYNOPSIS" .sp .nf // Constructor\&. Optionally, sets an expression against which we can match // text and capture hits\&. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror()\&. If you // set a pattern, you can call zrex_matches() to test it against text\&. CZMQ_EXPORT zrex_t * zrex_new (const char *expression); // Destructor CZMQ_EXPORT void zrex_destroy (zrex_t **self_p); // Return true if the expression was valid and compiled without errors\&. CZMQ_EXPORT bool zrex_valid (zrex_t *self); // Return the error message generated during compilation of the expression\&. CZMQ_EXPORT const char * zrex_strerror (zrex_t *self); // Returns true if the text matches the previously compiled expression\&. // Use this method to compare one expression against many strings\&. CZMQ_EXPORT bool zrex_matches (zrex_t *self, const char *text); // Returns true if the text matches the supplied expression\&. Use this // method to compare one string against several expressions\&. CZMQ_EXPORT bool zrex_eq (zrex_t *self, const char *text, const char *expression); // Returns number of hits from last zrex_matches or zrex_eq\&. If the text // matched, returns 1 plus the number of capture groups\&. If the text did // not match, returns zero\&. To retrieve individual capture groups, call // zrex_hit ()\&. CZMQ_EXPORT int zrex_hits (zrex_t *self); // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits()\&. Capture group 0 is the // whole matching string\&. Sequence 1 is the first capture group, if any, // and so on\&. CZMQ_EXPORT const char * zrex_hit (zrex_t *self, uint index); // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index\&. Caller should not modify nor // free the returned values\&. Returns number of strings returned\&. This // method starts at hit 1, i\&.e\&. first capture group, as hit 0 is always // the original matched string\&. CZMQ_EXPORT int zrex_fetch (zrex_t *self, const char **string_p, \&.\&.\&.); // Self test of this class CZMQ_EXPORT void zrex_test (bool verbose); .fi .SH "DESCRIPTION" .sp Wraps a very simple regular expression library (SLRE) as a CZMQ class\&. Supports this syntax: .sp .if n \{\ .RS 4 .\} .nf ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [\&.\&.\&.] Match any character from set [^\&.\&.\&.] Match any character but ones from set \&. Match any character \es Match whitespace \eS Match non\-whitespace \ed Match decimal digit \eD Match non decimal digit \ea Match alphabetic character \eA Match non\-alphabetic character \ew Match alphanumeric character \eW Match non\-alphanumeric character \er Match carriage return \en Match newline + Match one or more times (greedy) +? Match one or more times (non\-greedy) * Match zero or more times (greedy) *? Match zero or more times (non\-greedy) ? Match zero or once \exDD Match byte with hex value 0xDD \emeta Match one of the meta character: ^$()\&.[*+?\e .fi .if n \{\ .RE .\} .sp Please add @discuss section in \&.\&./src/zrex\&.c\&. .SH "EXAMPLE" .PP \fBFrom zrex_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // This shows the pattern of matching many lines to a single pattern zrex_t *rex = zrex_new ("\e\ed+\-\e\ed+\-\e\ed+"); assert (rex); assert (zrex_valid (rex)); bool matches = zrex_matches (rex, "123\-456\-789"); assert (matches); assert (zrex_hits (rex) == 1); assert (streq (zrex_hit (rex, 0), "123\-456\-789")); assert (zrex_hit (rex, 1) == NULL); zrex_destroy (&rex); // Here we pick out hits using capture groups rex = zrex_new ("(\e\ed+)\-(\e\ed+)\-(\e\ed+)"); assert (rex); assert (zrex_valid (rex)); matches = zrex_matches (rex, "123\-456\-ABC"); assert (!matches); matches = zrex_matches (rex, "123\-456\-789"); assert (matches); assert (zrex_hits (rex) == 4); assert (streq (zrex_hit (rex, 0), "123\-456\-789")); assert (streq (zrex_hit (rex, 1), "123")); assert (streq (zrex_hit (rex, 2), "456")); assert (streq (zrex_hit (rex, 3), "789")); zrex_destroy (&rex); // This shows the pattern of matching one line against many // patterns and then handling the case when it hits rex = zrex_new (NULL); // No initial pattern assert (rex); char *input = "Mechanism: CURVE"; matches = zrex_eq (rex, input, "Version: (\&.+)"); assert (!matches); assert (zrex_hits (rex) == 0); matches = zrex_eq (rex, input, "Mechanism: (\&.+)"); assert (matches); assert (zrex_hits (rex) == 2); const char *mechanism; zrex_fetch (rex, &mechanism, NULL); assert (streq (zrex_hit (rex, 1), "CURVE")); assert (streq (mechanism, "CURVE")); zrex_destroy (&rex); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zchunk.30000664000175000017500000002134612533132153013727 0ustar00phph00000000000000'\" t .\" Title: zchunk .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZCHUNK" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zchunk \- work with memory chunks .SH "SYNOPSIS" .sp .nf // Create a new chunk of the specified size\&. If you specify the data, it // is copied into the chunk\&. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append\&. CZMQ_EXPORT zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk CZMQ_EXPORT void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero CZMQ_EXPORT void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size CZMQ_EXPORT size_t zchunk_size (zchunk_t *self); // Return chunk max size CZMQ_EXPORT size_t zchunk_max_size (zchunk_t *self); // Return chunk data CZMQ_EXPORT byte * zchunk_data (zchunk_t *self); // Set chunk data from user\-supplied data; truncate if too large\&. Data may // be null\&. Returns actual size of chunk CZMQ_EXPORT size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user\-supplied octet CZMQ_EXPORT size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user\-supplied data to chunk, return resulting chunk size\&. If the // data would exceeed the available space, it is truncated\&. If you want to // grow the chunk to accomodate new data, use the zchunk_extend method\&. CZMQ_EXPORT size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user\-supplied data to chunk, return resulting chunk size\&. If the // data would exceeed the available space, the chunk grows in size\&. CZMQ_EXPORT size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from \*(Aqsource\*(Aq into the chunk as possible; returns the // new size of chunk\&. If all data from \*(Aqsource\*(Aq is used, returns exhausted // on the source chunk\&. Source can be consumed as many times as needed until // it is exhausted\&. If source was already exhausted, does not change chunk\&. CZMQ_EXPORT size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero\&. CZMQ_EXPORT bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor CZMQ_EXPORT zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor CZMQ_EXPORT int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk\&. Will read up to maxsize of // the file\&. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory\&. Returns a new // chunk containing the file data, or NULL if the file could not be read\&. CZMQ_EXPORT zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object\&. Returns a fresh zchunk_t // object, or null if there was not enough heap memory\&. If chunk is null, // returns null\&. CZMQ_EXPORT zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string\&. Caller must free // string when finished with it\&. CZMQ_EXPORT char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it\&. CZMQ_EXPORT char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator CZMQ_EXPORT bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message\&. CZMQ_EXPORT zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk\&. CZMQ_EXPORT zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class\&. CZMQ_EXPORT const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing\&. CZMQ_EXPORT void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing\&. // See zchunk_fprint for details CZMQ_EXPORT void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t\&. CZMQ_EXPORT bool zchunk_is (void *self); // Self test of this class CZMQ_EXPORT void zchunk_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zchunk class works with variable sized blobs\&. Not as efficient as MQ\(cqs messages but they do less weirdness and so are easier to understand\&. The chunk class has methods to read and write chunks from disk\&. .sp Please add @discuss section in \&.\&./src/zchunk\&.c\&. .SH "EXAMPLE" .PP \fBFrom zchunk_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zchunk_t *chunk = zchunk_new ("1234567890", 10); assert (chunk); assert (zchunk_size (chunk) == 10); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 10); assert (chunk); zchunk_append (chunk, "12345678", 8); zchunk_append (chunk, "90ABCDEF", 8); zchunk_append (chunk, "GHIJKLMN", 8); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); assert (zchunk_size (chunk) == 10); assert (zchunk_streq (chunk, "1234567890")); assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A")); char *string = zchunk_strdup (chunk); assert (streq (string, "1234567890")); free (string); string = zchunk_strhex (chunk); assert (streq (string, "31323334353637383930")); free (string); zframe_t *frame = zchunk_pack (chunk); assert (frame); zchunk_t *chunk2 = zchunk_unpack (frame); assert (chunk2); assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0); zframe_destroy (&frame); zchunk_destroy (&chunk2); zchunk_t *copy = zchunk_dup (chunk); assert (copy); assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0); assert (zchunk_size (copy) == 10); zchunk_destroy (©); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 0); zchunk_extend (chunk, "12345678", 8); zchunk_extend (chunk, "90ABCDEF", 8); zchunk_extend (chunk, "GHIJKLMN", 8); assert (zchunk_size (chunk) == 24); assert (zchunk_streq (chunk, "1234567890ABCDEFGHIJKLMN")); zchunk_destroy (&chunk); copy = zchunk_new ("1234567890abcdefghij", 20); assert (copy); chunk = zchunk_new (NULL, 8); assert (chunk); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (zchunk_exhausted (copy)); assert (zchunk_size (chunk) == 4); assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0); zchunk_destroy (©); zchunk_destroy (&chunk); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zactor.txt0000664000175000017500000000536612533132136014411 0ustar00phph00000000000000zactor(3) ========= NAME ---- zactor - simple actor framework SYNOPSIS -------- ---- // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Create a new actor passing arbitrary arguments reference. CZMQ_EXPORT zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. CZMQ_EXPORT void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. CZMQ_EXPORT int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. CZMQ_EXPORT bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. CZMQ_EXPORT void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. CZMQ_EXPORT zsock_t * zactor_sock (zactor_t *self); // Self test of this class. CZMQ_EXPORT void zactor_test (bool verbose); ---- DESCRIPTION ----------- The zactor class provides a simple actor framework. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard. A CZMQ actor is implemented as a thread plus a PAIR-PAIR pipe. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished.) A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, and zpoller. (zloop somehow escaped and needs catching.) An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command. Please add @discuss section in ../src/zactor.c. EXAMPLE ------- .From zactor_test method ---- zactor_t *actor = zactor_new (echo_actor, "Hello, World"); assert (actor); zstr_sendx (actor, "ECHO", "This is a string", NULL); char *string = zstr_recv (actor); assert (streq (string, "This is a string")); free (string); zactor_destroy (&actor); ---- czmq-3.0.2/doc/ziflist.txt0000664000175000017500000000454412533132136014570 0ustar00phph00000000000000ziflist(3) ========== NAME ---- ziflist - List of network interfaces available on system SYNOPSIS -------- ---- // Get a list of network interfaces currently defined on the system CZMQ_EXPORT ziflist_t * ziflist_new (); // Destroy a ziflist instance CZMQ_EXPORT void ziflist_destroy (ziflist_t **self_p); // Print properties of the ziflist object. CZMQ_EXPORT void ziflist_print (ziflist_t *self); // Reload network interfaces from system CZMQ_EXPORT void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system CZMQ_EXPORT size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none CZMQ_EXPORT const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one CZMQ_EXPORT const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string CZMQ_EXPORT const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string CZMQ_EXPORT const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string CZMQ_EXPORT const char * ziflist_netmask (ziflist_t *self); // Self test of this class. CZMQ_EXPORT void ziflist_test (bool verbose); ---- DESCRIPTION ----------- The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices). The caller can then access the network interface information using an iterator that works like zlistx. Only stores those interfaces with broadcast capability, and ignores the loopback interface. Please add @discuss section in ../src/ziflist.c. EXAMPLE ------- .From ziflist_test method ---- ziflist_t *iflist = ziflist_new (); assert (iflist); size_t items = ziflist_size (iflist); if (verbose) { // printf ("ziflist: interfaces=%zu\n", ziflist_size (iflist)); const char *name = ziflist_first (iflist); while (name) { printf (" - name=%s address=%s netmask=%s broadcast=%s\n", name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist)); name = ziflist_next (iflist); } } ziflist_reload (iflist); assert (items == ziflist_size (iflist)); ziflist_destroy (&iflist); ---- czmq-3.0.2/doc/zloop.30000664000175000017500000002335312533132163013571 0ustar00phph00000000000000'\" t .\" Title: zloop .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZLOOP" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zloop \- event\-driven reactor .SH "SYNOPSIS" .sp .nf // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low\-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Create a new zloop reactor CZMQ_EXPORT zloop_t * zloop_new (); // Destroy a reactor CZMQ_EXPORT void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor\&. When the reader has messages, // the reactor will call the handler, passing the arg\&. Returns 0 if OK, \-1 // if there was an error\&. If you register the same socket more than once, // each instance will invoke its corresponding handler\&. CZMQ_EXPORT int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor\&. If multiple readers exist for // same socket, cancels ALL of them\&. CZMQ_EXPORT void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors\&. If you do not set this, // then readers that have errors are removed from the reactor silently\&. CZMQ_EXPORT void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low\-level libzmq pollitem with the reactor\&. When the pollitem // is ready, will call the handler, passing the arg\&. Returns 0 if OK, \-1 // if there was an error\&. If you register the pollitem more than once, each // instance will invoke its corresponding handler\&. A pollitem with // socket=NULL and fd=0 means \*(Aqpoll on FD zero\*(Aq\&. CZMQ_EXPORT int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD\&. If both // are specified, uses only socket\&. If multiple poll items exist for same // socket/FD, cancels ALL of them\&. CZMQ_EXPORT void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors\&. If you do not set this, // then poller that have errors are removed from the reactor silently\&. CZMQ_EXPORT void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times\&. At each expiry, will call the handler, passing the arg\&. To run a // timer forever, use 0 times\&. Returns a timer_id that is used to cancel the // timer in the future\&. Returns \-1 if there was an error\&. CZMQ_EXPORT int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer)\&. CZMQ_EXPORT int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer\&. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them\&. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client\&. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients\&. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket\&. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete\&. CZMQ_EXPORT void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time\&. This is a very fast operation\&. CZMQ_EXPORT void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer\&. We do not actually delete the ticket here, as // other code may still refer to the ticket\&. We mark as deleted, and remove // later and safely\&. CZMQ_EXPORT void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets\&. If you lower the // delay and there are already tickets created, the results are undefined\&. CZMQ_EXPORT void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed\&. Setting more than a small // number of timers (10\-100) can have a dramatic impact on the performance // of the reactor\&. For high\-volume cases, use ticket timers\&. If the hard // limit is reached, the reactor stops creating new timers and logs an // error\&. CZMQ_EXPORT void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off CZMQ_EXPORT void zloop_set_verbose (zloop_t *self, bool verbose); // Start the reactor\&. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns \-1\&. Event handlers may register new sockets and timers, and // cancel sockets\&. Returns 0 if interrupted, \-1 if cancelled by a handler\&. CZMQ_EXPORT int zloop_start (zloop_t *self); // Ignore zsys_interrupted flag in this loop\&. By default, a zloop_start will // exit as soon as it detects zsys_interrupted is set to something other than // zero\&. Calling zloop_ignore_interrupts will supress this behavior\&. CZMQ_EXPORT void zloop_ignore_interrupts (zloop_t *self); // Self test of this class CZMQ_EXPORT void zloop_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zloop class provides an event\-driven reactor pattern\&. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once\-off or repeated timers\&. Its resolution is 1 msec\&. It uses a tickless timer to reduce CPU interrupts in inactive processes\&. .sp Please add @discuss section in \&.\&./src/zloop\&.c\&. .SH "EXAMPLE" .PP \fBFrom zloop_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); zsock_bind (output, "inproc://zloop\&.test"); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); zsock_connect (input, "inproc://zloop\&.test"); zloop_t *loop = zloop_new (); assert (loop); zloop_set_verbose (loop, verbose); // Create a timer that will be cancelled int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL); zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id); // After 20 msecs, send a ping message to output3 zloop_timer (loop, 20, 1, s_timer_event, output); // Set up some tickets that will never expire zloop_set_ticket_delay (loop, 10000); void *ticket1 = zloop_ticket (loop, s_timer_event, NULL); void *ticket2 = zloop_ticket (loop, s_timer_event, NULL); void *ticket3 = zloop_ticket (loop, s_timer_event, NULL); // When we get the ping message, end the reactor rc = zloop_reader (loop, input, s_socket_event, NULL); assert (rc == 0); zloop_reader_set_tolerant (loop, input); zloop_start (loop); zloop_ticket_delete (loop, ticket1); zloop_ticket_delete (loop, ticket2); zloop_ticket_delete (loop, ticket3); // Check whether loop properly ignores zsys_interrupted flag // when asked to zloop_destroy (&loop); loop = zloop_new (); bool timer_event_called = false; zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called); zsys_interrupted = 1; zloop_start (loop); // zloop returns immediately without giving any handler a chance to run assert (!timer_event_called); zloop_ignore_interrupts (loop); zloop_start (loop); // zloop runs the handler which will terminate the loop assert (timer_event_called); zsys_interrupted = 0; // cleanup zloop_destroy (&loop); assert (loop == NULL); zsock_destroy (&input); zsock_destroy (&output); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zbeacon_v2.30000664000175000017500000001710712533132172014456 0ustar00phph00000000000000'\" t .\" Title: zbeacon_v2 .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZBEACON_V2" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zbeacon_v2 \- LAN discovery and presence (deprecated) .SH "SYNOPSIS" .sp .nf // Create a new beacon on a certain UDP port\&. If the system does not // support UDP broadcasts (lacking a useful interface), returns NULL\&. // To force the beacon to operate on a given port, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() beforehand\&. // If you are using the new zsock API then pass NULL as the ctx here\&. CZMQ_EXPORT zbeacon_t * zbeacon_new (zctx_t *ctx, int port_nbr); // Destroy a beacon CZMQ_EXPORT void zbeacon_destroy (zbeacon_t **self_p); // Return our own IP address as printable string CZMQ_EXPORT char * zbeacon_hostname (zbeacon_t *self); // Set broadcast interval in milliseconds (default is 1000 msec) CZMQ_EXPORT void zbeacon_set_interval (zbeacon_t *self, int interval); // Filter out any beacon that looks exactly like ours CZMQ_EXPORT void zbeacon_noecho (zbeacon_t *self); // Start broadcasting beacon to peers at the specified interval CZMQ_EXPORT void zbeacon_publish (zbeacon_t *self, byte *transmit, size_t size); // Stop broadcasting beacons CZMQ_EXPORT void zbeacon_silence (zbeacon_t *self); // Start listening to other peers; zero\-sized filter means get everything CZMQ_EXPORT void zbeacon_subscribe (zbeacon_t *self, byte *filter, size_t size); // Stop listening to other peers CZMQ_EXPORT void zbeacon_unsubscribe (zbeacon_t *self); // Get beacon ZeroMQ socket, for polling or receiving messages CZMQ_EXPORT void * zbeacon_socket (zbeacon_t *self); // Self test of this class CZMQ_EXPORT void zbeacon_v2_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zbeacon class implements a peer\-to\-peer discovery service for local networks\&. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network\&. This implementation uses IPv4 UDP broadcasts\&. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons\&. Beacons are sent and received asynchronously in the background\&. The zbeacon API provides a incoming beacons on a ZeroMQ socket (the pipe) that you can configure, poll on, and receive messages on\&. Incoming beacons are always delivered as two frames: the ipaddress of the sender (a string), and the beacon data itself (binary, as published)\&. .sp This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes\&. New applications should use the V3 zauth interface, based on zactor, together with the zsock class for sockets\&. .SH "EXAMPLE" .PP \fBFrom zbeacon_v2_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create beacon to broadcast our service zctx_t *ctx = zctx_new (); assert (ctx); zbeacon_t *service_beacon = zbeacon_new (ctx, 9999); if (service_beacon == NULL) { printf ("OK (skipping test, no UDP discovery)\en"); return; } // Create a service socket and bind to an ephemeral port zsock_t *service = zsock_new (ZMQ_PUB); assert (service); int port_nbr = zsock_bind (service, "tcp://127\&.0\&.0\&.1:*"); byte announcement [2] = { (port_nbr >> 8) & 0xFF, port_nbr & 0xFF }; zbeacon_set_interval (service_beacon, 100); zbeacon_publish (service_beacon, announcement, 2); // Create beacon to lookup service zbeacon_t *client_beacon = zbeacon_new (ctx, 9999); assert (client_beacon); zbeacon_subscribe (client_beacon, NULL, 0); // Wait for at most 1/2 second if there\*(Aqs no broadcast networking zsocket_set_rcvtimeo (zbeacon_socket (client_beacon), 500); char *ipaddress = zstr_recv (zbeacon_socket (client_beacon)); if (ipaddress) { zframe_t *content = zframe_recv (zbeacon_socket (client_beacon)); int received_port = (zframe_data (content) [0] << 8) + zframe_data (content) [1]; assert (received_port == port_nbr); zframe_destroy (&content); zbeacon_silence (service_beacon); zstr_free (&ipaddress); } zbeacon_destroy (&client_beacon); zbeacon_destroy (&service_beacon); zbeacon_t *node1 = zbeacon_new (ctx, 5670); assert (node1); zbeacon_t *node2 = zbeacon_new (ctx, 5670); assert (node2); zbeacon_t *node3 = zbeacon_new (ctx, 5670); assert (node3); assert (*zbeacon_hostname (node1)); assert (*zbeacon_hostname (node2)); assert (*zbeacon_hostname (node3)); zbeacon_set_interval (node1, 250); zbeacon_set_interval (node2, 250); zbeacon_set_interval (node3, 250); zbeacon_noecho (node1); zbeacon_publish (node1, (byte *) "NODE/1", 6); zbeacon_publish (node2, (byte *) "NODE/2", 6); zbeacon_publish (node3, (byte *) "GARBAGE", 7); zbeacon_subscribe (node1, (byte *) "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new ( zbeacon_socket (node1), zbeacon_socket (node2), zbeacon_socket (node3), NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at \- zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == zbeacon_socket (node1)); char *ipaddress, *beacon; zstr_recvx (zbeacon_socket (node1), &ipaddress, &beacon, NULL); assert (streq (beacon, "NODE/2")); zstr_free (&ipaddress); zstr_free (&beacon); } } zpoller_destroy (&poller); // Stop listening zbeacon_unsubscribe (node1); // Stop all node broadcasts zbeacon_silence (node1); zbeacon_silence (node2); zbeacon_silence (node3); // Destroy the test nodes zbeacon_destroy (&node1); zbeacon_destroy (&node2); zbeacon_destroy (&node3); zsock_destroy (&service); zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zcert.txt0000664000175000017500000001252712533132136014233 0ustar00phph00000000000000zcert(3) ======== NAME ---- zcert - work with CURVE security certificates SYNOPSIS -------- ---- // Create and initialize a new certificate in memory CZMQ_EXPORT zcert_t * zcert_new (void); // Constructor, accepts public/secret key pair from caller CZMQ_EXPORT zcert_t * zcert_new_from (byte *public_key, byte *secret_key); // Destroy a certificate in memory CZMQ_EXPORT void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string CZMQ_EXPORT byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string CZMQ_EXPORT byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. CZMQ_EXPORT void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. CZMQ_EXPORT char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. CZMQ_EXPORT zlist_t * zcert_meta_keys (zcert_t *self); // Load certificate from file (constructor) CZMQ_EXPORT zcert_t * zcert_load (const char *filename); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). CZMQ_EXPORT int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. CZMQ_EXPORT void zcert_apply (zcert_t *self, void *zocket); // Return copy of certificate; if certificate is null or we exhausted // heap memory, returns null. CZMQ_EXPORT zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys CZMQ_EXPORT bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout CZMQ_EXPORT void zcert_print (zcert_t *self); // DEPRECATED as incompatible with centralized logging // Print certificate contents to open stream CZMQ_EXPORT void zcert_fprint (zcert_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcert_test (bool verbose); ---- DESCRIPTION ----------- The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism. A certificate contains a public + secret key pair, plus metadata. It can be used as a temporary object in memory, or persisted to disk. On disk, a certificate is stored as two files. One is public and contains only the public key. The second is secret and contains both keys. The two have the same filename, with the secret file adding "_secret". To exchange certificates, send the public file via some secure route. Certificates are not signed but are text files that can be verified by eye. Certificates are stored in the ZPL (ZMQ RFC 4) format. They have two sections, "metadata" and "curve". The first contains a list of 'name = value' pairs, one per line. Values may be enclosed in quotes. The curve section has a 'public-key = keyvalue' and, for secret certificates, a 'secret-key = keyvalue' line. The keyvalue is a Z85-encoded CURVE key. EXAMPLE ------- .From zcert_test method ---- // Create temporary directory for test files # define TESTDIR ".test_zcert" zsys_dir_create (TESTDIR); // Create a simple certificate with metadata zcert_t *cert = zcert_new (); assert (cert); zcert_set_meta (cert, "email", "ph@imatix.com"); zcert_set_meta (cert, "name", "Pieter Hintjens"); zcert_set_meta (cert, "organization", "iMatix Corporation"); zcert_set_meta (cert, "version", "%d", 1); assert (streq (zcert_meta (cert, "email"), "ph@imatix.com")); zlist_t *keys = zcert_meta_keys (cert); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Check the dup and eq methods zcert_t *shadow = zcert_dup (cert); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Check we can save and load certificate zcert_save (cert, TESTDIR "/mycert.txt"); assert (zsys_file_exists (TESTDIR "/mycert.txt")); assert (zsys_file_exists (TESTDIR "/mycert.txt_secret")); // Load certificate, will in fact load secret one shadow = zcert_load (TESTDIR "/mycert.txt"); assert (shadow); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Delete secret certificate, load public one int rc = zsys_file_delete (TESTDIR "/mycert.txt_secret"); assert (rc == 0); shadow = zcert_load (TESTDIR "/mycert.txt"); // 32-byte null key encodes as 40 '0' characters assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES)); zcert_destroy (&shadow); zcert_destroy (&cert); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); ---- czmq-3.0.2/doc/zmonitor_v2.txt0000664000175000017500000000526512533132136015375 0ustar00phph00000000000000zmonitor_v2(3) ============== NAME ---- zmonitor_v2 - socket event monitor (deprecated) SYNOPSIS -------- ---- // This code needs backporting to work with ZMQ v3.2 #if (ZMQ_VERSION_MAJOR == 4) // Create a new socket monitor CZMQ_EXPORT zmonitor_t * zmonitor_new (zctx_t *ctx, void *socket, int events); // Destroy a socket monitor CZMQ_EXPORT void zmonitor_destroy (zmonitor_t **self_p); // Receive a status message from the monitor; if no message arrives within // 500 msec, or the call was interrupted, returns NULL. CZMQ_EXPORT zmsg_t * zmonitor_recv (zmonitor_t *self); // Get the ZeroMQ socket, for polling CZMQ_EXPORT void * zmonitor_socket (zmonitor_t *self); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zmonitor_set_verbose (zmonitor_t *self, bool verbose); #endif // ZeroMQ 4.0 or later // Self test of this class CZMQ_EXPORT void zmonitor_v2_test (bool verbose); ---- DESCRIPTION ----------- The zmonitor class provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Currently this class requires libzmq v4.0 or later and is empty on older versions of libzmq. This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes. New applications should use the V3 zmonitor interface, based on zactor, together with the zsock class for sockets. EXAMPLE ------- .From zmonitor_v2_test method ---- zctx_t *ctx = zctx_new (); assert (ctx); bool result; void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); zmonitor_t *sinkmon = zmonitor_new (ctx, sink, ZMQ_EVENT_LISTENING | ZMQ_EVENT_ACCEPTED); assert (sinkmon); zmonitor_set_verbose (sinkmon, verbose); // Check sink is now listening int port_nbr = zsocket_bind (sink, "tcp://127.0.0.1:*"); assert (port_nbr != -1); result = s_check_event (sinkmon, ZMQ_EVENT_LISTENING); assert (result); void *source = zsocket_new (ctx, ZMQ_PUSH); assert (source); zmonitor_t *sourcemon = zmonitor_new (ctx, source, ZMQ_EVENT_CONNECTED | ZMQ_EVENT_DISCONNECTED); assert (sourcemon); zmonitor_set_verbose (sourcemon, verbose); zsocket_connect (source, "tcp://127.0.0.1:%d", port_nbr); // Check source connected to sink result = s_check_event (sourcemon, ZMQ_EVENT_CONNECTED); assert (result); // Check sink accepted connection result = s_check_event (sinkmon, ZMQ_EVENT_ACCEPTED); assert (result); zmonitor_destroy (&sinkmon); zmonitor_destroy (&sourcemon); zctx_destroy (&ctx); ---- czmq-3.0.2/doc/zsock_option.txt0000664000175000017500000007535612533132136015636 0ustar00phph00000000000000zsock_option(3) =============== NAME ---- zsock_option - get/set 0MQ socket options SYNOPSIS -------- ---- #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsock_tos (void *self); CZMQ_EXPORT char * zsock_zap_domain (void *self); CZMQ_EXPORT int zsock_mechanism (void *self); CZMQ_EXPORT int zsock_plain_server (void *self); CZMQ_EXPORT char * zsock_plain_username (void *self); CZMQ_EXPORT char * zsock_plain_password (void *self); CZMQ_EXPORT int zsock_curve_server (void *self); CZMQ_EXPORT char * zsock_curve_publickey (void *self); CZMQ_EXPORT char * zsock_curve_secretkey (void *self); CZMQ_EXPORT char * zsock_curve_serverkey (void *self); CZMQ_EXPORT int zsock_gssapi_server (void *self); CZMQ_EXPORT int zsock_gssapi_plaintext (void *self); CZMQ_EXPORT char * zsock_gssapi_principal (void *self); CZMQ_EXPORT char * zsock_gssapi_service_principal (void *self); CZMQ_EXPORT int zsock_ipv6 (void *self); CZMQ_EXPORT int zsock_immediate (void *self); CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_tos (void *self, int tos); CZMQ_EXPORT void zsock_set_router_handover (void *self, int router_handover); CZMQ_EXPORT void zsock_set_router_mandatory (void *self, int router_mandatory); CZMQ_EXPORT void zsock_set_probe_router (void *self, int probe_router); CZMQ_EXPORT void zsock_set_req_relaxed (void *self, int req_relaxed); CZMQ_EXPORT void zsock_set_req_correlate (void *self, int req_correlate); CZMQ_EXPORT void zsock_set_conflate (void *self, int conflate); CZMQ_EXPORT void zsock_set_zap_domain (void *self, const char * zap_domain); CZMQ_EXPORT void zsock_set_plain_server (void *self, int plain_server); CZMQ_EXPORT void zsock_set_plain_username (void *self, const char * plain_username); CZMQ_EXPORT void zsock_set_plain_password (void *self, const char * plain_password); CZMQ_EXPORT void zsock_set_curve_server (void *self, int curve_server); CZMQ_EXPORT void zsock_set_curve_publickey (void *self, const char * curve_publickey); CZMQ_EXPORT void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); CZMQ_EXPORT void zsock_set_curve_secretkey (void *self, const char * curve_secretkey); CZMQ_EXPORT void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); CZMQ_EXPORT void zsock_set_curve_serverkey (void *self, const char * curve_serverkey); CZMQ_EXPORT void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); CZMQ_EXPORT void zsock_set_gssapi_server (void *self, int gssapi_server); CZMQ_EXPORT void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); CZMQ_EXPORT void zsock_set_gssapi_principal (void *self, const char * gssapi_principal); CZMQ_EXPORT void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal); CZMQ_EXPORT void zsock_set_ipv6 (void *self, int ipv6); CZMQ_EXPORT void zsock_set_immediate (void *self, int immediate); CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsock_hwm (void *self); CZMQ_EXPORT int zsock_swap (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_recovery_ivl_msec (void *self); CZMQ_EXPORT int zsock_mcast_loop (void *self); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_rcvtimeo (void *self); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_sndtimeo (void *self); # endif CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); // Set socket options CZMQ_EXPORT void zsock_set_hwm (void *self, int hwm); CZMQ_EXPORT void zsock_set_swap (void *self, int swap); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); CZMQ_EXPORT void zsock_set_mcast_loop (void *self, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); # endif CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsock_option_test (bool verbose); ---- DESCRIPTION ----------- The zsock_option class provides access to the 0MQ getsockopt/setsockopt API. All methods in this class take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_r reference, or a libzmq void *. This class is generated, using the GSL code generator. See the sockopts XML file, which provides the metadata, and the sock_option.gsl template, which does the work. EXAMPLE ------- .From zsock_option_test method ---- zsock_t *self; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_tos (self, 1); assert (zsock_tos (self) == 1); zsock_tos (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_HANDOVER) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_handover (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_MANDATORY) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_mandatory (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_PROBE_ROUTER) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_probe_router (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_RELAXED) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_relaxed (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_CORRELATE) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_correlate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONFLATE) self = zsock_new (ZMQ_PUSH); assert (self); zsock_set_conflate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ZAP_DOMAIN) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_zap_domain (self, "test"); char *zap_domain = zsock_zap_domain (self); assert (zap_domain); free (zap_domain); zsock_destroy (&self); # endif # if defined (ZMQ_MECHANISM) self = zsock_new (ZMQ_SUB); assert (self); zsock_mechanism (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_SERVER) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_plain_server (self, 1); assert (zsock_plain_server (self) == 1); zsock_plain_server (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_USERNAME) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_username (self, "test"); char *plain_username = zsock_plain_username (self); assert (plain_username); free (plain_username); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_PASSWORD) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_password (self, "test"); char *plain_password = zsock_plain_password (self); assert (plain_password); free (plain_password); zsock_destroy (&self); # endif # if defined (ZMQ_IPV6) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv6 (self, 1); assert (zsock_ipv6 (self) == 1); zsock_ipv6 (self); zsock_destroy (&self); # endif # if defined (ZMQ_IMMEDIATE) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_immediate (self, 1); assert (zsock_immediate (self) == 1); zsock_immediate (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); free (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); free (last_endpoint); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_hwm (self, 1); assert (zsock_hwm (self) == 1); zsock_hwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_SWAP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_swap (self, 1); assert (zsock_swap (self) == 1); zsock_swap (self); zsock_destroy (&self); # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); free (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl_msec (self, 1); assert (zsock_recovery_ivl_msec (self) == 1); zsock_recovery_ivl_msec (self); zsock_destroy (&self); # endif # if defined (ZMQ_MCAST_LOOP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_mcast_loop (self, 1); assert (zsock_mcast_loop (self) == 1); zsock_mcast_loop (self); zsock_destroy (&self); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif #endif ---- czmq-3.0.2/doc/zhash.txt0000664000175000017500000003204412533132136014215 0ustar00phph00000000000000zhash(3) ======== NAME ---- zhash - simple generic hash container SYNOPSIS -------- ---- // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // DEPRECATED as clumsy -- use zhash_first/_next instead typedef int (zhash_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhash_t * zhash_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhash_destroy (zhash_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. CZMQ_EXPORT void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null CZMQ_EXPORT void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhash_comment (zhash_t *self, const char *format, ...) CHECK_PRINTF (2); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zhash_pack (zhash_t *self); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhash_t * zhash_unpack (zframe_t *frame); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction CZMQ_EXPORT void zhash_autofree (zhash_t *self); // DEPRECATED as clumsy -- use zhash_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). // Callback function for zhash_foreach method CZMQ_EXPORT int zhash_foreach (zhash_t *self, zhash_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhash_test (int verbose); ---- DESCRIPTION ----------- zhash is an expandable hash table container. This is a simple container. For heavy-duty applications we recommend using zhashx. Note that it's relatively slow (~50K insertions/deletes per second), so don't do inserts/updates on the critical path for message I/O. It can do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU. EXAMPLE ------- .From zhash_test method ---- zhash_t *hash = zhash_new (); assert (hash); assert (zhash_size (hash) == 0); assert (zhash_first (hash) == NULL); assert (zhash_cursor (hash) == NULL); // Insert some items int rc; rc = zhash_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhash_first (hash); assert (streq (zhash_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhash_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhash_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhash_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhash_size (hash) == 4); // Look for existing items item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhash_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhash_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhash_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhash_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhash_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlist_t *keys = zhash_keys (hash); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Test dup method zhash_t *copy = zhash_dup (hash); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test pack/unpack methods zframe_t *frame = zhash_pack (hash); copy = zhash_unpack (frame); zframe_destroy (&frame); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test save and load zhash_comment (hash, "This is a test file"); zhash_comment (hash, "Created by %s", "czmq_selftest"); zhash_save (hash, ".cache"); copy = zhash_new (); assert (copy); zhash_load (copy, ".cache"); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); zsys_file_delete (".cache"); // Delete a item zhash_delete (hash, "LIVEBEEF"); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhash_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr].exists) { item = (char *) zhash_lookup (hash, testset [testnbr].name); assert (item); zhash_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhash_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhash_destroy (&hash); zhash_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhash_new (); assert (hash); zhash_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhash_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Inserting with the same key will fail"); rc = zhash_insert (hash, "key1", value); assert (rc == -1); strcpy (value, "Ring a ding ding"); rc = zhash_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding")); zhash_destroy (&hash); ---- czmq-3.0.2/doc/zthread.txt0000664000175000017500000001010012533132136014526 0ustar00phph00000000000000zthread(3) ========== NAME ---- zthread - working with system threads (deprecated) SYNOPSIS -------- ---- // Detached threads follow POSIX pthreads API typedef void *(zthread_detached_fn) (void *args); // Attached threads get context and pipe from parent typedef void (zthread_attached_fn) (void *args, zctx_t *ctx, void *pipe); // Create a detached thread. A detached thread operates autonomously // and is used to simulate a separate process. It gets no ctx, and no // pipe. CZMQ_EXPORT int zthread_new (zthread_detached_fn *thread_fn, void *args); // Create an attached thread. An attached thread gets a ctx and a PAIR // pipe back to its parent. It must monitor its pipe, and exit if the // pipe becomes unreadable. Do not destroy the ctx, the thread does this // automatically when it ends. CZMQ_EXPORT void * zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args); // Self test of this class CZMQ_EXPORT void zthread_test (bool verbose); ---- DESCRIPTION ----------- The zthread class wraps OS thread creation. It creates detached threads that look like normal OS threads, or attached threads that share the caller's 0MQ context, and get an inproc pipe to talk back to the parent thread. Detached threads create their own 0MQ contexts as needed. NOTE: this class is deprecated in favor of zactor. We have several use cases for multiple threads. One is to simulate many processes, so we can test 0MQ designs and flows more easily. Another is to create APIs that can send and receive 0MQ messages in the background. zthread solves these two use cases separately, using the zthread_new and zthead_fork methods respectively. These methods wrap the native system calls needed to start threads, so your code can remain fully portable. Detached threads follow the POSIX pthreads API; they accept a void * argument and return a void * result (always NULL in our case). Attached thread receive a void * argument, a zctx_t context, and a pipe socket. The pipe socket is a PAIR socket that is connected back to the caller. When you call zthread_fork, it returns you a PAIR socket that is the other end of this pipe. Thus attached threads can talk back to their parent threads over the pipe. We use this very heavily when making so-called "asynchronous" APIs, which you can see in the Guide examples like 'clone'. To recap some rules about threading: do not share sockets between threads or your code will crash. You can migrate a socket from one thread to a child thread, if you stop using it in the parent thread immediately after creating the child thread. If you want to connect sockets over inproc:// they must share the same 0MQ context, i.e. be attached threads. You should always use zthread_fork to create an attached thread; it is not sufficient to pass a zctx_t structure to a detached thread (this will crash). If you want to communicate over ipc:// or tcp:// you may be sharing the same context, or use separate contexts. Thus, every detached thread usually starts by creating its own zctx_t instance. EXAMPLE ------- .From zthread_test method ---- static void * s_test_detached (void *args) { // Create a socket to check it'll be automatically deleted zctx_t *ctx = zctx_new (); assert (ctx); void *push = zsocket_new (ctx, ZMQ_PUSH); assert (push); zctx_destroy (&ctx); return NULL; } static void s_test_attached (void *args, zctx_t *ctx, void *pipe) { // Create a socket to check it'll be automatically deleted zsocket_new (ctx, ZMQ_PUSH); assert (ctx); // Wait for our parent to ping us, and pong back char *ping = zstr_recv (pipe); assert (ping); zstr_free (&ping); zstr_send (pipe, "pong"); } zctx_t *ctx = zctx_new (); assert (ctx); int rc = 0; // Create a detached thread, let it run rc = zthread_new (s_test_detached, NULL); assert (rc == 0); zclock_sleep (100); // Create an attached thread, check it's safely alive void *pipe = zthread_fork (ctx, s_test_attached, NULL); assert (pipe); zstr_send (pipe, "ping"); char *pong = zstr_recv (pipe); assert (pong); assert (streq (pong, "pong")); zstr_free (&pong); // Everything should be cleanly closed now zctx_destroy (&ctx); ---- czmq-3.0.2/doc/zfile.30000664000175000017500000002454212533132160013535 0ustar00phph00000000000000'\" t .\" Title: zfile .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZFILE" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zfile \- provides methods to work with files in a portable fashion\&. .SH "SYNOPSIS" .sp .nf // If file exists, populates properties\&. CZMQ supports portable symbolic // links, which are files with the extension "\&.ln"\&. A symbolic link is a // text file containing one line, the filename of a target file\&. Reading // data from the symbolic link actually reads from the target file\&. Path // may be NULL, in which case it is not used\&. CZMQ_EXPORT zfile_t * zfile_new (const char *path, const char *name); // Destroy a file item CZMQ_EXPORT void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item\&. If the file // is null, or memory was exhausted, returns null\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided CZMQ_EXPORT const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots\&. CZMQ_EXPORT void zfile_restat (zfile_t *self); // Return when the file was last modified\&. If you want this to reflect the // current situation, call zfile_restat before checking this property\&. CZMQ_EXPORT time_t zfile_modified (zfile_t *self); // Return the last\-known size of the file\&. If you want this to reflect the // current situation, call zfile_restat before checking this property\&. CZMQ_EXPORT off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory\&. If you want this to reflect // any external changes, call zfile_restat before checking this property\&. CZMQ_EXPORT bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file\&. If you want this to reflect // any external changes, call zfile_restat before checking this property\&. CZMQ_EXPORT bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process\&. If you want this to // reflect any external changes, call zfile_restat before checking this // property\&. CZMQ_EXPORT bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process\&. If you want this // to reflect any external changes, call zfile_restat before checking this // property\&. CZMQ_EXPORT bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed\&. // Updates the file statistics from disk at every call\&. CZMQ_EXPORT bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it\&. CZMQ_EXPORT bool zfile_has_changed (zfile_t *self); // Remove the file from disk CZMQ_EXPORT void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, \-1 if not found or not accessible CZMQ_EXPORT int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location\&. Returns 0 if OK, \-1 if error\&. CZMQ_EXPORT int zfile_output (zfile_t *self); // Read chunk from file at specified position\&. If this was the last chunk, // sets the eof property\&. Returns a null chunk in case of error\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file\&. CZMQ_EXPORT bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else \-1 CZMQ_EXPORT int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file\&. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file\&. CZMQ_EXPORT const char * zfile_readln (zfile_t *self); // Close file, if open CZMQ_EXPORT void zfile_close (zfile_t *self); // Return file handle, if opened CZMQ_EXPORT FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class\&. CZMQ_EXPORT const char * zfile_digest (zfile_t *self); // Self test of this class\&. CZMQ_EXPORT void zfile_test (bool verbose); // These methods are deprecated, and now moved to zsys class\&. CZMQ_EXPORT bool zfile_exists (const char *filename); CZMQ_EXPORT ssize_t zfile_size (const char *filename); CZMQ_EXPORT mode_t zfile_mode (const char *filename); CZMQ_EXPORT int zfile_delete (const char *filename); CZMQ_EXPORT bool zfile_stable (const char *filename); CZMQ_EXPORT int zfile_mkdir (const char *pathname); CZMQ_EXPORT int zfile_rmdir (const char *pathname); CZMQ_EXPORT void zfile_mode_private (void); CZMQ_EXPORT void zfile_mode_default (void); .fi .SH "DESCRIPTION" .sp The zfile class provides methods to work with disk files\&. A file object provides the modified date, current size, and type of the file\&. You can create a file object for a filename that does not yet exist\&. To read or write data from the file, use the input and output methods, and then read and write chunks\&. The output method lets you both read and write chunks, at any offset\&. Finally, this class provides portable symbolic links\&. If a filename ends in "\&.ln", the first line of text in the file is read, and used as the underlying file for read/write operations\&. This lets you manipulate (e\&.g\&.) copy symbolic links without copying the perhaps very large files they point to\&. .sp This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now)\&. .SH "EXAMPLE" .PP \fBFrom zfile_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zfile_t *file = zfile_new (NULL, "bilbo"); assert (file); assert (streq (zfile_filename (file, "\&."), "bilbo")); assert (zfile_is_readable (file) == false); zfile_destroy (&file); // Create a test file in some random subdirectory file = zfile_new ("\&./this/is/a/test", "bilbo"); assert (file); int rc = zfile_output (file); assert (rc == 0); zchunk_t *chunk = zchunk_new (NULL, 100); assert (chunk); zchunk_fill (chunk, 0, 100); // Write 100 bytes at position 1,000,000 in the file rc = zfile_write (file, chunk, 1000000); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_is_readable (file)); assert (zfile_cursize (file) == 1000100); assert (!zfile_is_stable (file)); assert (zfile_digest (file)); // Now truncate file from outside int handle = open ("\&./this/is/a/test/bilbo", O_WRONLY | O_TRUNC | O_BINARY, 0); assert (handle >= 0); rc = write (handle, "Hello, World\en", 13); assert (rc == 13); close (handle); assert (zfile_has_changed (file)); zclock_sleep (1001); assert (zfile_has_changed (file)); assert (!zfile_is_stable (file)); zfile_restat (file); assert (zfile_is_stable (file)); assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54")); // Check we can read from file rc = zfile_input (file); assert (rc == 0); chunk = zfile_read (file, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_close (file); // Check we can read lines from file rc = zfile_input (file); assert (rc == 0); const char *line = zfile_readln (file); assert (streq (line, "Hello, World")); line = zfile_readln (file); assert (line == NULL); zfile_close (file); // Try some fun with symbolic links zfile_t *link = zfile_new ("\&./this/is/a/test", "bilbo\&.ln"); assert (link); rc = zfile_output (link); assert (rc == 0); fprintf (zfile_handle (link), "\&./this/is/a/test/bilbo\en"); zfile_destroy (&link); link = zfile_new ("\&./this/is/a/test", "bilbo\&.ln"); assert (link); rc = zfile_input (link); assert (rc == 0); chunk = zfile_read (link, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_destroy (&link); // Remove file and directory zdir_t *dir = zdir_new ("\&./this", NULL); assert (dir); assert (zdir_cursize (dir) == 26); zdir_remove (dir, true); assert (zdir_cursize (dir) == 0); zdir_destroy (&dir); // Check we can no longer read from file assert (zfile_is_readable (file)); zfile_restat (file); assert (!zfile_is_readable (file)); rc = zfile_input (file); assert (rc == \-1); zfile_destroy (&file); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zmsg.txt0000664000175000017500000003363712533132136014071 0ustar00phph00000000000000zmsg(3) ======= NAME ---- zmsg - working with multipart messages SYNOPSIS -------- ---- // Create a new empty message object CZMQ_EXPORT zmsg_t * zmsg_new (); // Destroy a message object and all frames it contains CZMQ_EXPORT void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_recv (void *source); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). CZMQ_EXPORT size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. CZMQ_EXPORT size_t zmsg_content_size (zmsg_t *self); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. CZMQ_EXPORT int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. CZMQ_EXPORT int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushmem (zmsg_t *self, const void *src, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addmem (zmsg_t *self, const void *src, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. CZMQ_EXPORT int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not succesfull. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. CZMQ_EXPORT void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. CZMQ_EXPORT zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. CZMQ_EXPORT zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. CZMQ_EXPORT zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. CZMQ_EXPORT int zmsg_save (zmsg_t *self, FILE *file); // Load/append an open file into message, create new message if // null message provided. Returns NULL if the message could not // be loaded. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_load (zmsg_t *self, FILE *file); // Serialize multipart message to a single buffer. Use this method to send // structured messages across transports that do not support multipart data. // Allocates and returns a new buffer containing the serialized message. // To decode a serialized message buffer, use zmsg_decode (). CZMQ_EXPORT size_t zmsg_encode (zmsg_t *self, byte **buffer); // Decodes a serialized message buffer created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the buffer was badly formatted or // there was insufficient memory to work. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_decode (const byte *buffer, size_t buffer_size); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). CZMQ_EXPORT void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. CZMQ_EXPORT bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_new_signal (byte status); // Return signal value, 0 or greater, if message is a signal, -1 if not. CZMQ_EXPORT int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. CZMQ_EXPORT bool zmsg_is (void *self); // Self test of this class CZMQ_EXPORT void zmsg_test (bool verbose); ---- DESCRIPTION ----------- The zmsg class provides methods to send and receive multipart messages across 0MQ sockets. This class provides a list-like container interface, with methods to work with the overall container. zmsg_t messages are composed of zero or more zframe_t frames. Please add @discuss section in ../src/zmsg.c. EXAMPLE ------- .From zmsg_test method ---- // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zmsg.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zmsg.test"); assert (input); // Test send and receive of single-frame message zmsg_t *msg = zmsg_new (); assert (msg); zframe_t *frame = zframe_new ("Hello", 5); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); rc = zmsg_send (&msg, output); assert (msg == NULL); assert (rc == 0); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); zmsg_destroy (&msg); // Test send and receive of multi-frame message msg = zmsg_new (); assert (msg); rc = zmsg_addmem (msg, "Frame0", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame1", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame2", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame3", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame4", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame5", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame6", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame7", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame8", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame9", 6); assert (rc == 0); zmsg_t *copy = zmsg_dup (msg); assert (copy); rc = zmsg_send (©, output); assert (rc == 0); rc = zmsg_send (&msg, output); assert (rc == 0); copy = zmsg_recv (input); assert (copy); assert (zmsg_size (copy) == 10); assert (zmsg_content_size (copy) == 60); zmsg_destroy (©); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // create empty file for null test FILE *file = fopen ("zmsg.test", "w"); assert (file); fclose (file); file = fopen ("zmsg.test", "r"); zmsg_t *null_msg = zmsg_load (NULL, file); assert (null_msg == NULL); fclose (file); remove ("zmsg.test"); // Save to a file, read back file = fopen ("zmsg.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg.test", "r"); rc = zmsg_save (msg, file); assert (rc == -1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg.test", "r"); msg = zmsg_load (NULL, file); assert (msg); fclose (file); remove ("zmsg.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Remove all frames except first and last int frame_nbr; for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) { zmsg_first (msg); frame = zmsg_next (msg); zmsg_remove (msg, frame); zframe_destroy (&frame); } // Test message frame manipulation assert (zmsg_size (msg) == 2); frame = zmsg_last (msg); assert (zframe_streq (frame, "Frame9")); assert (zmsg_content_size (msg) == 12); frame = zframe_new ("Address", 7); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 3); rc = zmsg_addstr (msg, "Body"); assert (rc == 0); assert (zmsg_size (msg) == 4); frame = zmsg_pop (msg); zframe_destroy (&frame); assert (zmsg_size (msg) == 3); char *body = zmsg_popstr (msg); assert (streq (body, "Frame0")); free (body); zmsg_destroy (&msg); // Test encoding/decoding msg = zmsg_new (); assert (msg); byte *blank = (byte *) zmalloc (100000); assert (blank); rc = zmsg_addmem (msg, blank, 0); assert (rc == 0); rc = zmsg_addmem (msg, blank, 1); assert (rc == 0); rc = zmsg_addmem (msg, blank, 253); assert (rc == 0); rc = zmsg_addmem (msg, blank, 254); assert (rc == 0); rc = zmsg_addmem (msg, blank, 255); assert (rc == 0); rc = zmsg_addmem (msg, blank, 256); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65535); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65536); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65537); assert (rc == 0); free (blank); assert (zmsg_size (msg) == 9); byte *buffer; size_t buffer_size = zmsg_encode (msg, &buffer); zmsg_destroy (&msg); msg = zmsg_decode (buffer, buffer_size); assert (msg); free (buffer); zmsg_destroy (&msg); // Test submessages msg = zmsg_new (); assert (msg); zmsg_t *submsg = zmsg_new (); zmsg_pushstr (msg, "matr"); zmsg_pushstr (submsg, "joska"); rc = zmsg_addmsg (msg, &submsg); assert (rc == 0); assert (submsg == NULL); submsg = zmsg_popmsg (msg); assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded submsg = zmsg_popmsg (msg); assert (submsg); body = zmsg_popstr (submsg); assert (streq (body, "joska")); free (body); zmsg_destroy (&submsg); frame = zmsg_pop (msg); assert (frame == NULL); zmsg_destroy (&msg); // Test comparison of two messages msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); zmsg_addstr (msg, "Three"); zmsg_t *msg_other = zmsg_new (); zmsg_addstr (msg_other, "One"); zmsg_addstr (msg_other, "Two"); zmsg_addstr (msg_other, "One-Hundred"); zmsg_t *msg_dup = zmsg_dup (msg); zmsg_t *empty_msg = zmsg_new (); zmsg_t *empty_msg_2 = zmsg_new (); assert (zmsg_eq (msg, msg_dup)); assert (!zmsg_eq (msg, msg_other)); assert (zmsg_eq (empty_msg, empty_msg_2)); assert (!zmsg_eq (msg, NULL)); assert (!zmsg_eq (NULL, empty_msg)); assert (!zmsg_eq (NULL, NULL)); zmsg_destroy (&msg); zmsg_destroy (&msg_other); zmsg_destroy (&msg_dup); zmsg_destroy (&empty_msg); zmsg_destroy (&empty_msg_2); // Test signal messages msg = zmsg_new_signal (0); assert (zmsg_signal (msg) == 0); zmsg_destroy (&msg); msg = zmsg_new_signal (-1); assert (zmsg_signal (msg) == 255); zmsg_destroy (&msg); // Now try methods on an empty message msg = zmsg_new (); assert (msg); assert (zmsg_size (msg) == 0); assert (zmsg_unwrap (msg) == NULL); assert (zmsg_first (msg) == NULL); assert (zmsg_last (msg) == NULL); assert (zmsg_next (msg) == NULL); assert (zmsg_pop (msg) == NULL); // Sending an empty message is valid and destroys the message assert (zmsg_send (&msg, output) == 0); assert (!msg); zsock_destroy (&input); zsock_destroy (&output); ---- czmq-3.0.2/doc/zactor.30000664000175000017500000001134012533132151013716 0ustar00phph00000000000000'\" t .\" Title: zactor .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZACTOR" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zactor \- simple actor framework .SH "SYNOPSIS" .sp .nf // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Create a new actor passing arbitrary arguments reference\&. CZMQ_EXPORT zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor\&. CZMQ_EXPORT void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent\&. CZMQ_EXPORT int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor\&. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t\&. CZMQ_EXPORT bool zactor_is (void *self); // Probe the supplied reference\&. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value\&. CZMQ_EXPORT void * zactor_resolve (void *self); // Return the actor\*(Aqs zsock handle\&. Use this when you absolutely need // to work with the zsock instance rather than the actor\&. CZMQ_EXPORT zsock_t * zactor_sock (zactor_t *self); // Self test of this class\&. CZMQ_EXPORT void zactor_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zactor class provides a simple actor framework\&. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard\&. A CZMQ actor is implemented as a thread plus a PAIR\-PAIR pipe\&. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete\&. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished\&.) .sp A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, and zpoller\&. (zloop somehow escaped and needs catching\&.) .sp An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command\&. .sp Please add @discuss section in \&.\&./src/zactor\&.c\&. .SH "EXAMPLE" .PP \fBFrom zactor_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zactor_t *actor = zactor_new (echo_actor, "Hello, World"); assert (actor); zstr_sendx (actor, "ECHO", "This is a string", NULL); char *string = zstr_recv (actor); assert (streq (string, "This is a string")); free (string); zactor_destroy (&actor); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zarmour.30000664000175000017500000003256112533132151014123 0ustar00phph00000000000000'\" t .\" Title: zarmour .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZARMOUR" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zarmour \- armoured text encoding and decoding .SH "SYNOPSIS" .sp .nf // Enumeration defining different encoding modes typedef enum { ZARMOUR_MODE_BASE64_STD // Standard base 64 , ZARMOUR_MODE_BASE64_URL // URL and filename friendly base 64 , ZARMOUR_MODE_BASE32_STD // Standard base 32 , ZARMOUR_MODE_BASE32_HEX // Extended hex base 32 , ZARMOUR_MODE_BASE16 // Standard base 16 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 3, 0)) , ZARMOUR_MODE_Z85 // Z85 from ZeroMQ RFC 32 #endif } zarmour_mode_t; // Create a new zarmour CZMQ_EXPORT zarmour_t * zarmour_new (); // Destroy the zarmour CZMQ_EXPORT void zarmour_destroy (zarmour_t **self_p); // Print properties of object CZMQ_EXPORT void zarmour_print (zarmour_t *self); // Get printable string for mode CZMQ_EXPORT const char * zarmour_mode_str (zarmour_t *self); // Encode a stream of bytes into an armoured string\&. CZMQ_EXPORT char * zarmour_encode (zarmour_t *self, const byte *data, size_t data_size); // Decode an armoured string into a string of bytes\&. // The decoded output is null\-terminated, so it may be treated // as a string, if that\*(Aqs what it was prior to encoding\&. CZMQ_EXPORT byte * zarmour_decode (zarmour_t *self, const char *data, size_t *decode_size); // Get/set the mode property CZMQ_EXPORT zarmour_mode_t zarmour_mode (zarmour_t *self); CZMQ_EXPORT void zarmour_set_mode (zarmour_t *self, zarmour_mode_t mode); // Get/set the pad property CZMQ_EXPORT bool zarmour_pad (zarmour_t *self); CZMQ_EXPORT void zarmour_set_pad (zarmour_t *self, bool pad); // Get/set the pad_char property CZMQ_EXPORT char zarmour_pad_char (zarmour_t *self); CZMQ_EXPORT void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Get/set the line_breaks property CZMQ_EXPORT bool zarmour_line_breaks (zarmour_t *self); CZMQ_EXPORT void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get/set the line_length property CZMQ_EXPORT size_t zarmour_line_length (zarmour_t *self); CZMQ_EXPORT void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Self test of this class CZMQ_EXPORT int zarmour_test (bool verbose); .fi .SH "DESCRIPTION" .sp zarmour \- armoured text encoding and decoding .sp The zarmour class implements encoding and decoding of armoured text data\&. The following codecs are implemented: * RFC 4648 (\m[blue]\fBhttp://www\&.ietf\&.org/rfc/rfc4648\&.txt\fR\m[]) \- base64 \- base64url \- base32 \- base32hex \- base16 * Z85 (\m[blue]\fBhttp://rfc\&.zeromq\&.org/spec:32\fR\m[]) All RFC4648 base64 and base32 variants support padding the output\&. The pad character is configurable\&. Default is padding on, with character \fI=\fR\&. Additionally, in some cases (e\&.g\&. MIME), splitting the output into lines of a specific length is required\&. This feature is also supported, though turned off by default\&. The z85 mode does neither padding nor line breaks; it is merely a wrapping of the corresponding libzmq methods\&. Encoding will assert if input length is not divisible by 4 and decoding will assert if input length is not divisible by 5\&. .SH "EXAMPLE" .PP \fBFrom zarmour_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zarmour_t *self = zarmour_new (); assert (self); zarmour_mode_t mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_STD); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_URL); assert (zarmour_pad (self)); zarmour_set_pad (self, false); assert (!zarmour_pad (self)); assert (zarmour_pad_char (self) == \*(Aq=\*(Aq); zarmour_set_pad_char (self, \*(Aq!\*(Aq); assert (zarmour_pad_char (self) == \*(Aq!\*(Aq); zarmour_set_pad_char (self, \*(Aq=\*(Aq); assert (zarmour_pad_char (self) == \*(Aq=\*(Aq); assert (!zarmour_line_breaks (self)); zarmour_set_line_breaks (self, true); assert (zarmour_line_breaks (self)); assert (zarmour_line_length (self) == 72); zarmour_set_line_length (self, 64); assert (zarmour_line_length (self) == 64); // Test against test vectors from RFC4648\&. zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY", verbose); s_armour_test (self, "fo", "MZXQ", verbose); s_armour_test (self, "foo", "MZXW6", verbose); s_armour_test (self, "foob", "MZXW6YQ", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI", verbose); s_armour_decode (self, "my", "f", verbose); s_armour_decode (self, "mzxq", "fo", verbose); s_armour_decode (self, "mzxw6", "foo", verbose); s_armour_decode (self, "mzxw6yq", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY======", verbose); s_armour_test (self, "fo", "MZXQ====", verbose); s_armour_test (self, "foo", "MZXW6===", verbose); s_armour_test (self, "foob", "MZXW6YQ=", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI======", verbose); s_armour_decode (self, "my======", "f", verbose); s_armour_decode (self, "mzxq====", "fo", verbose); s_armour_decode (self, "mzxw6===", "foo", verbose); s_armour_decode (self, "mzxw6yq=", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi======", "foobar", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO", verbose); s_armour_test (self, "fo", "CPNG", verbose); s_armour_test (self, "foo", "CPNMU", verbose); s_armour_test (self, "foob", "CPNMUOG", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8", verbose); s_armour_decode (self, "co", "f", verbose); s_armour_decode (self, "cpng", "fo", verbose); s_armour_decode (self, "cpnmu", "foo", verbose); s_armour_decode (self, "cpnmuog", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO======", verbose); s_armour_test (self, "fo", "CPNG====", verbose); s_armour_test (self, "foo", "CPNMU===", verbose); s_armour_test (self, "foob", "CPNMUOG=", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8======", verbose); s_armour_decode (self, "co======", "f", verbose); s_armour_decode (self, "cpng====", "fo", verbose); s_armour_decode (self, "cpnmu===", "foo", verbose); s_armour_decode (self, "cpnmuog=", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8======", "foobar", verbose); zarmour_set_pad (self, true); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "66", verbose); s_armour_test (self, "fo", "666F", verbose); s_armour_test (self, "foo", "666F6F", verbose); s_armour_test (self, "foob", "666F6F62", verbose); s_armour_test (self, "fooba", "666F6F6261", verbose); s_armour_test (self, "foobar", "666F6F626172", verbose); s_armour_decode (self, "666f", "fo", verbose); s_armour_decode (self, "666f6f", "foo", verbose); s_armour_decode (self, "666f6f62", "foob", verbose); s_armour_decode (self, "666f6f6261", "fooba", verbose); s_armour_decode (self, "666f6f626172", "foobar", verbose); #ifdef _INCLUDE_Z85 // Z85 test is homemade; using 0, 4 and 8 bytes, with precalculated // test vectors created with a libzmq test\&. // \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- // Make a fake curve key from hex (base16) string, making sure // there are no null bytes inside, so we can use our test utility zarmour_set_mode (self, ZARMOUR_MODE_BASE16); zarmour_set_line_breaks (self, false); size_t key_len; byte *key_data = zarmour_decode (self, "4E6F87E2FB6EB22A1EF5E257B75D79124949565F0B8B36A878A4F03111C96E0B", &key_len); zarmour_set_mode (self, ZARMOUR_MODE_Z85); // Z85 mode does not support padding or line breaks zarmour_set_pad (self, false); // so these two are superfluous; zarmour_set_line_breaks (self, false); // just for consistency if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "foob", "w]zP%", verbose); s_armour_test (self, "foobar!!", "w]zP%vr9Im", verbose); s_armour_test (self, (char *) key_data, "ph+{E}!&X?9}!I]W{sm(nL8@&3Yu{wC+<*\-5Y[[#", verbose); free (key_data); #endif // Armouring longer byte array to test line breaks zarmour_set_pad (self, true); zarmour_set_line_breaks (self, true); byte test_data[256]; int i; for (i = 0; i < 256; ++i) { test_data[i] = i; } zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); s_armour_test_long (self, test_data, 256, verbose); #ifdef _INCLUDE_Z85 zarmour_set_mode (self, ZARMOUR_MODE_Z85); s_armour_test_long (self, test_data, 256, verbose); #endif zarmour_destroy (&self); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zdigest.30000664000175000017500000000774212533132156014105 0ustar00phph00000000000000'\" t .\" Title: zdigest .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZDIGEST" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zdigest \- provides hashing functions (SHA\-1 at present) .SH "SYNOPSIS" .sp .nf // Constructor \- creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data\&. CZMQ_EXPORT zdigest_t * zdigest_new (void); // Destroy a digest object CZMQ_EXPORT void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation CZMQ_EXPORT void zdigest_update (zdigest_t *self, byte *buffer, size_t length); // Return final digest hash data\&. If built without crypto support, returns // NULL\&. CZMQ_EXPORT byte * zdigest_data (zdigest_t *self); // Return final digest hash size CZMQ_EXPORT size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string\&. After calling this, you may not use zdigest_update() // on the same digest\&. If built without crypto support, returns NULL\&. CZMQ_EXPORT char * zdigest_string (zdigest_t *self); // Self test of this class CZMQ_EXPORT void zdigest_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zdigest class generates a hash from zchunks of data\&. The current algorithm is SHA\-1, chosen for speed\&. We are aiming to generate a unique digest for a file, and there are no security issues in this use case\&. .sp The current code depends on OpenSSL, which might be replaced by hard coded SHA\-1 implementation to reduce build dependencies\&. .SH "EXAMPLE" .PP \fBFrom zdigest_test method\fR. .sp .if n \{\ .RS 4 .\} .nf byte *buffer = (byte *) zmalloc (1024); memset (buffer, 0xAA, 1024); zdigest_t *digest = zdigest_new (); assert (digest); zdigest_update (digest, buffer, 1024); byte *data = zdigest_data (digest); assert (data [0] == 0xDE); assert (data [1] == 0xB2); assert (data [2] == 0x38); assert (data [3] == 0x07); assert (streq (zdigest_string (digest), "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671")); zdigest_destroy (&digest); free (buffer); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zdigest.txt0000664000175000017500000000371612533132136014555 0ustar00phph00000000000000zdigest(3) ========== NAME ---- zdigest - provides hashing functions (SHA-1 at present) SYNOPSIS -------- ---- // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. CZMQ_EXPORT zdigest_t * zdigest_new (void); // Destroy a digest object CZMQ_EXPORT void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation CZMQ_EXPORT void zdigest_update (zdigest_t *self, byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, returns // NULL. CZMQ_EXPORT byte * zdigest_data (zdigest_t *self); // Return final digest hash size CZMQ_EXPORT size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. CZMQ_EXPORT char * zdigest_string (zdigest_t *self); // Self test of this class CZMQ_EXPORT void zdigest_test (bool verbose); ---- DESCRIPTION ----------- The zdigest class generates a hash from zchunks of data. The current algorithm is SHA-1, chosen for speed. We are aiming to generate a unique digest for a file, and there are no security issues in this use case. The current code depends on OpenSSL, which might be replaced by hard coded SHA-1 implementation to reduce build dependencies. EXAMPLE ------- .From zdigest_test method ---- byte *buffer = (byte *) zmalloc (1024); memset (buffer, 0xAA, 1024); zdigest_t *digest = zdigest_new (); assert (digest); zdigest_update (digest, buffer, 1024); byte *data = zdigest_data (digest); assert (data [0] == 0xDE); assert (data [1] == 0xB2); assert (data [2] == 0x38); assert (data [3] == 0x07); assert (streq (zdigest_string (digest), "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671")); zdigest_destroy (&digest); free (buffer); ---- czmq-3.0.2/doc/zgossip.txt0000664000175000017500000001561012533132136014576 0ustar00phph00000000000000zgossip(3) ========== NAME ---- zgossip - decentralized configuration management SYNOPSIS -------- ---- // To work with zgossip, use the CZMQ zactor API: // // Create new zgossip instance, passing logging prefix: // // zactor_t *zgossip = zactor_new (zgossip, "myname"); // // Destroy zgossip instance // // zactor_destroy (&zgossip); // // Enable verbose logging of commands and activity: // // zstr_send (zgossip, "VERBOSE"); // // Bind zgossip to specified endpoint. TCP endpoints may specify // the port number as "*" to aquire an ephemeral port: // // zstr_sendx (zgossip, "BIND", endpoint, NULL); // // Return assigned port number, specifically when BIND was done using an // an ephemeral port: // // zstr_sendx (zgossip, "PORT", NULL); // char *command, *port_str; // zstr_recvx (zgossip, &command, &port_str, NULL); // assert (streq (command, "PORT")); // // Specify configuration file to load, overwriting any previous loaded // configuration file or options: // // zstr_sendx (zgossip, "LOAD", filename, NULL); // // Set configuration path value: // // zstr_sendx (zgossip, "SET", path, value, NULL); // // Save configuration data to config file on disk: // // zstr_sendx (zgossip, "SAVE", filename, NULL); // // Send zmsg_t instance to zgossip: // // zactor_send (zgossip, &msg); // // Receive zmsg_t instance from zgossip: // // zmsg_t *msg = zactor_recv (zgossip); // // This is the zgossip constructor as a zactor_fn: // CZMQ_EXPORT void zgossip (zsock_t *pipe, void *args); // Self test of this class CZMQ_EXPORT void zgossip_test (bool verbose); ---- DESCRIPTION ----------- Implements a gossip protocol for decentralized configuration management. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples. Each node re-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state. The current design does not expire tuples. Provides these commands (sent as multipart strings to the actor): * BIND endpoint -- binds the gossip service to specified endpoint * PORT -- returns the last TCP port, if any, used for binding * LOAD configfile -- load configuration from specified file * SET configpath value -- set configuration path = value * SAVE configfile -- save configuration to specified file * CONNECT endpoint -- connect the gossip service to the specified peer * PUBLISH key value -- publish a key/value pair to the gossip cluster * STATUS -- return number of key/value pairs held by gossip service Returns these messages: * PORT number -- reply to PORT command * STATUS number -- reply to STATUS command * DELIVER key value -- new tuple delivered from network The gossip protocol distributes information around a loosely-connected network of gossip services. The information consists of name/value pairs published by applications at any point in the network. The goal of the gossip protocol is to create eventual consistency between all the using applications. The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery. When used for discovery, the gossip protocol works as an alternative to e.g. UDP beaconing. The gossip network consists of a set of loosely-coupled nodes that exchange tuples. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time. Each node runs the same stack, which is a server-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): http://zguide.zeromq.org/page:all#True-Peer-Connectivity-Harmony-Pattern Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command. The state machine for these connections is in zgossip.xml, and the generated code is in zgossip_engine.inc. Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote. The messages between client and server are defined in zgossip_msg.xml. We built this stack using the zeromq/zproto toolkit. To join the gossip network, a node connects to one or more peers. Each peer acts as a forwarder. This loosely-coupled network can scale to thousands of nodes. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network. The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to. When a node gets a duplicate tuple, it throws it away. When a node gets a new tuple, it stores it, and fowards it as just described. At any point the application can access the node's set of tuples. At present there is no way to expire tuples from the network. The assumptions in this design are: * The data set is slow-changing. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic. EXAMPLE ------- .From zgossip_test method ---- // Test basic client-to-server operation of the protocol zactor_t *server = zactor_new (zgossip, "server"); assert (server); if (verbose) zstr_send (server, "VERBOSE"); zstr_sendx (server, "BIND", "inproc://zgossip", NULL); zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zsock_set_rcvtimeo (client, 2000); int rc = zsock_connect (client, "inproc://zgossip"); assert (rc == 0); // Send HELLO, which gets no message zgossip_msg_t *message = zgossip_msg_new (); zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (message, client); // Send PING, expect PONG back zgossip_msg_set_id (message, ZGOSSIP_MSG_PING); zgossip_msg_send (message, client); zgossip_msg_recv (message, client); assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG); zgossip_msg_destroy (&message); zactor_destroy (&server); zsock_destroy (&client); // Test peer-to-peer operations zactor_t *base = zactor_new (zgossip, "base"); assert (base); if (verbose) zstr_send (base, "VERBOSE"); // Set a 100msec timeout on clients so we can test expiry zstr_sendx (base, "SET", "server/timeout", "100", NULL); zstr_sendx (base, "BIND", "inproc://base", NULL); zactor_t *alpha = zactor_new (zgossip, "alpha"); assert (alpha); zstr_sendx (alpha, "CONNECT", "inproc://base", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-1", "service1", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-2", "service2", NULL); zactor_t *beta = zactor_new (zgossip, "beta"); assert (beta); zstr_sendx (beta, "CONNECT", "inproc://base", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-1", "service1", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-2", "service2", NULL); // got nothing zclock_sleep (200); zactor_destroy (&base); zactor_destroy (&alpha); zactor_destroy (&beta); ---- czmq-3.0.2/doc/zgossip.30000664000175000017500000002376112533132160014124 0ustar00phph00000000000000'\" t .\" Title: zgossip .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZGOSSIP" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zgossip \- decentralized configuration management .SH "SYNOPSIS" .sp .nf // To work with zgossip, use the CZMQ zactor API: // // Create new zgossip instance, passing logging prefix: // // zactor_t *zgossip = zactor_new (zgossip, "myname"); // // Destroy zgossip instance // // zactor_destroy (&zgossip); // // Enable verbose logging of commands and activity: // // zstr_send (zgossip, "VERBOSE"); // // Bind zgossip to specified endpoint\&. TCP endpoints may specify // the port number as "*" to aquire an ephemeral port: // // zstr_sendx (zgossip, "BIND", endpoint, NULL); // // Return assigned port number, specifically when BIND was done using an // an ephemeral port: // // zstr_sendx (zgossip, "PORT", NULL); // char *command, *port_str; // zstr_recvx (zgossip, &command, &port_str, NULL); // assert (streq (command, "PORT")); // // Specify configuration file to load, overwriting any previous loaded // configuration file or options: // // zstr_sendx (zgossip, "LOAD", filename, NULL); // // Set configuration path value: // // zstr_sendx (zgossip, "SET", path, value, NULL); // // Save configuration data to config file on disk: // // zstr_sendx (zgossip, "SAVE", filename, NULL); // // Send zmsg_t instance to zgossip: // // zactor_send (zgossip, &msg); // // Receive zmsg_t instance from zgossip: // // zmsg_t *msg = zactor_recv (zgossip); // // This is the zgossip constructor as a zactor_fn: // CZMQ_EXPORT void zgossip (zsock_t *pipe, void *args); // Self test of this class CZMQ_EXPORT void zgossip_test (bool verbose); .fi .SH "DESCRIPTION" .sp Implements a gossip protocol for decentralized configuration management\&. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples\&. Each node re\-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state\&. The current design does not expire tuples\&. .sp Provides these commands (sent as multipart strings to the actor): .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} BIND endpoint \(em binds the gossip service to specified endpoint .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} PORT \(em returns the last TCP port, if any, used for binding .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} LOAD configfile \(em load configuration from specified file .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} SET configpath value \(em set configuration path = value .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} SAVE configfile \(em save configuration to specified file .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CONNECT endpoint \(em connect the gossip service to the specified peer .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} PUBLISH key value \(em publish a key/value pair to the gossip cluster .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} STATUS \(em return number of key/value pairs held by gossip service .RE .sp Returns these messages: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} PORT number \(em reply to PORT command .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} STATUS number \(em reply to STATUS command .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} DELIVER key value \(em new tuple delivered from network .RE .sp The gossip protocol distributes information around a loosely\-connected network of gossip services\&. The information consists of name/value pairs published by applications at any point in the network\&. The goal of the gossip protocol is to create eventual consistency between all the using applications\&. .sp The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery\&. When used for discovery, the gossip protocol works as an alternative to e\&.g\&. UDP beaconing\&. .sp The gossip network consists of a set of loosely\-coupled nodes that exchange tuples\&. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time\&. .sp Each node runs the same stack, which is a server\-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): \m[blue]\fBhttp://zguide\&.zeromq\&.org/page:all#True\-Peer\-Connectivity\-Harmony\-Pattern\fR\m[] .sp Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command\&. The state machine for these connections is in zgossip\&.xml, and the generated code is in zgossip_engine\&.inc\&. .sp Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote\&. .sp The messages between client and server are defined in zgossip_msg\&.xml\&. We built this stack using the zeromq/zproto toolkit\&. .sp To join the gossip network, a node connects to one or more peers\&. Each peer acts as a forwarder\&. This loosely\-coupled network can scale to thousands of nodes\&. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network\&. .sp The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to\&. When a node gets a duplicate tuple, it throws it away\&. When a node gets a new tuple, it stores it, and fowards it as just described\&. At any point the application can access the node\(cqs set of tuples\&. .sp At present there is no way to expire tuples from the network\&. .sp The assumptions in this design are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The data set is slow\-changing\&. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic\&. .RE .SH "EXAMPLE" .PP \fBFrom zgossip_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Test basic client\-to\-server operation of the protocol zactor_t *server = zactor_new (zgossip, "server"); assert (server); if (verbose) zstr_send (server, "VERBOSE"); zstr_sendx (server, "BIND", "inproc://zgossip", NULL); zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zsock_set_rcvtimeo (client, 2000); int rc = zsock_connect (client, "inproc://zgossip"); assert (rc == 0); // Send HELLO, which gets no message zgossip_msg_t *message = zgossip_msg_new (); zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (message, client); // Send PING, expect PONG back zgossip_msg_set_id (message, ZGOSSIP_MSG_PING); zgossip_msg_send (message, client); zgossip_msg_recv (message, client); assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG); zgossip_msg_destroy (&message); zactor_destroy (&server); zsock_destroy (&client); // Test peer\-to\-peer operations zactor_t *base = zactor_new (zgossip, "base"); assert (base); if (verbose) zstr_send (base, "VERBOSE"); // Set a 100msec timeout on clients so we can test expiry zstr_sendx (base, "SET", "server/timeout", "100", NULL); zstr_sendx (base, "BIND", "inproc://base", NULL); zactor_t *alpha = zactor_new (zgossip, "alpha"); assert (alpha); zstr_sendx (alpha, "CONNECT", "inproc://base", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha\-1", "service1", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha\-2", "service2", NULL); zactor_t *beta = zactor_new (zgossip, "beta"); assert (beta); zstr_sendx (beta, "CONNECT", "inproc://base", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta\-1", "service1", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta\-2", "service2", NULL); // got nothing zclock_sleep (200); zactor_destroy (&base); zactor_destroy (&alpha); zactor_destroy (&beta); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zthread.30000664000175000017500000001426312533132201014060 0ustar00phph00000000000000'\" t .\" Title: zthread .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZTHREAD" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zthread \- working with system threads (deprecated) .SH "SYNOPSIS" .sp .nf // Detached threads follow POSIX pthreads API typedef void *(zthread_detached_fn) (void *args); // Attached threads get context and pipe from parent typedef void (zthread_attached_fn) (void *args, zctx_t *ctx, void *pipe); // Create a detached thread\&. A detached thread operates autonomously // and is used to simulate a separate process\&. It gets no ctx, and no // pipe\&. CZMQ_EXPORT int zthread_new (zthread_detached_fn *thread_fn, void *args); // Create an attached thread\&. An attached thread gets a ctx and a PAIR // pipe back to its parent\&. It must monitor its pipe, and exit if the // pipe becomes unreadable\&. Do not destroy the ctx, the thread does this // automatically when it ends\&. CZMQ_EXPORT void * zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args); // Self test of this class CZMQ_EXPORT void zthread_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zthread class wraps OS thread creation\&. It creates detached threads that look like normal OS threads, or attached threads that share the caller\(cqs 0MQ context, and get an inproc pipe to talk back to the parent thread\&. Detached threads create their own 0MQ contexts as needed\&. NOTE: this class is deprecated in favor of zactor\&. .sp We have several use cases for multiple threads\&. One is to simulate many processes, so we can test 0MQ designs and flows more easily\&. Another is to create APIs that can send and receive 0MQ messages in the background\&. .sp zthread solves these two use cases separately, using the zthread_new and zthead_fork methods respectively\&. These methods wrap the native system calls needed to start threads, so your code can remain fully portable\&. .sp Detached threads follow the POSIX pthreads API; they accept a void * argument and return a void * result (always NULL in our case)\&. .sp Attached thread receive a void * argument, a zctx_t context, and a pipe socket\&. The pipe socket is a PAIR socket that is connected back to the caller\&. When you call zthread_fork, it returns you a PAIR socket that is the other end of this pipe\&. Thus attached threads can talk back to their parent threads over the pipe\&. We use this very heavily when making so\-called "asynchronous" APIs, which you can see in the Guide examples like \fIclone\fR\&. .sp To recap some rules about threading: do not share sockets between threads or your code will crash\&. You can migrate a socket from one thread to a child thread, if you stop using it in the parent thread immediately after creating the child thread\&. If you want to connect sockets over inproc:// they must share the same 0MQ context, i\&.e\&. be attached threads\&. You should always use zthread_fork to create an attached thread; it is not sufficient to pass a zctx_t structure to a detached thread (this will crash)\&. .sp If you want to communicate over ipc:// or tcp:// you may be sharing the same context, or use separate contexts\&. Thus, every detached thread usually starts by creating its own zctx_t instance\&. .SH "EXAMPLE" .PP \fBFrom zthread_test method\fR. .sp .if n \{\ .RS 4 .\} .nf static void * s_test_detached (void *args) { // Create a socket to check it\*(Aqll be automatically deleted zctx_t *ctx = zctx_new (); assert (ctx); void *push = zsocket_new (ctx, ZMQ_PUSH); assert (push); zctx_destroy (&ctx); return NULL; } static void s_test_attached (void *args, zctx_t *ctx, void *pipe) { // Create a socket to check it\*(Aqll be automatically deleted zsocket_new (ctx, ZMQ_PUSH); assert (ctx); // Wait for our parent to ping us, and pong back char *ping = zstr_recv (pipe); assert (ping); zstr_free (&ping); zstr_send (pipe, "pong"); } zctx_t *ctx = zctx_new (); assert (ctx); int rc = 0; // Create a detached thread, let it run rc = zthread_new (s_test_detached, NULL); assert (rc == 0); zclock_sleep (100); // Create an attached thread, check it\*(Aqs safely alive void *pipe = zthread_fork (ctx, s_test_attached, NULL); assert (pipe); zstr_send (pipe, "ping"); char *pong = zstr_recv (pipe); assert (pong); assert (streq (pong, "pong")); zstr_free (&pong); // Everything should be cleanly closed now zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zhashx.txt0000664000175000017500000004063112533132136014406 0ustar00phph00000000000000zhashx(3) ========= NAME ---- zhashx - extended generic hash container SYNOPSIS -------- ---- // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // compare two items, for sorting typedef void (zhashx_free_fn) ( void *data); // compare two items, for sorting typedef size_t (zhashx_hash_fn) ( const void *key); // DEPRECATED as clumsy -- use zhashx_first/_next instead typedef int (zhashx_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhashx_t * zhashx_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhashx_destroy (zhashx_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. CZMQ_EXPORT void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. CZMQ_EXPORT void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null CZMQ_EXPORT void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhashx_comment (zhashx_t *self, const char *format, ...) CHECK_PRINTF (2); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zhashx_pack (zhashx_t *self); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhashx_t * zhashx_unpack (zframe_t *frame); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. CZMQ_EXPORT void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. CZMQ_EXPORT void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). CZMQ_EXPORT void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. CZMQ_EXPORT void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. CZMQ_EXPORT void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. CZMQ_EXPORT void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. CZMQ_EXPORT zhashx_t * zhashx_dup_v2 (zhashx_t *self); // DEPRECATED as clumsy -- use set_destructor instead // Set hash for automatic value destruction CZMQ_EXPORT void zhashx_autofree (zhashx_t *self); // DEPRECATED as clumsy -- use zhashx_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). // Callback function for zhashx_foreach method CZMQ_EXPORT int zhashx_foreach (zhashx_t *self, zhashx_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhashx_test (int verbose); ---- DESCRIPTION ----------- zhashx is an extended hash table container with more functionality than zhash, its simpler cousin. The hash table always has a size that is prime and roughly doubles its size when 75% full. In case of hash collisions items are chained in a linked list. The hash table size is increased slightly (up to 5 times before roughly doubling the size) when an overly long chain (between 1 and 63 items depending on table size) is detected. EXAMPLE ------- .From zhashx_test method ---- zhashx_t *hash = zhashx_new (); assert (hash); assert (zhashx_size (hash) == 0); assert (zhashx_first (hash) == NULL); assert (zhashx_cursor (hash) == NULL); // Insert some items int rc; rc = zhashx_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhashx_first (hash); assert (streq ((char *) zhashx_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhashx_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhashx_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhashx_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhashx_size (hash) == 4); // Look for existing items item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhashx_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhashx_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhashx_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhashx_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhashx_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhashx_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhashx_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhashx_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlistx_t *keys = zhashx_keys (hash); assert (zlistx_size (keys) == 4); zlistx_destroy (&keys); zlistx_t *values = zhashx_values(hash); assert (zlistx_size (values) == 4); zlistx_destroy (&values); // Test dup method zhashx_t *copy = zhashx_dup (hash); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test pack/unpack methods zframe_t *frame = zhashx_pack (hash); copy = zhashx_unpack (frame); zframe_destroy (&frame); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test save and load zhashx_comment (hash, "This is a test file"); zhashx_comment (hash, "Created by %s", "czmq_selftest"); zhashx_save (hash, ".cache"); copy = zhashx_new (); assert (copy); zhashx_load (copy, ".cache"); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); zsys_file_delete (".cache"); // Delete a item zhashx_delete (hash, "LIVEBEEF"); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhashx_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr].exists) { item = (char *) zhashx_lookup (hash, testset [testnbr].name); assert (item); zhashx_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhashx_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhashx_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhashx_destroy (&hash); zhashx_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhashx_new (); assert (hash); zhashx_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhashx_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); zhashx_destroy (&hash); ---- czmq-3.0.2/doc/Makefile.in0000664000175000017500000005322412535241735014417 0ustar00phph00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = doc DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \ $(top_srcdir)/config/ltoptions.m4 \ $(top_srcdir)/config/ltsugar.m4 \ $(top_srcdir)/config/ltversion.m4 \ $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/platform.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" \ "$(DESTDIR)$(man7dir)" man3dir = $(mandir)/man3 man7dir = $(mandir)/man7 NROFF = nroff MANS = $(dist_man_MANS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LTVER = @LTVER@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ czmq_have_asciidoc = @czmq_have_asciidoc@ czmq_have_xmlto = @czmq_have_xmlto@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ zmq_CFLAGS = @zmq_CFLAGS@ zmq_LIBS = @zmq_LIBS@ ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ MAN1 = makecert.1 MAN3 = zactor.3 zauth.3 zarmour.3 zbeacon.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zgossip.3 zhashx.3 ziflist.3 zlistx.3 zloop.3 zmonitor.3 zmsg.3 zpoller.3 zproxy.3 zrex.3 zsock.3 zsock_option.3 zstr.3 zsys.3 zuuid.3 zauth_v2.3 zbeacon_v2.3 zctx.3 zhash.3 zlist.3 zmonitor_v2.3 zmutex.3 zproxy_v2.3 zsocket.3 zsockopt.3 zthread.3 MAN7 = czmq.7 MAN_DOC = $(MAN1) $(MAN3) $(MAN7) MAN_TXT = $(MAN1:%.1=%.txt) $(MAN3:%.3=%.txt) $(MAN7:%.7=%.txt) EXTRA_DIST = asciidoc.conf $(MAN_TXT) @BUILD_DOC_TRUE@@INSTALL_MAN_TRUE@dist_man_MANS = $(MAN_DOC) @BUILD_DOC_TRUE@MAINTAINERCLEANFILES = $(MAN_DOC) @BUILD_DOC_TRUE@SUFFIXES = .txt .xml .1 .3 .7 all: all-am .SUFFIXES: .SUFFIXES: .txt .xml .1 .3 .7 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-man1: $(dist_man_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" @list=''; test -n "$(man1dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man3: $(dist_man_MANS) @$(NORMAL_INSTALL) test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)" @list=''; test -n "$(man3dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.3[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ done; } uninstall-man3: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man3dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.3[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) install-man7: $(dist_man_MANS) @$(NORMAL_INSTALL) test -z "$(man7dir)" || $(MKDIR_P) "$(DESTDIR)$(man7dir)" @list=''; test -n "$(man7dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.7[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man7dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man7dir)" || exit $$?; }; \ done; } uninstall-man7: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man7dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.7[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man7dir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: ctags: CTAGS CTAGS: @BUILD_DOC_FALSE@dist-hook: distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(MANS) installdirs: for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man7dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) @BUILD_DOC_FALSE@clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man3 install-man7 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man1 uninstall-man3 uninstall-man7 .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ dist-hook distclean distclean-generic distclean-libtool \ distdir dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-man1 install-man3 install-man7 install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ uninstall-man uninstall-man1 uninstall-man3 uninstall-man7 @BUILD_DOC_TRUE@dist-hook : $(MAN_DOC) @BUILD_DOC_TRUE@.txt.xml: @BUILD_DOC_TRUE@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ @BUILD_DOC_TRUE@ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< @BUILD_DOC_TRUE@.xml.1: @BUILD_DOC_TRUE@ xmlto man $< @BUILD_DOC_TRUE@.xml.3: @BUILD_DOC_TRUE@ xmlto man $< @BUILD_DOC_TRUE@.xml.7: @BUILD_DOC_TRUE@ xmlto man $< @BUILD_DOC_TRUE@zactor.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zauth.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zarmour.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zbeacon.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zcert.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zcertstore.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zchunk.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zclock.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zconfig.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zdigest.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zdir.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zdir_patch.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zfile.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zframe.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zgossip.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zhashx.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@ziflist.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zlistx.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zloop.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zmonitor.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zmsg.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zpoller.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zproxy.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zrex.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zsock.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zsock_option.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zstr.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zsys.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zuuid.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zauth_v2.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zbeacon_v2.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zctx.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zhash.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zlist.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zmonitor_v2.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zmutex.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zproxy_v2.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zsocket.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zsockopt.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@zthread.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@makecert.txt: @BUILD_DOC_TRUE@ zproject_mkman $@ @BUILD_DOC_TRUE@clean: @BUILD_DOC_TRUE@ rm -f *.1 *.3 @BUILD_DOC_TRUE@ zproject_mkman zactor zauth zarmour zbeacon zcert zcertstore zchunk zclock zconfig zdigest zdir zdir_patch zfile zframe zgossip zhashx ziflist zlistx zloop zmonitor zmsg zpoller zproxy zrex zsock zsock_option zstr zsys zuuid zauth_v2 zbeacon_v2 zctx zhash zlist zmonitor_v2 zmutex zproxy_v2 zsocket zsockopt zthread makecert ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: czmq-3.0.2/doc/zsockopt.txt0000664000175000017500000010415512533132136014757 0ustar00phph00000000000000zsockopt(3) =========== NAME ---- zsockopt - get/set 0MQ socket options (deprecated) SYNOPSIS -------- ---- #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsocket_tos (void *zocket); CZMQ_EXPORT char * zsocket_zap_domain (void *zocket); CZMQ_EXPORT int zsocket_mechanism (void *zocket); CZMQ_EXPORT int zsocket_plain_server (void *zocket); CZMQ_EXPORT char * zsocket_plain_username (void *zocket); CZMQ_EXPORT char * zsocket_plain_password (void *zocket); CZMQ_EXPORT int zsocket_curve_server (void *zocket); CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket); CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket); CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket); CZMQ_EXPORT int zsocket_gssapi_server (void *zocket); CZMQ_EXPORT int zsocket_gssapi_plaintext (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_principal (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_service_principal (void *zocket); CZMQ_EXPORT int zsocket_ipv6 (void *zocket); CZMQ_EXPORT int zsocket_immediate (void *zocket); CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_tos (void *zocket, int tos); CZMQ_EXPORT void zsocket_set_router_handover (void *zocket, int router_handover); CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory); CZMQ_EXPORT void zsocket_set_probe_router (void *zocket, int probe_router); CZMQ_EXPORT void zsocket_set_req_relaxed (void *zocket, int req_relaxed); CZMQ_EXPORT void zsocket_set_req_correlate (void *zocket, int req_correlate); CZMQ_EXPORT void zsocket_set_conflate (void *zocket, int conflate); CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain); CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server); CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username); CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password); CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server); CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey); CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey); CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey); CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey); CZMQ_EXPORT void zsocket_set_gssapi_server (void *zocket, int gssapi_server); CZMQ_EXPORT void zsocket_set_gssapi_plaintext (void *zocket, int gssapi_plaintext); CZMQ_EXPORT void zsocket_set_gssapi_principal (void *zocket, const char * gssapi_principal); CZMQ_EXPORT void zsocket_set_gssapi_service_principal (void *zocket, const char * gssapi_service_principal); CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6); CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate); CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsocket_hwm (void *zocket); CZMQ_EXPORT int zsocket_swap (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *zocket); CZMQ_EXPORT int zsocket_mcast_loop (void *zocket); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); # endif CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); CZMQ_EXPORT void zsocket_set_swap (void *zocket, int swap); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec); CZMQ_EXPORT void zsocket_set_mcast_loop (void *zocket, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); # endif CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsockopt_test (bool verbose); ---- DESCRIPTION ----------- The zsockopt class provides access to the 0MQ getsockopt/setsockopt API. This class is generated, using the GSL code generator. See the sockopts XML file, which provides the metadata, and the zsockopt.gsl template, which does the work. EXAMPLE ------- .From zsockopt_test method ---- zctx_t *ctx = zctx_new (); assert (ctx); void *zocket; #if (ZMQ_VERSION_MAJOR == 4) # if defined (ZMQ_TOS) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_tos (zocket, 1); assert (zsocket_tos (zocket) == 1); zsocket_tos (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_HANDOVER) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_handover (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_MANDATORY) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_mandatory (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PROBE_ROUTER) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_probe_router (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_RELAXED) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_relaxed (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_REQ_CORRELATE) zocket = zsocket_new (ctx, ZMQ_REQ); assert (zocket); zsocket_set_req_correlate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_CONFLATE) zocket = zsocket_new (ctx, ZMQ_PUSH); assert (zocket); zsocket_set_conflate (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ZAP_DOMAIN) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_zap_domain (zocket, "test"); char *zap_domain = zsocket_zap_domain (zocket); assert (zap_domain); free (zap_domain); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MECHANISM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_mechanism (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_SERVER) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_plain_server (zocket, 1); assert (zsocket_plain_server (zocket) == 1); zsocket_plain_server (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_USERNAME) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_username (zocket, "test"); char *plain_username = zsocket_plain_username (zocket); assert (plain_username); free (plain_username); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_PLAIN_PASSWORD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_plain_password (zocket, "test"); char *plain_password = zsocket_plain_password (zocket); assert (plain_password); free (plain_password); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV6) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv6 (zocket, 1); assert (zsocket_ipv6 (zocket) == 1); zsocket_ipv6 (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IMMEDIATE) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_immediate (zocket, 1); assert (zsocket_immediate (zocket) == 1); zsocket_immediate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 3) # if defined (ZMQ_ROUTER_RAW) zocket = zsocket_new (ctx, ZMQ_ROUTER); assert (zocket); zsocket_set_router_raw (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IPV4ONLY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_ipv4only (zocket, 1); assert (zsocket_ipv4only (zocket) == 1); zsocket_ipv4only (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_delay_attach_on_connect (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDHWM) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndhwm (zocket, 1); assert (zsocket_sndhwm (zocket) == 1); zsocket_sndhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVHWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvhwm (zocket, 1); assert (zsocket_rcvhwm (zocket) == 1); zsocket_rcvhwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_DEALER); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_PUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MAXMSGSIZE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_maxmsgsize (zocket, 1); assert (zsocket_maxmsgsize (zocket) == 1); zsocket_maxmsgsize (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MULTICAST_HOPS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_multicast_hops (zocket, 1); assert (zsocket_multicast_hops (zocket) == 1); zsocket_multicast_hops (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_XPUB_VERBOSE) zocket = zsocket_new (ctx, ZMQ_XPUB); assert (zocket); zsocket_set_xpub_verbose (zocket, 1); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive (zocket, 1); assert (zsocket_tcp_keepalive (zocket) == 1); zsocket_tcp_keepalive (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_idle (zocket, 1); assert (zsocket_tcp_keepalive_idle (zocket) == 1); zsocket_tcp_keepalive_idle (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_cnt (zocket, 1); assert (zsocket_tcp_keepalive_cnt (zocket) == 1); zsocket_tcp_keepalive_cnt (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_keepalive_intvl (zocket, 1); assert (zsocket_tcp_keepalive_intvl (zocket) == 1); zsocket_tcp_keepalive_intvl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_tcp_accept_filter (zocket, "127.0.0.1"); char *tcp_accept_filter = zsocket_tcp_accept_filter (zocket); assert (tcp_accept_filter); free (tcp_accept_filter); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LAST_ENDPOINT) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); char *last_endpoint = zsocket_last_endpoint (zocket); assert (last_endpoint); free (last_endpoint); zsocket_destroy (ctx, zocket); # endif #endif #if (ZMQ_VERSION_MAJOR == 2) # if defined (ZMQ_HWM) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_hwm (zocket, 1); assert (zsocket_hwm (zocket) == 1); zsocket_hwm (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SWAP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_swap (zocket, 1); assert (zsocket_swap (zocket) == 1); zsocket_swap (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_AFFINITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_affinity (zocket, 1); assert (zsocket_affinity (zocket) == 1); zsocket_affinity (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_IDENTITY) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_identity (zocket, "test"); char *identity = zsocket_identity (zocket); assert (identity); free (identity); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RATE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rate (zocket, 1); assert (zsocket_rate (zocket) == 1); zsocket_rate (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl (zocket, 1); assert (zsocket_recovery_ivl (zocket) == 1); zsocket_recovery_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECOVERY_IVL_MSEC) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_recovery_ivl_msec (zocket, 1); assert (zsocket_recovery_ivl_msec (zocket) == 1); zsocket_recovery_ivl_msec (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_MCAST_LOOP) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_mcast_loop (zocket, 1); assert (zsocket_mcast_loop (zocket) == 1); zsocket_mcast_loop (zocket); zsocket_destroy (ctx, zocket); # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_RCVTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvtimeo (zocket, 1); assert (zsocket_rcvtimeo (zocket) == 1); zsocket_rcvtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if (ZMQ_VERSION_MINOR == 2) # if defined (ZMQ_SNDTIMEO) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndtimeo (zocket, 1); assert (zsocket_sndtimeo (zocket) == 1); zsocket_sndtimeo (zocket); zsocket_destroy (ctx, zocket); # endif # endif # if defined (ZMQ_SNDBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_sndbuf (zocket, 1); assert (zsocket_sndbuf (zocket) == 1); zsocket_sndbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVBUF) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_rcvbuf (zocket, 1); assert (zsocket_rcvbuf (zocket) == 1); zsocket_rcvbuf (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_LINGER) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_linger (zocket, 1); assert (zsocket_linger (zocket) == 1); zsocket_linger (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl (zocket, 1); assert (zsocket_reconnect_ivl (zocket) == 1); zsocket_reconnect_ivl (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_reconnect_ivl_max (zocket, 1); assert (zsocket_reconnect_ivl_max (zocket) == 1); zsocket_reconnect_ivl_max (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_BACKLOG) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_backlog (zocket, 1); assert (zsocket_backlog (zocket) == 1); zsocket_backlog (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_SUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_subscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_UNSUBSCRIBE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_set_unsubscribe (zocket, "test"); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_TYPE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_type (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_RCVMORE) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_rcvmore (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_FD) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_fd (zocket); zsocket_destroy (ctx, zocket); # endif # if defined (ZMQ_EVENTS) zocket = zsocket_new (ctx, ZMQ_SUB); assert (zocket); zsocket_events (zocket); zsocket_destroy (ctx, zocket); # endif #endif zctx_destroy (&ctx); ---- czmq-3.0.2/doc/zmsg.30000664000175000017500000003700312533132165013405 0ustar00phph00000000000000'\" t .\" Title: zmsg .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZMSG" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zmsg \- working with multipart messages .SH "SYNOPSIS" .sp .nf // Create a new empty message object CZMQ_EXPORT zmsg_t * zmsg_new (); // Destroy a message object and all frames it contains CZMQ_EXPORT void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted\&. Does a blocking recv\&. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zmsg_recv (void *source); // Send message to destination socket, and destroy the message after sending // it successfully\&. If the message has no frames, sends nothing but destroys // the message anyhow\&. Nullifies the caller\*(Aqs reference to the message (as // it is a destructor)\&. CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); // Return size of message, i\&.e\&. number of frames (0 or more)\&. CZMQ_EXPORT size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message\&. CZMQ_EXPORT size_t zmsg_content_size (zmsg_t *self); // Push frame to the front of the message, i\&.e\&. before all other frames\&. // Message takes ownership of frame, will destroy it when message is sent\&. // Returns 0 on success, \-1 on error\&. Deprecates zmsg_push, which did not // nullify the caller\*(Aqs frame reference\&. CZMQ_EXPORT int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i\&.e\&. after all other frames\&. // Message takes ownership of frame, will destroy it when message is sent\&. // Returns 0 on success\&. Deprecates zmsg_add, which did not nullify the // caller\*(Aqs frame reference\&. CZMQ_EXPORT int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any\&. Returns frame, or NULL\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame\&. // Returns 0 on success, \-1 on error\&. CZMQ_EXPORT int zmsg_pushmem (zmsg_t *self, const void *src, size_t size); // Add block of memory to the end of the message, as a new frame\&. // Returns 0 on success, \-1 on error\&. CZMQ_EXPORT int zmsg_addmem (zmsg_t *self, const void *src, size_t size); // Push string as new frame to front of message\&. // Returns 0 on success, \-1 on error\&. CZMQ_EXPORT int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message\&. // Returns 0 on success, \-1 on error\&. CZMQ_EXPORT int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message\&. // Returns 0 on success, \-1 on error\&. CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Push formatted string as new frame to end of message\&. // Returns 0 on success, \-1 on error\&. CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Pop frame off front of message, return as fresh string\&. If there were // no more frames in the message, returns NULL\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame\&. Message takes ownership of // submessage, so the original is destroyed in this call\&. Returns 0 on // success, \-1 on error\&. CZMQ_EXPORT int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any\&. Returns zmsg_t, or NULL if // decoding was not succesfull\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present\&. Does not destroy frame\&. CZMQ_EXPORT void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message\&. Returns frame, or NULL, if the // message is empty\&. Use this to navigate the frames as a list\&. CZMQ_EXPORT zframe_t * zmsg_first (zmsg_t *self); // Return the next frame\&. If there are no more frames, returns NULL\&. To move // to the first frame call zmsg_first()\&. Advances the cursor\&. CZMQ_EXPORT zframe_t * zmsg_next (zmsg_t *self); // Return the last frame\&. If there are no frames, returns NULL\&. CZMQ_EXPORT zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else \-1\&. The message is // saved as a series of frames, each with length and data\&. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ\&. The file format is at present undocumented and liable // to arbitrary change\&. CZMQ_EXPORT int zmsg_save (zmsg_t *self, FILE *file); // Load/append an open file into message, create new message if // null message provided\&. Returns NULL if the message could not // be loaded\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zmsg_load (zmsg_t *self, FILE *file); // Serialize multipart message to a single buffer\&. Use this method to send // structured messages across transports that do not support multipart data\&. // Allocates and returns a new buffer containing the serialized message\&. // To decode a serialized message buffer, use zmsg_decode ()\&. CZMQ_EXPORT size_t zmsg_encode (zmsg_t *self, byte **buffer); // Decodes a serialized message buffer created by zmsg_encode () and returns // a new zmsg_t object\&. Returns NULL if the buffer was badly formatted or // there was insufficient memory to work\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zmsg_decode (const byte *buffer, size_t buffer_size); // Create copy of message, as new message object\&. Returns a fresh zmsg_t // object\&. If message is null, or memory was exhausted, returns null\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream)\&. CZMQ_EXPORT void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message\&. As with zframe_eq, return false if either message is NULL\&. CZMQ_EXPORT bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Generate a signal message encoding the given status\&. A signal is a short // message carrying a 1\-byte success/failure code (by convention, 0 means // OK)\&. Signals are encoded to be distinguishable from "normal" messages\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zmsg_t * zmsg_new_signal (byte status); // Return signal value, 0 or greater, if message is a signal, \-1 if not\&. CZMQ_EXPORT int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t\&. CZMQ_EXPORT bool zmsg_is (void *self); // Self test of this class CZMQ_EXPORT void zmsg_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zmsg class provides methods to send and receive multipart messages across 0MQ sockets\&. This class provides a list\-like container interface, with methods to work with the overall container\&. zmsg_t messages are composed of zero or more zframe_t frames\&. .sp Please add @discuss section in \&.\&./src/zmsg\&.c\&. .SH "EXAMPLE" .PP \fBFrom zmsg_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zmsg\&.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zmsg\&.test"); assert (input); // Test send and receive of single\-frame message zmsg_t *msg = zmsg_new (); assert (msg); zframe_t *frame = zframe_new ("Hello", 5); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); rc = zmsg_send (&msg, output); assert (msg == NULL); assert (rc == 0); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); zmsg_destroy (&msg); // Test send and receive of multi\-frame message msg = zmsg_new (); assert (msg); rc = zmsg_addmem (msg, "Frame0", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame1", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame2", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame3", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame4", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame5", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame6", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame7", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame8", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame9", 6); assert (rc == 0); zmsg_t *copy = zmsg_dup (msg); assert (copy); rc = zmsg_send (©, output); assert (rc == 0); rc = zmsg_send (&msg, output); assert (rc == 0); copy = zmsg_recv (input); assert (copy); assert (zmsg_size (copy) == 10); assert (zmsg_content_size (copy) == 60); zmsg_destroy (©); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // create empty file for null test FILE *file = fopen ("zmsg\&.test", "w"); assert (file); fclose (file); file = fopen ("zmsg\&.test", "r"); zmsg_t *null_msg = zmsg_load (NULL, file); assert (null_msg == NULL); fclose (file); remove ("zmsg\&.test"); // Save to a file, read back file = fopen ("zmsg\&.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg\&.test", "r"); rc = zmsg_save (msg, file); assert (rc == \-1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg\&.test", "r"); msg = zmsg_load (NULL, file); assert (msg); fclose (file); remove ("zmsg\&.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Remove all frames except first and last int frame_nbr; for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) { zmsg_first (msg); frame = zmsg_next (msg); zmsg_remove (msg, frame); zframe_destroy (&frame); } // Test message frame manipulation assert (zmsg_size (msg) == 2); frame = zmsg_last (msg); assert (zframe_streq (frame, "Frame9")); assert (zmsg_content_size (msg) == 12); frame = zframe_new ("Address", 7); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 3); rc = zmsg_addstr (msg, "Body"); assert (rc == 0); assert (zmsg_size (msg) == 4); frame = zmsg_pop (msg); zframe_destroy (&frame); assert (zmsg_size (msg) == 3); char *body = zmsg_popstr (msg); assert (streq (body, "Frame0")); free (body); zmsg_destroy (&msg); // Test encoding/decoding msg = zmsg_new (); assert (msg); byte *blank = (byte *) zmalloc (100000); assert (blank); rc = zmsg_addmem (msg, blank, 0); assert (rc == 0); rc = zmsg_addmem (msg, blank, 1); assert (rc == 0); rc = zmsg_addmem (msg, blank, 253); assert (rc == 0); rc = zmsg_addmem (msg, blank, 254); assert (rc == 0); rc = zmsg_addmem (msg, blank, 255); assert (rc == 0); rc = zmsg_addmem (msg, blank, 256); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65535); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65536); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65537); assert (rc == 0); free (blank); assert (zmsg_size (msg) == 9); byte *buffer; size_t buffer_size = zmsg_encode (msg, &buffer); zmsg_destroy (&msg); msg = zmsg_decode (buffer, buffer_size); assert (msg); free (buffer); zmsg_destroy (&msg); // Test submessages msg = zmsg_new (); assert (msg); zmsg_t *submsg = zmsg_new (); zmsg_pushstr (msg, "matr"); zmsg_pushstr (submsg, "joska"); rc = zmsg_addmsg (msg, &submsg); assert (rc == 0); assert (submsg == NULL); submsg = zmsg_popmsg (msg); assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded submsg = zmsg_popmsg (msg); assert (submsg); body = zmsg_popstr (submsg); assert (streq (body, "joska")); free (body); zmsg_destroy (&submsg); frame = zmsg_pop (msg); assert (frame == NULL); zmsg_destroy (&msg); // Test comparison of two messages msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); zmsg_addstr (msg, "Three"); zmsg_t *msg_other = zmsg_new (); zmsg_addstr (msg_other, "One"); zmsg_addstr (msg_other, "Two"); zmsg_addstr (msg_other, "One\-Hundred"); zmsg_t *msg_dup = zmsg_dup (msg); zmsg_t *empty_msg = zmsg_new (); zmsg_t *empty_msg_2 = zmsg_new (); assert (zmsg_eq (msg, msg_dup)); assert (!zmsg_eq (msg, msg_other)); assert (zmsg_eq (empty_msg, empty_msg_2)); assert (!zmsg_eq (msg, NULL)); assert (!zmsg_eq (NULL, empty_msg)); assert (!zmsg_eq (NULL, NULL)); zmsg_destroy (&msg); zmsg_destroy (&msg_other); zmsg_destroy (&msg_dup); zmsg_destroy (&empty_msg); zmsg_destroy (&empty_msg_2); // Test signal messages msg = zmsg_new_signal (0); assert (zmsg_signal (msg) == 0); zmsg_destroy (&msg); msg = zmsg_new_signal (\-1); assert (zmsg_signal (msg) == 255); zmsg_destroy (&msg); // Now try methods on an empty message msg = zmsg_new (); assert (msg); assert (zmsg_size (msg) == 0); assert (zmsg_unwrap (msg) == NULL); assert (zmsg_first (msg) == NULL); assert (zmsg_last (msg) == NULL); assert (zmsg_next (msg) == NULL); assert (zmsg_pop (msg) == NULL); // Sending an empty message is valid and destroys the message assert (zmsg_send (&msg, output) == 0); assert (!msg); zsock_destroy (&input); zsock_destroy (&output); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zstr.30000664000175000017500000001402112533132170013416 0ustar00phph00000000000000'\" t .\" Title: zstr .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZSTR" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zstr \- sending and receiving strings .SH "SYNOPSIS" .sp .nf // Receive C string from socket\&. Caller must free returned string using // zstr_free()\&. Returns NULL if the context is being terminated or the // process was interrupted\&. CZMQ_EXPORT char * zstr_recv (void *source); // Send a C string to a socket, as a frame\&. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string\&. String // may be NULL, which is sent as ""\&. CZMQ_EXPORT int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi\-part message\&. CZMQ_EXPORT int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket\&. Note that you should NOT use // user\-supplied strings in the format (they may contain \*(Aq%\*(Aq which // will create security holes)\&. CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, \&.\&.\&.); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi\-part // message\&. CZMQ_EXPORT int zstr_sendfm (void *dest, const char *format, \&.\&.\&.); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or \-1 on error\&. CZMQ_EXPORT int zstr_sendx (void *dest, const char *string, \&.\&.\&.); // Receive a series of strings (until NULL) from multipart data\&. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL\&. // Returns \-1 if the message could not be read, else returns the // number of strings filled, zero or more\&. Free each returned string // using zstr_free()\&. If not enough strings are provided, remaining // multipart frames in the message are dropped\&. CZMQ_EXPORT int zstr_recvx (void *source, char **string_p, \&.\&.\&.); // Free a provided string, and nullify the parent pointer\&. Safe to call on // a null pointer\&. CZMQ_EXPORT void zstr_free (char **string_p); // Self test of this class CZMQ_EXPORT void zstr_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zstr class provides utility functions for sending and receiving C strings across 0MQ sockets\&. It sends strings without a terminating null, and appends a null byte on received strings\&. This class is for simple message sending\&. .sp .if n \{\ .RS 4 .\} .nf Memory Wire +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+ +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+ Send | S t r i n g | 0 | \-\-\-\-> | 6 | S t r i n g | +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+ +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+ .fi .if n \{\ .RE .\} .sp .if n \{\ .RS 4 .\} .nf Wire Heap +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+ Recv | 6 | S t r i n g | \-\-\-\-> | S t r i n g | 0 | +\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-+ .fi .if n \{\ .RE .\} .SH "EXAMPLE" .PP \fBFrom zstr_test method\fR. .sp .if n \{\ .RS 4 .\} .nf // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zstr\&.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zstr\&.test"); assert (input); // Send ten strings, five strings with MORE flag and then END int string_nbr; for (string_nbr = 0; string_nbr < 10; string_nbr++) zstr_sendf (output, "this is string %d", string_nbr); zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL); // Read and count until we receive END string_nbr = 0; for (string_nbr = 0;; string_nbr++) { char *string = zstr_recv (input); assert (string); if (streq (string, "END")) { zstr_free (&string); break; } zstr_free (&string); } assert (string_nbr == 15); zsock_destroy (&input); zsock_destroy (&output); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zproxy_v2.30000664000175000017500000001236312533132200014377 0ustar00phph00000000000000'\" t .\" Title: zproxy_v2 .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZPROXY_V2" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zproxy_v2 \- run a steerable proxy in the background (deprecated) .SH "SYNOPSIS" .sp .nf // Constructor // Create a new zproxy object\&. You must create the frontend and backend // sockets, configure them, and connect or bind them, before you pass them // to the constructor\&. Do NOT use the sockets again, after passing them to // this method\&. CZMQ_EXPORT zproxy_t * zproxy_new (zctx_t *ctx, void *frontend, void *backend); // Destructor // Destroy a zproxy object; note this first stops the proxy\&. CZMQ_EXPORT void zproxy_destroy (zproxy_t **self_p); // Copy all proxied messages to specified endpoint; if this is NULL, any // in\-progress capturing will be stopped\&. You must already have bound the // endpoint to a PULL socket\&. CZMQ_EXPORT void zproxy_capture (zproxy_t *self, const char *endpoint); // Pauses a zproxy object; a paused proxy will cease processing messages, // causing them to be queued up and potentially hit the high\-water mark on // the frontend socket, causing messages to be dropped, or writing // applications to block\&. CZMQ_EXPORT void zproxy_pause (zproxy_t *self); // Resume a zproxy object CZMQ_EXPORT void zproxy_resume (zproxy_t *self); // Self test of this class CZMQ_EXPORT void zproxy_v2_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zproxy class provides an equivalent to the ZMQ steerable proxy, on all versions of ZeroMQ\&. .sp This class is deprecated in CZMQ v3; it works together with zctx, zsocket, and other deprecated V2 classes\&. New applications should use the V3 zproxy interface, based on zactor, together with the zsock class for sockets\&. .SH "EXAMPLE" .PP \fBFrom zproxy_v2_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zctx_t *ctx = zctx_new (); assert (ctx); void *frontend = zsocket_new (ctx, ZMQ_PULL); assert (frontend); int rc = zsocket_bind (frontend, "inproc://frontend"); assert (rc == 0); void *backend = zsocket_new (ctx, ZMQ_PUSH); assert (backend); rc = zsocket_bind (backend, "inproc://backend"); assert (rc == 0); zproxy_t *proxy = zproxy_new (ctx, frontend, backend); assert (proxy); // Connect application sockets to proxy void *faucet = zsocket_new (ctx, ZMQ_PUSH); assert (faucet); rc = zsocket_connect (faucet, "inproc://frontend"); assert (rc == 0); void *sink = zsocket_new (ctx, ZMQ_PULL); assert (sink); rc = zsocket_connect (sink, "inproc://backend"); assert (rc == 0); // Send some messages and check they arrived zstr_send (faucet, "Hello"); char *string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); // Check pause/resume functionality zproxy_pause (proxy); zstr_send (faucet, "World"); zproxy_resume (proxy); string = zstr_recv (sink); assert (streq (string, "World")); zstr_free (&string); // Create capture socket, must be a PULL socket void *capture = zsocket_new (ctx, ZMQ_PULL); assert (capture); rc = zsocket_bind (capture, "inproc://capture"); assert (rc == 0); // Switch on capturing, check that it works zproxy_capture (proxy, "inproc://capture"); zstr_send (faucet, "Hello"); string = zstr_recv (sink); assert (streq (string, "Hello")); zstr_free (&string); string = zstr_recv (capture); assert (streq (string, "Hello")); zstr_free (&string); zproxy_destroy (&proxy); zctx_destroy (&ctx); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zmutex.30000664000175000017500000000621512533132200013750 0ustar00phph00000000000000'\" t .\" Title: zmutex .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZMUTEX" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zmutex \- working with mutexes (deprecated) .SH "SYNOPSIS" .sp .nf // Create a new mutex container CZMQ_EXPORT zmutex_t * zmutex_new (void); // Destroy a mutex container CZMQ_EXPORT void zmutex_destroy (zmutex_t **self_p); // Lock mutex CZMQ_EXPORT void zmutex_lock (zmutex_t *self); // Unlock mutex CZMQ_EXPORT void zmutex_unlock (zmutex_t *self); // Try to lock mutex CZMQ_EXPORT int zmutex_try_lock (zmutex_t *self); // Self test of this class CZMQ_EXPORT void zmutex_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zmutex class provides a portable wrapper for mutexes\&. Please do not use this class to do multi\-threading\&. It is for the rare case where you absolutely need thread\-safe global state\&. This should happen in system code only\&. DO NOT USE THIS TO SHARE SOCKETS BETWEEN THREADS, OR DARK THINGS WILL HAPPEN TO YOUR CODE\&. .sp Please add @discuss section in \&.\&./src/zmutex\&.c\&. .SH "EXAMPLE" .PP \fBFrom zmutex_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zmutex_t *mutex = zmutex_new (); assert (mutex); zmutex_lock (mutex); zmutex_unlock (mutex); zmutex_destroy (&mutex); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zsys.txt0000664000175000017500000004106612533132136014114 0ustar00phph00000000000000zsys(3) ======= NAME ---- zsys - system-level methods SYNOPSIS -------- ---- #define UDP_FRAME_MAX 255 // Max size of UDP frame // Callback for interrupt signal handler typedef void (zsys_handler_fn) (int signal_value); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. CZMQ_EXPORT void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. CZMQ_EXPORT void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. CZMQ_EXPORT zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. CZMQ_EXPORT void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed CZMQ_EXPORT void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_catch_interrupts (void); // Return 1 if file exists, else zero CZMQ_EXPORT bool zsys_file_exists (const char *filename); // Return size of file, or -1 if not found CZMQ_EXPORT ssize_t zsys_file_size (const char *filename); // Return file modification time. Returns 0 if the file does not exist. CZMQ_EXPORT time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. CZMQ_EXPORT int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent CZMQ_EXPORT int zsys_file_delete (const char *filename); // Check if file is 'stable' CZMQ_EXPORT bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as a // printf format. CZMQ_EXPORT int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. CZMQ_EXPORT int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. CZMQ_EXPORT int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. CZMQ_EXPORT void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. CZMQ_EXPORT void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. CZMQ_EXPORT void zsys_version (int *major, int *minor, int *patch); // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. CZMQ_EXPORT char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. CZMQ_EXPORT int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. CZMQ_EXPORT int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. CZMQ_EXPORT bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. CZMQ_EXPORT size_t zsys_socket_limit (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. CZMQ_EXPORT void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. CZMQ_EXPORT size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. CZMQ_EXPORT void zsys_set_ipv6 (int ipv6); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zsys_interface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). CZMQ_EXPORT void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority CZMQ_EXPORT void zsys_error (const char *format, ...); // Log warning condition - high priority CZMQ_EXPORT void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zsys_notice (const char *format, ...); // Log informational message - low priority CZMQ_EXPORT void zsys_info (const char *format, ...); // Log debug-level message - lowest priority CZMQ_EXPORT void zsys_debug (const char *format, ...); // Self test of this class CZMQ_EXPORT void zsys_test (bool verbose); // Global signal indicator, TRUE when user presses Ctrl-C or the process // gets a SIGTERM signal. CZMQ_EXPORT extern volatile int zsys_interrupted; // Deprecated name for this variable CZMQ_EXPORT extern volatile int zctx_interrupted; ---- DESCRIPTION ----------- The zsys class provides a portable wrapper for system calls. We collect them here to reduce the number of weird #ifdefs in other classes. As far as possible, the bulk of CZMQ classes are fully portable. Please add @discuss section in ../src/zsys.c. EXAMPLE ------- .From zsys_test method ---- zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); free (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_io_threads (1); zsys_set_max_sockets (0); zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); // Test pipe creation zsock_t *pipe_back; zsock_t *pipe_front = zsys_create_pipe (&pipe_back); zstr_send (pipe_front, "Hello"); char *string = zstr_recv (pipe_back); assert (streq (string, "Hello")); free (string); zsock_destroy (&pipe_back); zsock_destroy (&pipe_front); // Test file manipulation rc = zsys_file_delete ("nosuchfile"); assert (rc == -1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == -1); time_t when = zsys_file_modified ("."); assert (when > 0); int mode = zsys_file_mode ("."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); zsys_file_mode_private (); rc = zsys_dir_create ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); when = zsys_file_modified ("./.testsys/subdir"); assert (when > 0); assert (!zsys_file_stable ("./.testsys/subdir")); rc = zsys_dir_delete ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", ".", ".testsys"); assert (rc == 0); zsys_file_mode_default (); assert (zsys_dir_change (".") == 0); int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); free (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zmq_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); ---- czmq-3.0.2/doc/zctx.txt0000664000175000017500000001110512533132136014063 0ustar00phph00000000000000zctx(3) ======= NAME ---- zctx - working with 0MQ contexts (deprecated) SYNOPSIS -------- ---- // Create new context, returns context object, replaces zmq_init CZMQ_EXPORT zctx_t * zctx_new (void); // Destroy context and all sockets in it, replaces zmq_term CZMQ_EXPORT void zctx_destroy (zctx_t **self_p); // Create new shadow context, returns context object CZMQ_EXPORT zctx_t * zctx_shadow (zctx_t *self); // Raise default I/O threads from 1, for crazy heavy applications // The rule of thumb is one I/O thread per gigabyte of traffic in // or out. Call this method before creating any sockets on the context, // or calling zctx_shadow, or the setting will have no effect. CZMQ_EXPORT void zctx_set_iothreads (zctx_t *self, int iothreads); // Set msecs to flush sockets when closing them, see the ZMQ_LINGER // man page section for more details. By default, set to zero, so // any in-transit messages are discarded when you destroy a socket or // a context. CZMQ_EXPORT void zctx_set_linger (zctx_t *self, int linger); // Set initial high-water mark for inter-thread pipe sockets. Note that // this setting is separate from the default for normal sockets. You // should change the default for pipe sockets *with care*. Too low values // will cause blocked threads, and an infinite setting can cause memory // exhaustion. The default, no matter the underlying ZeroMQ version, is // 1,000. CZMQ_EXPORT void zctx_set_pipehwm (zctx_t *self, int pipehwm); // Set initial send HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. CZMQ_EXPORT void zctx_set_sndhwm (zctx_t *self, int sndhwm); // Set initial receive HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. CZMQ_EXPORT void zctx_set_rcvhwm (zctx_t *self, int rcvhwm); // Return low-level 0MQ context object, will be NULL before first socket // is created. Use with care. CZMQ_EXPORT void * zctx_underlying (zctx_t *self); // Self test of this class CZMQ_EXPORT void zctx_test (bool 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 (interrupt) handling for the process. The zctx class has these main features: * Tracks all open sockets and automatically closes them before calling zmq_term(). This avoids an infinite wait on open sockets. * Automatically configures sockets with a ZMQ_LINGER timeout you can define, and which defaults to zero. The default behavior of zctx is therefore like 0MQ/2.0, immediate termination with loss of any pending messages. You can set any linger timeout you like by calling the zctx_set_linger() method. * Moves the iothreads configuration to a separate method, so that default usage is 1 I/O thread. Lets you configure this value. * Sets up signal (SIGINT and SIGTERM) handling so that blocking calls such as zmq_recv() and zmq_poll() will return when the user presses Ctrl-C. NOTE: this class is deprecated in favor of zsock, which does not expose contexts in the API at all. All zsock instances use the same global context. EXAMPLE ------- .From zctx_test method ---- // Create and destroy a context without using it zctx_t *ctx = zctx_new (); assert (ctx); zctx_destroy (&ctx); assert (ctx == NULL); // Create a context with many busy sockets, destroy it ctx = zctx_new (); assert (ctx); zctx_set_iothreads (ctx, 1); zctx_set_linger (ctx, 5); // 5 msecs void *s1 = zctx__socket_new (ctx, ZMQ_PAIR); assert (s1); void *s2 = zctx__socket_new (ctx, ZMQ_XREQ); assert (s2); void *s3 = zctx__socket_new (ctx, ZMQ_REQ); assert (s3); void *s4 = zctx__socket_new (ctx, ZMQ_REP); assert (s4); void *s5 = zctx__socket_new (ctx, ZMQ_PUB); assert (s5); void *s6 = zctx__socket_new (ctx, ZMQ_SUB); assert (s6); int rc = zsocket_connect (s1, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s2, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s3, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s4, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s5, "tcp://127.0.0.1:5555"); assert (rc == 0); rc = zsocket_connect (s6, "tcp://127.0.0.1:5555"); assert (rc == 0); assert (zctx_underlying (ctx)); zctx_destroy (&ctx); ---- czmq-3.0.2/doc/zhashx.30000664000175000017500000004216212533132163013732 0ustar00phph00000000000000'\" t .\" Title: zhashx .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZHASHX" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zhashx \- extended generic hash container .SH "SYNOPSIS" .sp .nf // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // compare two items, for sorting typedef void (zhashx_free_fn) ( void *data); // compare two items, for sorting typedef size_t (zhashx_hash_fn) ( const void *key); // DEPRECATED as clumsy \-\- use zhashx_first/_next instead typedef int (zhashx_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhashx_t * zhashx_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhashx_destroy (zhashx_t **self_p); // Insert item into hash table with specified key and item\&. // If key is already present returns \-1 and leaves existing item unchanged // Returns 0 on success\&. CZMQ_EXPORT int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item\&. If the // key is already present, destroys old item and inserts new one\&. If you set // a container item destructor, this is called on the old value\&. If the key // was not already present, inserts a new item\&. Sets the hash cursor to the // new item\&. CZMQ_EXPORT void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table\&. If there was no such // item, this function does nothing\&. CZMQ_EXPORT void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table\&. If the key destructor is // set, calls it on every key\&. If the item destructor is set, calls // it on every item\&. CZMQ_EXPORT void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null CZMQ_EXPORT void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key\&. If there was no such // item, does nothing\&. Returns 0 if successful, else \-1\&. CZMQ_EXPORT int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item\&. When the item is // destroyed, the free function, if any, is called on that item\&. // Use this when hash items are dynamically allocated, to ensure that // you don\*(Aqt have memory leaks\&. You can pass \*(Aqfree\*(Aq or NULL as a free_fn\&. // Returns the item, or NULL if there is no such item\&. CZMQ_EXPORT void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table\&. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table\&. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty\&. This method is simpler to use than the // foreach() method, which is deprecated\&. To access the key for this item // use zhashx_cursor()\&. NOTE: do NOT modify the table while iterating\&. CZMQ_EXPORT void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned\&. Use this together with // zhashx_first() to process all items in a hash table\&. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort()\&. To // access the key for this item use zhashx_cursor()\&. NOTE: do NOT modify // the table while iterating\&. CZMQ_EXPORT void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned\&. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash\&. After an // unsuccessful first/next, returns NULL\&. CZMQ_EXPORT const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk\&. You can add as many // comment lines as you like\&. These comment lines are discarded when loading // the file\&. If you use a null format, all comments are deleted\&. CZMQ_EXPORT void zhashx_comment (zhashx_t *self, const char *format, \&.\&.\&.) CHECK_PRINTF (2); // Save hash table to a text file in name=value format\&. Hash values must be // printable strings; keys may not contain \*(Aq=\*(Aq character\&. Returns 0 if OK, // else \-1 if a file error occurred\&. CZMQ_EXPORT int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist\&. Hash values must printable strings; keys may not contain // \*(Aq=\*(Aq character\&. Returns 0 if OK, else \-1 if a file was not readable\&. CZMQ_EXPORT int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i\&.e\&. not // still changing\&. Returns 0 if OK, \-1 if there was an error reloading the // file\&. CZMQ_EXPORT int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message\&. // The packed format is compatible with the \*(Aqdictionary\*(Aq type defined in // http://rfc\&.zeromq\&.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict\-count *( dict\-name dict\-value ) // dict\-count = number\-4 // dict\-value = longstr // dict\-name = string // // ; Strings are always length + text contents // longstr = number\-4 *VCHAR // string = number\-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number\-1 = 1OCTET // number\-4 = 4OCTET // // Comments are not included in the packed data\&. Item values MUST be // strings\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zframe_t * zhashx_pack (zhashx_t *self); // Unpack binary frame into a new hash table\&. Packed data must follow format // defined by zhashx_pack\&. Hash table is set to autofree\&. An empty frame // unpacks to an empty hash table\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zhashx_t * zhashx_unpack (zframe_t *frame); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not\&. Copying a null reference returns a null // reference\&. Note that this method\*(Aqs behavior changed slightly for CZMQ // v3\&.x, as it does not set nor respect autofree\&. It does however let you // duplicate any hash table safely\&. The old behavior is in zhashx_dup_v2\&. // The caller is responsible for destroying the return value when finished with it\&. CZMQ_EXPORT zhashx_t * zhashx_dup (zhashx_t *self); // Set a user\-defined deallocator for hash items; by default items are not // freed when the hash is destroyed\&. CZMQ_EXPORT void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user\-defined duplicator for hash items; by default items are not // copied when the hash is duplicated\&. CZMQ_EXPORT void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user\-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free()\&. CZMQ_EXPORT void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user\-defined duplicator for keys; by default keys are duplicated // using strdup\&. CZMQ_EXPORT void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user\-defined comparator for keys; by default keys are // compared using strcmp\&. CZMQ_EXPORT void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user\-defined comparator for keys; by default keys are // compared using strcmp\&. CZMQ_EXPORT void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null\&. // Does not copy items themselves\&. Rebuilds new table so may be slow on // very large tables\&. NOTE: only works with item values that are strings // since there\*(Aqs no other way to know how to duplicate the item value\&. CZMQ_EXPORT zhashx_t * zhashx_dup_v2 (zhashx_t *self); // DEPRECATED as clumsy \-\- use set_destructor instead // Set hash for automatic value destruction CZMQ_EXPORT void zhashx_autofree (zhashx_t *self); // DEPRECATED as clumsy \-\- use zhashx_first/_next instead // Apply function to each item in the hash table\&. Items are iterated in no // defined order\&. Stops if callback function returns non\-zero and returns // final return code from callback function (zero = success)\&. // Callback function for zhashx_foreach method CZMQ_EXPORT int zhashx_foreach (zhashx_t *self, zhashx_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhashx_test (int verbose); .fi .SH "DESCRIPTION" .sp zhashx is an extended hash table container with more functionality than zhash, its simpler cousin\&. .sp The hash table always has a size that is prime and roughly doubles its size when 75% full\&. In case of hash collisions items are chained in a linked list\&. The hash table size is increased slightly (up to 5 times before roughly doubling the size) when an overly long chain (between 1 and 63 items depending on table size) is detected\&. .SH "EXAMPLE" .PP \fBFrom zhashx_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zhashx_t *hash = zhashx_new (); assert (hash); assert (zhashx_size (hash) == 0); assert (zhashx_first (hash) == NULL); assert (zhashx_cursor (hash) == NULL); // Insert some items int rc; rc = zhashx_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhashx_first (hash); assert (streq ((char *) zhashx_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhashx_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhashx_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhashx_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhashx_size (hash) == 4); // Look for existing items item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhashx_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhashx_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non\-existent items item = (char *) zhashx_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhashx_insert (hash, "DEADBEEF", "foo"); assert (rc == \-1); item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhashx_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non\-existent key rc = zhashx_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == \-1); // Trying to rename an unknown item to an existing key rc = zhashx_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == \-1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhashx_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == \-1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlistx_t *keys = zhashx_keys (hash); assert (zlistx_size (keys) == 4); zlistx_destroy (&keys); zlistx_t *values = zhashx_values(hash); assert (zlistx_size (values) == 4); zlistx_destroy (&values); // Test dup method zhashx_t *copy = zhashx_dup (hash); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test pack/unpack methods zframe_t *frame = zhashx_pack (hash); copy = zhashx_unpack (frame); zframe_destroy (&frame); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test save and load zhashx_comment (hash, "This is a test file"); zhashx_comment (hash, "Created by %s", "czmq_selftest"); zhashx_save (hash, "\&.cache"); copy = zhashx_new (); assert (copy); zhashx_load (copy, "\&.cache"); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); zsys_file_delete ("\&.cache"); // Delete a item zhashx_delete (hash, "LIVEBEEF"); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhashx_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr]\&.exists) { item = (char *) zhashx_lookup (hash, testset [testnbr]\&.name); assert (item); zhashx_delete (hash, testset [testnbr]\&.name); testset [testnbr]\&.exists = false; } else { sprintf (testset [testnbr]\&.name, "%x\-%x", rand (), rand ()); if (zhashx_insert (hash, testset [testnbr]\&.name, "") == 0) testset [testnbr]\&.exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhashx_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhashx_destroy (&hash); zhashx_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhashx_new (); assert (hash); zhashx_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhashx_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); zhashx_destroy (&hash); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zfile.txt0000664000175000017500000002112212533132136014204 0ustar00phph00000000000000zfile(3) ======== NAME ---- zfile - provides methods to work with files in a portable fashion. SYNOPSIS -------- ---- // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. CZMQ_EXPORT zfile_t * zfile_new (const char *path, const char *name); // Destroy a file item CZMQ_EXPORT void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided CZMQ_EXPORT const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. CZMQ_EXPORT void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. CZMQ_EXPORT bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. CZMQ_EXPORT bool zfile_has_changed (zfile_t *self); // Remove the file from disk CZMQ_EXPORT void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible CZMQ_EXPORT int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. CZMQ_EXPORT int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. CZMQ_EXPORT bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 CZMQ_EXPORT int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. CZMQ_EXPORT const char * zfile_readln (zfile_t *self); // Close file, if open CZMQ_EXPORT void zfile_close (zfile_t *self); // Return file handle, if opened CZMQ_EXPORT FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. CZMQ_EXPORT const char * zfile_digest (zfile_t *self); // Self test of this class. CZMQ_EXPORT void zfile_test (bool verbose); // These methods are deprecated, and now moved to zsys class. CZMQ_EXPORT bool zfile_exists (const char *filename); CZMQ_EXPORT ssize_t zfile_size (const char *filename); CZMQ_EXPORT mode_t zfile_mode (const char *filename); CZMQ_EXPORT int zfile_delete (const char *filename); CZMQ_EXPORT bool zfile_stable (const char *filename); CZMQ_EXPORT int zfile_mkdir (const char *pathname); CZMQ_EXPORT int zfile_rmdir (const char *pathname); CZMQ_EXPORT void zfile_mode_private (void); CZMQ_EXPORT void zfile_mode_default (void); ---- DESCRIPTION ----------- The zfile class provides methods to work with disk files. A file object provides the modified date, current size, and type of the file. You can create a file object for a filename that does not yet exist. To read or write data from the file, use the input and output methods, and then read and write chunks. The output method lets you both read and write chunks, at any offset. Finally, this class provides portable symbolic links. If a filename ends in ".ln", the first line of text in the file is read, and used as the underlying file for read/write operations. This lets you manipulate (e.g.) copy symbolic links without copying the perhaps very large files they point to. This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now). EXAMPLE ------- .From zfile_test method ---- zfile_t *file = zfile_new (NULL, "bilbo"); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (zfile_is_readable (file) == false); zfile_destroy (&file); // Create a test file in some random subdirectory file = zfile_new ("./this/is/a/test", "bilbo"); assert (file); int rc = zfile_output (file); assert (rc == 0); zchunk_t *chunk = zchunk_new (NULL, 100); assert (chunk); zchunk_fill (chunk, 0, 100); // Write 100 bytes at position 1,000,000 in the file rc = zfile_write (file, chunk, 1000000); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_is_readable (file)); assert (zfile_cursize (file) == 1000100); assert (!zfile_is_stable (file)); assert (zfile_digest (file)); // Now truncate file from outside int handle = open ("./this/is/a/test/bilbo", O_WRONLY | O_TRUNC | O_BINARY, 0); assert (handle >= 0); rc = write (handle, "Hello, World\n", 13); assert (rc == 13); close (handle); assert (zfile_has_changed (file)); zclock_sleep (1001); assert (zfile_has_changed (file)); assert (!zfile_is_stable (file)); zfile_restat (file); assert (zfile_is_stable (file)); assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54")); // Check we can read from file rc = zfile_input (file); assert (rc == 0); chunk = zfile_read (file, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_close (file); // Check we can read lines from file rc = zfile_input (file); assert (rc == 0); const char *line = zfile_readln (file); assert (streq (line, "Hello, World")); line = zfile_readln (file); assert (line == NULL); zfile_close (file); // Try some fun with symbolic links zfile_t *link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_output (link); assert (rc == 0); fprintf (zfile_handle (link), "./this/is/a/test/bilbo\n"); zfile_destroy (&link); link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_input (link); assert (rc == 0); chunk = zfile_read (link, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_destroy (&link); // Remove file and directory zdir_t *dir = zdir_new ("./this", NULL); assert (dir); assert (zdir_cursize (dir) == 26); zdir_remove (dir, true); assert (zdir_cursize (dir) == 0); zdir_destroy (&dir); // Check we can no longer read from file assert (zfile_is_readable (file)); zfile_restat (file); assert (!zfile_is_readable (file)); rc = zfile_input (file); assert (rc == -1); zfile_destroy (&file); ---- czmq-3.0.2/doc/zmonitor.30000664000175000017500000001175312533132165014312 0ustar00phph00000000000000'\" t .\" Title: zmonitor .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZMONITOR" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zmonitor \- socket event monitor .SH "SYNOPSIS" .sp .nf // Create new zmonitor actor instance to monitor a zsock_t socket: // // zactor_t *monitor = zactor_new (zmonitor, mysocket); // // Destroy zmonitor instance\&. // // zactor_destroy (&monitor); // // Enable verbose logging of commands and activity\&. // // zstr_send (monitor, "VERBOSE"); // // Listen to monitor event type (zero or types, ending in NULL): // zstr_sendx (monitor, "LISTEN", type, \&.\&.\&., NULL); // // Events: // CONNECTED // CONNECT_DELAYED // CONNECT_RETRIED // LISTENING // BIND_FAILED // ACCEPTED // ACCEPT_FAILED // CLOSED // CLOSE_FAILED // DISCONNECTED // MONITOR_STOPPED // ALL // // Start monitor; after this, any further LISTEN commands are ignored\&. // // zstr_send (monitor, "START"); // zsock_wait (monitor); // // Receive next monitor event: // // zmsg_t *msg = zmsg_recv (monitor); // // This is the zmonitor constructor as a zactor_fn; the argument can be // a zactor_t, zsock_t, or libzmq void * socket: CZMQ_EXPORT void zmonitor (zsock_t *pipe, void *sock); // Selftest CZMQ_EXPORT void zmonitor_test (bool verbose); .fi .SH "DESCRIPTION" .sp The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc\&. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints\&. .sp This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details\&. Works on all versions of libzmq from 3\&.2 onwards\&. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock)\&. .SH "EXAMPLE" .PP \fBFrom zmonitor_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zactor_t *clientmon = zactor_new (zmonitor, client); assert (clientmon); if (verbose) zstr_sendx (clientmon, "VERBOSE", NULL); zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL); zstr_sendx (clientmon, "START", NULL); zsock_wait (clientmon); zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon); // Allow a brief time for the message to get there\&.\&.\&. zmq_poll (NULL, 0, 200); // Check client is now listening int port_nbr = zsock_bind (client, "tcp://127\&.0\&.0\&.1:*"); assert (port_nbr != \-1); s_assert_event (clientmon, "LISTENING"); // Check server connected to client zsock_connect (server, "tcp://127\&.0\&.0\&.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED"); // Check client accepted connection s_assert_event (clientmon, "ACCEPTED"); zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/doc/zsys.30000664000175000017500000004564112533132172013442 0ustar00phph00000000000000'\" t .\" Title: zsys .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/01/2015 .\" Manual: CZMQ Manual .\" Source: CZMQ 3.0.1 .\" Language: English .\" .TH "ZSYS" "3" "06/01/2015" "CZMQ 3\&.0\&.1" "CZMQ Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" zsys \- system\-level methods .SH "SYNOPSIS" .sp .nf #define UDP_FRAME_MAX 255 // Max size of UDP frame // Callback for interrupt signal handler typedef void (zsys_handler_fn) (int signal_value); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e\&.g\&. logging is properly set\-up before you start working\&. // Not threadsafe, so call only from main thread\&. Safe to call multiple // times\&. Returns global CZMQ context\&. CZMQ_EXPORT void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls\&. CZMQ_EXPORT void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time\&. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock\&. Note: you should not use // this method in CZMQ apps, use zsock_new() instead\&. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket\&. You should call this for every socket you // create using zsys_socket()\&. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc\&. // The pipe is configured to use the zsys_pipehwm setting\&. Returns the // frontend socket successful, NULL if failed\&. CZMQ_EXPORT zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them\&. If you call this multiple times // then the last handler will take affect\&. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ\&. CZMQ_EXPORT void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed CZMQ_EXPORT void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl\-C or SIGTERM will set // zsys_interrupted\&. Idempotent; safe to call multiple times\&. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_catch_interrupts (void); // Return 1 if file exists, else zero CZMQ_EXPORT bool zsys_file_exists (const char *filename); // Return size of file, or \-1 if not found CZMQ_EXPORT ssize_t zsys_file_size (const char *filename); // Return file modification time\&. Returns 0 if the file does not exist\&. CZMQ_EXPORT time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes\&. // Returns a mode_t cast to int, or \-1 in case of error\&. CZMQ_EXPORT int zsys_file_mode (const char *filename); // Delete file\&. Does not complain if the file is absent CZMQ_EXPORT int zsys_file_delete (const char *filename); // Check if file is \*(Aqstable\*(Aq CZMQ_EXPORT bool zsys_file_stable (const char *filename); // Create a file path if it doesn\*(Aqt exist\&. The file path is treated as a // printf format\&. CZMQ_EXPORT int zsys_dir_create (const char *pathname, \&.\&.\&.); // Remove a file path if empty; the pathname is treated as printf format\&. CZMQ_EXPORT int zsys_dir_delete (const char *pathname, \&.\&.\&.); // Move to a specified working directory\&. Returns 0 if OK, \-1 if this failed\&. CZMQ_EXPORT int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only\&. CZMQ_EXPORT void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults\&. CZMQ_EXPORT void zsys_file_mode_default (void); // Return the CZMQ version for run\-time API detection; returns version // number into provided fields, providing reference isn\*(Aqt null in each case\&. CZMQ_EXPORT void zsys_version (int *major, int *minor, int *patch); // Format a string using printf formatting, returning a freshly allocated // buffer\&. If there was insufficient memory, returns NULL\&. Free the returned // string using zstr_free()\&. CZMQ_EXPORT char * zsys_sprintf (const char *format, \&.\&.\&.); // Format a string with a va_list argument, returning a freshly allocated // buffer\&. If there was insufficient memory, returns NULL\&. Free the returned // string using zstr_free()\&. CZMQ_EXPORT char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast\&. This method // and related ones might _eventually_ be moved to a zudp class\&. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return \-1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array\&. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors\&. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints\&. Caller gets // a freshly allocated string, should free it using zstr_free()\&. If the host // name is not resolvable, returns NULL\&. CZMQ_EXPORT char * zsys_hostname (void); // Move the current process into the background\&. The precise effect depends // on the operating system\&. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP\&. On // Windows, does nothing\&. Returns 0 if OK, \-1 if there was an error\&. CZMQ_EXPORT int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user\&. Any of the arguments // may be null, indicating a no\-op\&. Returns 0 on success, \-1 on failure\&. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID\&. CZMQ_EXPORT int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security\&. // Uses a heuristic probe according to the version of libzmq being used\&. CZMQ_EXPORT bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use\&. A good // rule of thumb is one thread per gigabit of traffic in or out\&. The // default is 1, sufficient for most applications\&. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default\&. // Note that this method is valid only before any socket is created\&. CZMQ_EXPORT void zsys_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow\&. The default // is 1024\&. The actual limit depends on the system, and you can query it // by using zsys_socket_limit ()\&. A value of zero means "maximum"\&. // Note that this method is valid only before any socket is created\&. CZMQ_EXPORT void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support\&. CZMQ_EXPORT size_t zsys_socket_limit (void); // Configure the default linger timeout in msecs for new zsock instances\&. // You can also set this separately on each zsock_t instance\&. The default // linger time is zero, i\&.e\&. any pending messages will be dropped\&. If the // environment variable ZSYS_LINGER is defined, that provides the default\&. // Note that process exit will typically be delayed by the linger time\&. CZMQ_EXPORT void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances\&. // You can also set this separately on each zsock_t instance\&. The default // HWM is 1,000, on all versions of ZeroMQ\&. If the environment variable // ZSYS_SNDHWM is defined, that provides the default\&. Note that a value of // zero means no limit, i\&.e\&. infinite memory consumption\&. CZMQ_EXPORT void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances\&. // You can also set this separately on each zsock_t instance\&. The default // HWM is 1,000, on all versions of ZeroMQ\&. If the environment variable // ZSYS_RCVHWM is defined, that provides the default\&. Note that a value of // zero means no limit, i\&.e\&. infinite memory consumption\&. CZMQ_EXPORT void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm)\&. The default HWM is // 1,000, on all versions of ZeroMQ\&. If the environment var ZSYS_ACTORHWM is // defined, that provides the default\&. Note that a value of zero means no // limit, i\&.e\&. infinite memory consumption\&. CZMQ_EXPORT void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes\&. CZMQ_EXPORT size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances\&. By default sockets accept // and make only IPv4 connections\&. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers\&. You can override the setting on // each zsock_t instance\&. The default is IPv4 only (ipv6 set to 0)\&. If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default\&. Note: has no effect on ZMQ v2\&. CZMQ_EXPORT void zsys_set_ipv6 (int ipv6); // Set network interface name to use for broadcasts, particularly zbeacon\&. // This lets the interface be configured for test environments where required\&. // For example, on Mac OS X, zbeacon cannot bind to 255\&.255\&.255\&.255 which is // the default when there is no specified interface\&. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name\&. // Setting the interface to "*" means "use all available interfaces"\&. CZMQ_EXPORT void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set\&. CZMQ_EXPORT const char * zsys_interface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process\&. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set\&. CZMQ_EXPORT void zsys_set_logident (const char *value); // Set stream to receive log traffic\&. By default, log traffic is sent to // stdout\&. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility)\&. CZMQ_EXPORT void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint\&. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint\&. Log traffic is sent as a // single string frame, in the same format as when sent to stdout\&. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints\&. To disable the sender, call // this method with a null argument\&. CZMQ_EXPORT void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows)\&. By default this is disabled\&. CZMQ_EXPORT void zsys_set_logsystem (bool logsystem); // Log error condition \- highest priority CZMQ_EXPORT void zsys_error (const char *format, \&.\&.\&.); // Log warning condition \- high priority CZMQ_EXPORT void zsys_warning (const char *format, \&.\&.\&.); // Log normal, but significant, condition \- normal priority CZMQ_EXPORT void zsys_notice (const char *format, \&.\&.\&.); // Log informational message \- low priority CZMQ_EXPORT void zsys_info (const char *format, \&.\&.\&.); // Log debug\-level message \- lowest priority CZMQ_EXPORT void zsys_debug (const char *format, \&.\&.\&.); // Self test of this class CZMQ_EXPORT void zsys_test (bool verbose); // Global signal indicator, TRUE when user presses Ctrl\-C or the process // gets a SIGTERM signal\&. CZMQ_EXPORT extern volatile int zsys_interrupted; // Deprecated name for this variable CZMQ_EXPORT extern volatile int zctx_interrupted; .fi .SH "DESCRIPTION" .sp The zsys class provides a portable wrapper for system calls\&. We collect them here to reduce the number of weird #ifdefs in other classes\&. As far as possible, the bulk of CZMQ classes are fully portable\&. .sp Please add @discuss section in \&.\&./src/zsys\&.c\&. .SH "EXAMPLE" .PP \fBFrom zsys_test method\fR. .sp .if n \{\ .RS 4 .\} .nf zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); free (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_io_threads (1); zsys_set_max_sockets (0); zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); // Test pipe creation zsock_t *pipe_back; zsock_t *pipe_front = zsys_create_pipe (&pipe_back); zstr_send (pipe_front, "Hello"); char *string = zstr_recv (pipe_back); assert (streq (string, "Hello")); free (string); zsock_destroy (&pipe_back); zsock_destroy (&pipe_front); // Test file manipulation rc = zsys_file_delete ("nosuchfile"); assert (rc == \-1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == \-1); time_t when = zsys_file_modified ("\&."); assert (when > 0); int mode = zsys_file_mode ("\&."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); zsys_file_mode_private (); rc = zsys_dir_create ("%s/%s", "\&.", "\&.testsys/subdir"); assert (rc == 0); when = zsys_file_modified ("\&./\&.testsys/subdir"); assert (when > 0); assert (!zsys_file_stable ("\&./\&.testsys/subdir")); rc = zsys_dir_delete ("%s/%s", "\&.", "\&.testsys/subdir"); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", "\&.", "\&.testsys"); assert (rc == 0); zsys_file_mode_default (); assert (zsys_dir_change ("\&.") == 0); int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,\&."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); free (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zmq_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); .fi .if n \{\ .RE .\} .sp .SH "AUTHORS" .sp The czmq manual was written by the authors in the AUTHORS file\&. .SH "RESOURCES" .sp Main web site: \m[blue]\fB\%\fR\m[] .sp Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2> .SH "COPYRIGHT" .sp Copyright (c) 1991\-2012 iMatix Corporation \-\- http://www\&.imatix\&.com Copyright other contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&. .SH "NOTES" .IP " 1." 4 zeromq-dev@lists.zeromq.org .RS 4 \%mailto:zeromq-dev@lists.zeromq.org .RE czmq-3.0.2/configure.ac0000775000175000017500000002310712535241704014067 0ustar00phph00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) # # The version number is extracted from include/czmq.h using # the version.sh script. Hence, it should be updated there. # The version in git should reflect the *next* version planned. # AC_INIT([czmq],[m4_esyscmd([./version.sh czmq])],[zeromq-dev@lists.zeromq.org]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(config) AC_CONFIG_HEADERS([src/platform.h]) AM_INIT_AUTOMAKE([subdir-objects tar-ustar foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # 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], [CZMQ major version]) AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],[$PV_MINOR], [CZMQ minor version]) AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCH],[$PV_PATCH], [CZMQ patchlevel]) # This lets us use PACKAGE_VERSION in Makefiles AC_SUBST(PACKAGE_VERSION) # # Libtool -version-info (ABI version) # # Currently 2.0.1 ("stable"). 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 # # libczmq -version-info LTVER="3:0:0" AC_SUBST(LTVER) # Capture c flags CZMQ_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 PKG_PROG_PKG_CONFIG # Code coverage AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no], [With GCC Code Coverage reporting.])], [CZMQ_GCOV="$withval"]) if test "x${CZMQ_GCOV}" == "xyes"; then CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" if test "x${CZMQ_ORIG_CFLAGS}" != "xnone"; then CFLAGS="${CFLAGS} ${CZMQ_ORIG_CFLAGS}" fi fi PREVIOUS_CFLAGS="${CFLAGS}" PREVIOUS_LIBS="${LIBS}" was_zmq_check_lib_detected=no PKG_CHECK_MODULES([zmq], [libzmq],, [ AC_ARG_WITH([libzmq], [ AS_HELP_STRING([--with-libzmq], [Specify libzmq prefix]) ], [search_libzmq="yes"], []) zmq_synthetic_cflags="" zmq_synthetic_libs="-lzmq" if test "x$search_libzmq" = "xyes"; then if test -r "${with_libzmq}/include/zmq.h"; then zmq_synthetic_cflags="-I${with_libzmq}/include" zmq_synthetic_libs="-L${with_libzmq}/lib -lzmq" else AC_MSG_ERROR([${with_libzmq}/include/zmq.h not found. Please check libzmq prefix]) fi fi CFLAGS="${zmq_synthetic_cflags} ${CFLAGS}" LDFLAGS="${zmq_synthetic_libs} ${LDFLAGS}" LIBS="${zmq_synthetic_libs} ${LIBS}" AC_CHECK_LIB([zmq], [zmq_init], [ AC_SUBST([zmq_CFLAGS],[${zmq_synthetic_cflags}]) AC_SUBST([zmq_LIBS],[${zmq_synthetic_libs}]) was_zmq_check_lib_detected=yes ], [AC_MSG_ERROR([cannot link with -lzmq, install libzmq.])]) ]) if test "x$was_zmq_check_lib_detected" = "xno"; then CFLAGS="${zmq_CFLAGS} ${CFLAGS}" LIBS="${zmq_LIBS} ${LIBS}" fi CFLAGS="${PREVIOUS_CFLAGS}" LIBS="${PREVIOUS_LIBS}" # Platform specific checks czmq_on_mingw32="no" czmq_on_cygwin="no" czmq_on_android="no" # Host specific checks AC_CANONICAL_HOST # Determine whether or not documentation should be built and installed. czmq_build_doc="yes" czmq_install_man="yes" # Check for asciidoc and xmlto and don't build the docs if these are not installed. AC_CHECK_PROG(czmq_have_asciidoc, asciidoc, yes, no) AC_CHECK_PROG(czmq_have_xmlto, xmlto, yes, no) if test "x$czmq_have_asciidoc" = "xno" -o "x$czmq_have_xmlto" = "xno"; then czmq_build_doc="no" # Tarballs built with 'make dist' ship with prebuilt documentation. if ! test -f doc/czmq.7; then czmq_install_man="no" AC_MSG_WARN([You are building an unreleased version of CZMQ 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([$czmq_build_doc]) AC_MSG_CHECKING([whether to install manpages]) AC_MSG_RESULT([$czmq_install_man]) # Set some default features required by libczmq 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(CZMQ_HAVE_LINUX, 1, [Have Linux OS]) case "${host_os}" in *android*) AC_DEFINE(CZMQ_HAVE_ANDROID, 1, [Have Android OS]) czmq_on_android="yes" ;; esac ;; *solaris*) # Define on Solaris to enable all library features CPPFLAGS="-D_PTHREADS $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_SOLARIS, 1, [Have Solaris OS]) CFLAGS="${CFLAGS} -lsocket -lssp" ;; *freebsd*) # Define on FreeBSD to enable all library features CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_FREEBSD, 1, [Have FreeBSD OS]) ;; *darwin*) # Define on Darwin to enable all library features CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) ;; *netbsd*) # Define on NetBSD to enable all library features CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_NETBSD, 1, [Have NetBSD OS]) ;; *openbsd*) # Define on OpenBSD to enable all library features CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS]) ;; *nto-qnx*) AC_DEFINE(CZMQ_HAVE_QNXNTO, 1, [Have QNX Neutrino OS]) ;; *aix*) AC_DEFINE(CZMQ_HAVE_AIX, 1, [Have AIX OS]) ;; *hpux*) # Define on HP-UX to enable all library features CPPFLAGS="-D_POSIX_C_SOURCE=200112L" AC_DEFINE(CZMQ_HAVE_HPUX, 1, [Have HPUX OS]) ;; *mingw32*) AC_DEFINE(CZMQ_HAVE_WINDOWS, 1, [Have Windows OS]) AC_DEFINE(CZMQ_HAVE_MINGW32, 1, [Have MinGW32]) AC_CHECK_HEADERS(windows.h) czmq_on_mingw32="yes" czmq_install_man="no" ;; *cygwin*) # Define on Cygwin to enable all library features CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_CYGWIN, 1, [Have Cygwin]) czmq_on_cygwin="yes" ;; *) 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 ifaddrs.h) AC_CHECK_HEADERS([net/if.h net/if_media.h linux/wireless.h], [], [], [ #ifdef HAVE_SYS_SOCKET_H # include #endif #include ]) # 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 AC_C_BIGENDIAN # These options are GNU compiler specific. if test "x$GCC" = "xyes"; then CPPFLAGS="-pedantic -Werror -Wall -Wc++-compat ${CPPFLAGS}" fi AM_CONDITIONAL(ENABLE_SHARED, test "x$enable_shared" = "xyes") AM_CONDITIONAL(ON_MINGW, test "x$czmq_on_mingw32" = "xyes") AM_CONDITIONAL(ON_CYGWIN, test "x$czmq_on_cygwin" = "xyes") AM_CONDITIONAL(ON_ANDROID, test "x$czmq_on_android" = "xyes") AM_CONDITIONAL(INSTALL_MAN, test "x$czmq_install_man" = "xyes") AM_CONDITIONAL(BUILD_DOC, test "x$czmq_build_doc" = "xyes") # Check for makecert intent AC_ARG_WITH([makecert], AS_HELP_STRING([--with-makecert], [Compile and install the makecert program [default=yes].]), [with_makecert=$withval], [with_makecert=yes]) AM_CONDITIONAL([WITH_MAKECERT], [test x$with_makecert != xno]) AM_COND_IF([WITH_MAKECERT], [AC_MSG_NOTICE([WITH_MAKECERT defined])]) # Check for test_zgossip intent AC_ARG_WITH([test_zgossip], AS_HELP_STRING([--with-test_zgossip], [Compile the test_zgossip program [default=yes].]), [with_test_zgossip=$withval], [with_test_zgossip=yes]) AM_CONDITIONAL([WITH_TEST_ZGOSSIP], [test x$with_test_zgossip != xno]) AM_COND_IF([WITH_TEST_ZGOSSIP], [AC_MSG_NOTICE([WITH_TEST_ZGOSSIP defined])]) # Checks for library functions. AC_TYPE_SIGNAL AC_CHECK_FUNCS(perror gettimeofday memset getifaddrs) # Set pkgconfigdir AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH], [Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]), [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST([pkgconfigdir]) # Specify output files AC_CONFIG_FILES([Makefile doc/Makefile src/libczmq.pc ]) AC_OUTPUT ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/configure0000775000175000017500000163753112535241735013526 0ustar00phph00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for czmq 3.0.2. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: zeromq-dev@lists.zeromq.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='czmq' PACKAGE_TARNAME='czmq' PACKAGE_VERSION='3.0.2' PACKAGE_STRING='czmq 3.0.2' PACKAGE_BUGREPORT='zeromq-dev@lists.zeromq.org' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS pkgconfigdir WITH_TEST_ZGOSSIP_FALSE WITH_TEST_ZGOSSIP_TRUE WITH_MAKECERT_FALSE WITH_MAKECERT_TRUE BUILD_DOC_FALSE BUILD_DOC_TRUE INSTALL_MAN_FALSE INSTALL_MAN_TRUE ON_ANDROID_FALSE ON_ANDROID_TRUE ON_CYGWIN_FALSE ON_CYGWIN_TRUE ON_MINGW_FALSE ON_MINGW_TRUE ENABLE_SHARED_FALSE ENABLE_SHARED_TRUE czmq_have_xmlto czmq_have_asciidoc zmq_LIBS zmq_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED LIBTOOL OBJDUMP DLLTOOL AS host_os host_vendor host_cpu host build_os build_vendor build_cpu build am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC LTVER AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock with_gcov with_libzmq with_makecert with_test_zgossip with_pkgconfigdir ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR zmq_CFLAGS zmq_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures czmq 3.0.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/czmq] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of czmq 3.0.2:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-gcov=yes/no With GCC Code Coverage reporting. --with-libzmq Specify libzmq prefix --with-makecert Compile and install the makecert program [default=yes]. --with-test_zgossip Compile the test_zgossip program [default=yes]. --with-pkgconfigdir=PATH Path to the pkgconfig directory [[LIBDIR/pkgconfig]] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path zmq_CFLAGS C compiler flags for zmq, overriding pkg-config zmq_LIBS linker flags for zmq, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF czmq configure 3.0.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to zeromq-dev@lists.zeromq.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by czmq $as_me 3.0.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in config "$srcdir"/config; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ac_config_headers="$ac_config_headers src/platform.h" am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='czmq' VERSION='3.0.2' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 $as_echo_n "checking how to create a ustar tar archive... " >&6; } # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' _am_tools=${am_cv_prog_tar_ustar-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do { echo "$as_me:$LINENO: $_am_tar --version" >&5 ($_am_tar --version) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && break done am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x ustar -w "$$tardir"' am__tar_='pax -L -x ustar -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H ustar -L' am__tar_='find "$tardir" -print | cpio -o -H ustar -L' am__untar='cpio -i -H ustar -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_ustar}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -rf conftest.dir if test -s conftest.tar; then { echo "$as_me:$LINENO: $am__untar &5 ($am__untar &5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } grep GrepMe conftest.dir/file >/dev/null 2>&1 && break fi done rm -rf conftest.dir if ${am_cv_prog_tar_ustar+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 $as_echo "$am_cv_prog_tar_ustar" >&6; } # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' # 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` cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_MAJOR $PV_MAJOR _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_MINOR $PV_MINOR _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_PATCH $PV_PATCH _ACEOF # This lets us use PACKAGE_VERSION in Makefiles # # Libtool -version-info (ABI version) # # Currently 2.0.1 ("stable"). 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 # # libczmq -version-info LTVER="3:0:0" # Capture c flags CZMQ_ORIG_CFLAGS="${CFLAGS:-none}" # Checks for programs ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; } if ${ac_cv_prog_cc_c99+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 $as_echo "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then : fi if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AS="${ac_tool_prefix}as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 $as_echo "$AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AS="as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 $as_echo "$ac_ct_AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AS" = x; then AS="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS fi else AS="$ac_cv_prog_AS" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi ;; esac test -z "$AS" && AS=as test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$OBJDUMP" && OBJDUMP=objdump case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi # Code coverage # Check whether --with-gcov was given. if test "${with_gcov+set}" = set; then : withval=$with_gcov; CZMQ_GCOV="$withval" fi if test "x${CZMQ_GCOV}" == "xyes"; then CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" if test "x${CZMQ_ORIG_CFLAGS}" != "xnone"; then CFLAGS="${CFLAGS} ${CZMQ_ORIG_CFLAGS}" fi fi PREVIOUS_CFLAGS="${CFLAGS}" PREVIOUS_LIBS="${LIBS}" was_zmq_check_lib_detected=no pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zmq" >&5 $as_echo_n "checking for zmq... " >&6; } if test -n "$zmq_CFLAGS"; then pkg_cv_zmq_CFLAGS="$zmq_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzmq\""; } >&5 ($PKG_CONFIG --exists --print-errors "libzmq") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_zmq_CFLAGS=`$PKG_CONFIG --cflags "libzmq" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$zmq_LIBS"; then pkg_cv_zmq_LIBS="$zmq_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzmq\""; } >&5 ($PKG_CONFIG --exists --print-errors "libzmq") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_zmq_LIBS=`$PKG_CONFIG --libs "libzmq" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then zmq_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzmq" 2>&1` else zmq_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzmq" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$zmq_PKG_ERRORS" >&5 # Check whether --with-libzmq was given. if test "${with_libzmq+set}" = set; then : withval=$with_libzmq; search_libzmq="yes" fi zmq_synthetic_cflags="" zmq_synthetic_libs="-lzmq" if test "x$search_libzmq" = "xyes"; then if test -r "${with_libzmq}/include/zmq.h"; then zmq_synthetic_cflags="-I${with_libzmq}/include" zmq_synthetic_libs="-L${with_libzmq}/lib -lzmq" else as_fn_error $? "${with_libzmq}/include/zmq.h not found. Please check libzmq prefix" "$LINENO" 5 fi fi CFLAGS="${zmq_synthetic_cflags} ${CFLAGS}" LDFLAGS="${zmq_synthetic_libs} ${LDFLAGS}" LIBS="${zmq_synthetic_libs} ${LIBS}" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zmq_init in -lzmq" >&5 $as_echo_n "checking for zmq_init in -lzmq... " >&6; } if ${ac_cv_lib_zmq_zmq_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lzmq $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char zmq_init (); int main () { return zmq_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_zmq_zmq_init=yes else ac_cv_lib_zmq_zmq_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zmq_zmq_init" >&5 $as_echo "$ac_cv_lib_zmq_zmq_init" >&6; } if test "x$ac_cv_lib_zmq_zmq_init" = xyes; then : zmq_CFLAGS=${zmq_synthetic_cflags} zmq_LIBS=${zmq_synthetic_libs} was_zmq_check_lib_detected=yes else as_fn_error $? "cannot link with -lzmq, install libzmq." "$LINENO" 5 fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # Check whether --with-libzmq was given. if test "${with_libzmq+set}" = set; then : withval=$with_libzmq; search_libzmq="yes" fi zmq_synthetic_cflags="" zmq_synthetic_libs="-lzmq" if test "x$search_libzmq" = "xyes"; then if test -r "${with_libzmq}/include/zmq.h"; then zmq_synthetic_cflags="-I${with_libzmq}/include" zmq_synthetic_libs="-L${with_libzmq}/lib -lzmq" else as_fn_error $? "${with_libzmq}/include/zmq.h not found. Please check libzmq prefix" "$LINENO" 5 fi fi CFLAGS="${zmq_synthetic_cflags} ${CFLAGS}" LDFLAGS="${zmq_synthetic_libs} ${LDFLAGS}" LIBS="${zmq_synthetic_libs} ${LIBS}" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zmq_init in -lzmq" >&5 $as_echo_n "checking for zmq_init in -lzmq... " >&6; } if ${ac_cv_lib_zmq_zmq_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lzmq $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char zmq_init (); int main () { return zmq_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_zmq_zmq_init=yes else ac_cv_lib_zmq_zmq_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zmq_zmq_init" >&5 $as_echo "$ac_cv_lib_zmq_zmq_init" >&6; } if test "x$ac_cv_lib_zmq_zmq_init" = xyes; then : zmq_CFLAGS=${zmq_synthetic_cflags} zmq_LIBS=${zmq_synthetic_libs} was_zmq_check_lib_detected=yes else as_fn_error $? "cannot link with -lzmq, install libzmq." "$LINENO" 5 fi else zmq_CFLAGS=$pkg_cv_zmq_CFLAGS zmq_LIBS=$pkg_cv_zmq_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi if test "x$was_zmq_check_lib_detected" = "xno"; then CFLAGS="${zmq_CFLAGS} ${CFLAGS}" LIBS="${zmq_LIBS} ${LIBS}" fi CFLAGS="${PREVIOUS_CFLAGS}" LIBS="${PREVIOUS_LIBS}" # Platform specific checks czmq_on_mingw32="no" czmq_on_cygwin="no" czmq_on_android="no" # Host specific checks # Determine whether or not documentation should be built and installed. czmq_build_doc="yes" czmq_install_man="yes" # Check for asciidoc and xmlto and don't build the docs if these are not installed. # Extract the first word of "asciidoc", so it can be a program name with args. set dummy asciidoc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_czmq_have_asciidoc+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$czmq_have_asciidoc"; then ac_cv_prog_czmq_have_asciidoc="$czmq_have_asciidoc" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_czmq_have_asciidoc="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_czmq_have_asciidoc" && ac_cv_prog_czmq_have_asciidoc="no" fi fi czmq_have_asciidoc=$ac_cv_prog_czmq_have_asciidoc if test -n "$czmq_have_asciidoc"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_have_asciidoc" >&5 $as_echo "$czmq_have_asciidoc" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "xmlto", so it can be a program name with args. set dummy xmlto; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_czmq_have_xmlto+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$czmq_have_xmlto"; then ac_cv_prog_czmq_have_xmlto="$czmq_have_xmlto" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_czmq_have_xmlto="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_czmq_have_xmlto" && ac_cv_prog_czmq_have_xmlto="no" fi fi czmq_have_xmlto=$ac_cv_prog_czmq_have_xmlto if test -n "$czmq_have_xmlto"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_have_xmlto" >&5 $as_echo "$czmq_have_xmlto" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$czmq_have_asciidoc" = "xno" -o "x$czmq_have_xmlto" = "xno"; then czmq_build_doc="no" # Tarballs built with 'make dist' ship with prebuilt documentation. if ! test -f doc/czmq.7; then czmq_install_man="no" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You are building an unreleased version of CZMQ and asciidoc or xmlto are not installed." >&5 $as_echo "$as_me: WARNING: You are building an unreleased version of CZMQ and asciidoc or xmlto are not installed." >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Documentation will not be built and manual pages will not be installed." >&5 $as_echo "$as_me: WARNING: Documentation will not be built and manual pages will not be installed." >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build documentation" >&5 $as_echo_n "checking whether to build documentation... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_build_doc" >&5 $as_echo "$czmq_build_doc" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install manpages" >&5 $as_echo_n "checking whether to install manpages... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_install_man" >&5 $as_echo "$czmq_install_man" >&6; } # Set some default features required by libczmq 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" $as_echo "#define CZMQ_HAVE_LINUX 1" >>confdefs.h case "${host_os}" in *android*) $as_echo "#define CZMQ_HAVE_ANDROID 1" >>confdefs.h czmq_on_android="yes" ;; esac ;; *solaris*) # Define on Solaris to enable all library features CPPFLAGS="-D_PTHREADS $CPPFLAGS" $as_echo "#define CZMQ_HAVE_SOLARIS 1" >>confdefs.h CFLAGS="${CFLAGS} -lsocket -lssp" ;; *freebsd*) # Define on FreeBSD to enable all library features CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_FREEBSD 1" >>confdefs.h ;; *darwin*) # Define on Darwin to enable all library features CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_OSX 1" >>confdefs.h ;; *netbsd*) # Define on NetBSD to enable all library features CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_NETBSD 1" >>confdefs.h ;; *openbsd*) # Define on OpenBSD to enable all library features CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_OPENBSD 1" >>confdefs.h ;; *nto-qnx*) $as_echo "#define CZMQ_HAVE_QNXNTO 1" >>confdefs.h ;; *aix*) $as_echo "#define CZMQ_HAVE_AIX 1" >>confdefs.h ;; *hpux*) # Define on HP-UX to enable all library features CPPFLAGS="-D_POSIX_C_SOURCE=200112L" $as_echo "#define CZMQ_HAVE_HPUX 1" >>confdefs.h ;; *mingw32*) $as_echo "#define CZMQ_HAVE_WINDOWS 1" >>confdefs.h $as_echo "#define CZMQ_HAVE_MINGW32 1" >>confdefs.h for ac_header in windows.h do : ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" if test "x$ac_cv_header_windows_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINDOWS_H 1 _ACEOF fi done czmq_on_mingw32="yes" czmq_install_man="no" ;; *cygwin*) # Define on Cygwin to enable all library features CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_CYGWIN 1" >>confdefs.h czmq_on_cygwin="yes" ;; *) as_fn_error $? "unsupported system: ${host_os}." "$LINENO" 5 ;; esac # Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi for ac_header in 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 ifaddrs.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in net/if.h net/if_media.h linux/wireless.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " #ifdef HAVE_SYS_SOCKET_H # include #endif #include " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 $as_echo_n "checking for working volatile... " >&6; } if ${ac_cv_c_volatile+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { volatile int x; int * volatile y = (int *) 0; return !x && !y; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_volatile=yes else ac_cv_c_volatile=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 $as_echo "$ac_cv_c_volatile" >&6; } if test $ac_cv_c_volatile = no; then $as_echo "#define volatile /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac # These options are GNU compiler specific. if test "x$GCC" = "xyes"; then CPPFLAGS="-pedantic -Werror -Wall -Wc++-compat ${CPPFLAGS}" fi if test "x$enable_shared" = "xyes"; then ENABLE_SHARED_TRUE= ENABLE_SHARED_FALSE='#' else ENABLE_SHARED_TRUE='#' ENABLE_SHARED_FALSE= fi if test "x$czmq_on_mingw32" = "xyes"; then ON_MINGW_TRUE= ON_MINGW_FALSE='#' else ON_MINGW_TRUE='#' ON_MINGW_FALSE= fi if test "x$czmq_on_cygwin" = "xyes"; then ON_CYGWIN_TRUE= ON_CYGWIN_FALSE='#' else ON_CYGWIN_TRUE='#' ON_CYGWIN_FALSE= fi if test "x$czmq_on_android" = "xyes"; then ON_ANDROID_TRUE= ON_ANDROID_FALSE='#' else ON_ANDROID_TRUE='#' ON_ANDROID_FALSE= fi if test "x$czmq_install_man" = "xyes"; then INSTALL_MAN_TRUE= INSTALL_MAN_FALSE='#' else INSTALL_MAN_TRUE='#' INSTALL_MAN_FALSE= fi if test "x$czmq_build_doc" = "xyes"; then BUILD_DOC_TRUE= BUILD_DOC_FALSE='#' else BUILD_DOC_TRUE='#' BUILD_DOC_FALSE= fi # Check for makecert intent # Check whether --with-makecert was given. if test "${with_makecert+set}" = set; then : withval=$with_makecert; with_makecert=$withval else with_makecert=yes fi if test x$with_makecert != xno; then WITH_MAKECERT_TRUE= WITH_MAKECERT_FALSE='#' else WITH_MAKECERT_TRUE='#' WITH_MAKECERT_FALSE= fi if test -z "$WITH_MAKECERT_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: WITH_MAKECERT defined" >&5 $as_echo "$as_me: WITH_MAKECERT defined" >&6;} fi # Check for test_zgossip intent # Check whether --with-test_zgossip was given. if test "${with_test_zgossip+set}" = set; then : withval=$with_test_zgossip; with_test_zgossip=$withval else with_test_zgossip=yes fi if test x$with_test_zgossip != xno; then WITH_TEST_ZGOSSIP_TRUE= WITH_TEST_ZGOSSIP_FALSE='#' else WITH_TEST_ZGOSSIP_TRUE='#' WITH_TEST_ZGOSSIP_FALSE= fi if test -z "$WITH_TEST_ZGOSSIP_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: WITH_TEST_ZGOSSIP defined" >&5 $as_echo "$as_me: WITH_TEST_ZGOSSIP defined" >&6;} fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in perror gettimeofday memset getifaddrs do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Set pkgconfigdir # Check whether --with-pkgconfigdir was given. if test "${with_pkgconfigdir+set}" = set; then : withval=$with_pkgconfigdir; pkgconfigdir="$withval" else pkgconfigdir='${libdir}/pkgconfig' fi # Specify output files ac_config_files="$ac_config_files Makefile doc/Makefile src/libczmq.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_SHARED_TRUE}" && test -z "${ENABLE_SHARED_FALSE}"; then as_fn_error $? "conditional \"ENABLE_SHARED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_MINGW_TRUE}" && test -z "${ON_MINGW_FALSE}"; then as_fn_error $? "conditional \"ON_MINGW\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_CYGWIN_TRUE}" && test -z "${ON_CYGWIN_FALSE}"; then as_fn_error $? "conditional \"ON_CYGWIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_ANDROID_TRUE}" && test -z "${ON_ANDROID_FALSE}"; then as_fn_error $? "conditional \"ON_ANDROID\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INSTALL_MAN_TRUE}" && test -z "${INSTALL_MAN_FALSE}"; then as_fn_error $? "conditional \"INSTALL_MAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_DOC_TRUE}" && test -z "${BUILD_DOC_FALSE}"; then as_fn_error $? "conditional \"BUILD_DOC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_MAKECERT_TRUE}" && test -z "${WITH_MAKECERT_FALSE}"; then as_fn_error $? "conditional \"WITH_MAKECERT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_TEST_ZGOSSIP_TRUE}" && test -z "${WITH_TEST_ZGOSSIP_FALSE}"; then as_fn_error $? "conditional \"WITH_TEST_ZGOSSIP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by czmq $as_me 3.0.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ czmq config.status 3.0.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in AS \ DLLTOOL \ OBJDUMP \ SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/platform.h") CONFIG_HEADERS="$CONFIG_HEADERS src/platform.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "src/libczmq.pc") CONFIG_FILES="$CONFIG_FILES src/libczmq.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Assembler program. AS=$lt_AS # DLL creation program. DLLTOOL=$lt_DLLTOOL # Object dumper program. OBJDUMP=$lt_OBJDUMP # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/README.txt0000664000175000017500000003727512531332123013277 0ustar00phph00000000000000.set GIT=https://github.com/zeromq/czmq .sub 0MQ=ØMQ # CZMQ - High-level C binding for 0MQ [![Build Status](https://travis-ci.org/zeromq/czmq.png?branch=master)](https://travis-ci.org/zeromq/czmq) ## Contents .toc 3 ## Overview ### Scope and Goals CZMQ has these goals: * To wrap the 0MQ core API in semantics that lead to shorter, more readable applications. * To hide as far as possible the differences between different versions of 0MQ (2.x, 3.x, 4.x). * To provide a space for development of more sophisticated API semantics. * To wrap the 0MQ security features with high-level tools and APIs. * To become the basis for other language bindings built on top of CZMQ. CZMQ grew out of concepts developed in [ØMQ - The Guide](http://zguide.zeromq.org). [diagram] +---------------+ | | | C application | | | +-----+---+-----+ | | | | +------------+ | | | v | Open context +---------+ | Create sockets | | | Connect, bind sockets Close sockets | CZMQ | | get/set socket options Send/receive | cYEL | | Multithreading +----+----+ | Reactor pattern | | Hash container +------------+ | List container | | System clock v v Close context +---------+ | | | libzmq | | | +---------+ [/diagram] ### Ownership and License The contributors are listed in AUTHORS. This project uses the MPL v2 license, see LICENSE. CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/spec:21) guide for code style. To report an issue, use the [CZMQ issue tracker](https://github.com/zeromq/czmq/issues) at github.com. ## Using CZMQ ### Building and Installing Here's how to build CZMQ from GitHub (building from packages is very similar, you don't clone a repo but unpack a tarball), including the libsodium (for security) and libzmq (ZeroMQ core) libraries: git clone git://github.com/jedisct1/libsodium.git cd libsodium ./autogen.sh ./configure && make check sudo make install sudo ldconfig cd .. git clone git://github.com/zeromq/libzmq.git cd libzmq ./autogen.sh ./configure && make check sudo make install sudo ldconfig cd .. git clone git://github.com/zeromq/czmq.git cd czmq ./autogen.sh ./configure && make check sudo make install sudo ldconfig cd .. In general CZMQ works best with the latest libzmq master. If you already have an older version of libzmq installed on your system, e.g. in /usr/, then you can install libzmq master to your home directory ($HOME/local): # Building libzmq in our home directory ./configure --prefix=$HOME/local And then to build CZMQ against this installation of libzmq: export CFLAGS=-I$HOME/local/include export LDFLAGS=-L$HOME/local/lib64 ./configure You will need the pkg-config, libtool, and autoreconf packages. After building, run the CZMQ selftests: make check ### Linking with an Application Include `czmq.h` in your application and link with libczmq. Here is a typical gcc link command: gcc -lczmq -lzmq myapp.c -o myapp ### Use from Other Languages This is a list of known higher-level wrappers around CZMQ: * https://github.com/1100110/CZMQ - D bindings * https://github.com/methodmissing/rbczmq - Ruby * https://github.com/zeromq/pyczmq - Python * https://github.com/lhope/cl-czmq - Common Lisp * https://github.com/fmp88/ocaml-czmq - Ocaml * https://github.com/gar1t/erlang-czmq - Erlang * https://github.com/mtortonesi/ruby-czmq-ffi - Ruby FFI * https://github.com/zeromq/goczmq - Go ### API v3 Summary This is the API provided by CZMQ v3.x, in alphabetical order. .pull doc/zactor.doc .pull doc/zauth.doc .pull doc/zbeacon.doc .pull doc/zcert.doc .pull doc/zcertstore.doc .pull doc/zchunk.doc .pull doc/zclock.doc .pull doc/zconfig.doc .pull doc/zdigest.doc .pull doc/zdir.doc .pull doc/zdir_patch.doc .pull doc/zfile.doc .pull doc/zframe.doc .pull doc/zgossip.doc .pull doc/zhash.doc .pull doc/ziflist.doc .pull doc/zlist.doc .pull doc/zloop.doc .pull doc/zmonitor.doc .pull doc/zmsg.doc .pull doc/zpoller.doc .pull doc/zproxy.doc .pull doc/zrex.doc .pull doc/zsock.doc .pull doc/zsock_option.doc .pull doc/zstr.doc .pull doc/zsys.doc .pull doc/zuuid.doc ### API v2 Summary This is the deprecated API provided by CZMQ v2.x, in alphabetical order. .pull doc/zauth_v2.doc .pull doc/zctx.doc .pull doc/zmonitor_v2.doc .pull doc/zmutex.doc .pull doc/zproxy_v2.doc .pull doc/zsocket.doc .pull doc/zsockopt.doc .pull doc/zthread.doc ## Error Handling The CZMQ policy is to reduce the error flow to 0/-1 where possible. libzmq still does a lot of errno setting. CZMQ does not do that, as it creates a fuzzy API. Things either work as expected, or they fail, and the application's best strategy is usually to assert on non-zero return codes. Some older libraries still return plethora of error codes, to indicate different types of failure. This ironically makes both library and application more likely to be buggy. The reason is simply that it needs more code on both sides of the API, and the more code, the more bugs. The use of black/white error handling fits the CLASS style for APIs where each call is explicit and without side effects of any kind, and where damage is either impossible, or fatal. The one exception is running out of resources (memory, sockets). In that case, there are two strategies that work, for different types of app. One is to assert, to force better sizing of the machine and/or limits such as max connections. Two is to degrade carefully, e.g. refuse new connections, however that is considerably harder to do correctly and probably unrealistic for most developers. Some CZMQ methods used to actually assert, e.g. in zsocket_bind, if the action failed, instead of returning -1. That was just closer to the majority case where the action MUST work, or nothing can continue. However there's a small slice of cases where failure means something positive, and for these cases, such calls return -1 on failure. 99% of calling code simply asserts the return value is not -1. There are a few cases where the return value is overloaded to return -1, 0, or other values. These are somewhat confusing special cases and we aim to eliminate them over time. The overall goal with this strategy is robustness, and absolute minimal and predictable expression in the code. You can see that it works: the CZMQ code is generally very simple and clear, with a few exceptions of places where people have used their old C style (we fix these over time). ## CZMQ Actors The v2 API had a zthread class that let you create "attached threads" connected to their parent by an inproc:// PIPE socket. In v3 this has been simplified and better wrapped as the zactor class. CZMQ actors are in effect threads with a socket interface. A zactor_t instance works like a socket, and the CZMQ classes that deal with sockets (like zmsg and zpoller) all accept zactor_t references as well as zsock_t and libzmq void * socket handles. To write an actor, use this template. Note that your actor is a single function "void myname (zsock_t *pipe, void *args)" function: /* ========================================================================= someclass - some description Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Please take e.g. include/zmonitor.h as basis for your public API. And delete this text, and write your own, when you create an actor :-) @discuss @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller // ... you'll be adding other stuff here bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); self->pipe = pipe; // ... initialize your own state including any other // sockets, which you can add to the poller: self->poller = zpoller_new (self->pipe, NULL); return self; } static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zpoller_destroy (&self->poller); // ... destroy your own state here free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (self->verbose) zsys_info ("zxxx: API command=%s", command); if (streq (command, "VERBOSE")) self->verbose = true; else // An example of a command that the caller would wait for // via a signal, so that the two threads synchronize if (streq (command, "WAIT")) zsock_signal (self->pipe, 0); else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zxxx: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // zxxx() implements the zxxx actor interface void zxxx (zsock_t *pipe, void *args) { self_t *self = s_self_new (pipe); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zxxx_test (bool verbose) { printf (" * zxxx: "); if (verbose) printf ("\n"); // @selftest zactor_t *xxx = zactor_new (zxxx, NULL); assert (xxx); if (verbose) zstr_sendx (xxx, "VERBOSE", NULL); zactor_destroy (&xxx); // @end printf ("OK\n"); } The selftest code shows how to create, talk to, and destroy an actor. ## Under the Hood ### Adding a New Class If you define a new CZMQ class `myclass` you need to: * Write the `zmyclass.c` and `zmyclass.h` source files, in `src` and `include` respectively. * Add`#include ` to `include/czmq.h`. * Add the myclass header and test call to `src/czmq_selftest.c`. * Add a reference documentation to 'doc/zmyclass.txt'. * Add myclass to 'model/projects.xml` and read model/README.txt. * Add a section to README.txt. ### Documentation Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (http://github.com/imatix/gitdown). The header file for a class must wrap its interface as follows (example is from include/zclock.h): // @interface // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds int64_t zclock_time (void); // Self test of this class int zclock_test (Bool verbose); // @end The source file for a class must provide documentation as follows: /* @header ...short explanation of class... @discuss ...longer discussion of how it works... @end */ The source file for a class then provides the self test example as follows: // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); // @end The template for man pages is in doc/mkman. ### Development CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code: * Modify a class or method. * Update the test method for that class. * Run the 'selftest' script, which uses the Valgrind memcheck tool. * Repeat until perfect. ### Porting CZMQ When you try CZMQ 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 non-trivial. 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 `czmq_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 czmq_prelude.h. * Defining macros that rename exotic library functions to more conventional names: do this in czmq_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. ### Hints to Contributors CZMQ is a nice, neat library, and you may not immediately appreciate why. Read the CLASS style guide please, and write your code to make it indistinguishable from the rest of the code in the library. That is the only real criteria for good style: it's invisible. Don't include system headers in source files. The right place for these is czmq_prelude.h. If you need to check against configured libraries and/or headers, include platform.h in the source before including czmq.h. Do read your code after you write it and ask, "Can I make this simpler?" We do use a nice minimalist and yet readable style. Learn it, adopt it, use it. Before opening a pull request read our [contribution guidelines](https://github.com/zeromq/czmq/blob/master/CONTRIBUTING.md). Thanks! ### Code Generation We generate the zsockopt class using [GSL](https://github.com/imatix/gsl), using a code generator script in scripts/sockopts.gsl. We also generate the project files. ### This Document This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown). czmq-3.0.2/NEWS0000664000175000017500000003074312535242115012276 0ustar00phph00000000000000CZMQ version 3.0.2 stable, released on 2015/06/08 ================================================= Added LICENSE, README, and CONTRIBUTING. CZMQ version 3.0.1 stable, released on 2015/06/02 ================================================= CZMQ version 3.0.0 (rc1), released on 2014/10/15 ================================================ CZMQ version 2.2.0 stable, released on 2014/04/23 ================================================= CZMQ version 2.1.0 stable, released on 2014/03/20 ================================================= CZMQ version 2.0.3 stable, released on 2013/11/16 ================================================= Fixed to support ZeroMQ 3.2; was causing a build error due to use of ZMQ_STREAM in zsockopt.c. CZMQ version 2.0.2 stable, released on 2013/10/08 ================================================= * Fixed builds on MSVC and FreeBSD. * Fixed minor build issues in RC2. CZMQ version 2.0.1 (rc2), released on 2013/09/21 ================================================ Updated to support ZeroMQ v4.x. If you are using an older version of CZMQ it will not build correctly with ZeroMQ v4.x. Sorry about that. Added support for the new socket options: * zsocket_set_req_relaxed () * zsocket_set_req_correlate () * zsocket_set_conflate () CZMQ version 2.0.0 (rc1), released on 2013/09/19 ================================================ The changes are mainly tools to support encryption via the libzmq CURVE mechanism, but also some new API constructs to make it simpler to do common messaging work. Bug fixes and cleanups of codebase: * zconfig_load () failed if the ZPL file contained a blank line. * zconfig_locate () allows and ignores initial '/' on pathname. * Added zsys_vprintf () to centralize all variable string formatting; this code was duplicated many times across the project. * Updated zmsg interface documentation to be more detailed. * Removed deprecated zstr_sendfm () method. * Removed deprecated zstr_sendf () method. * Removed definition of ZMQ_IGNERR and added zloop_set_tolerant () to configure a specific poller as error-tolerant. * Removed deprecated zframe and zmsg zero-copy methods; this API was too complex and split over several classes, and IMO if we want this optimization it should be in a new zero-copy class with a clean API. * Removed deprecated zsocket zero-copy methods, for above reason. * Removed deprecated zlist_copy method. * Renamed zframe_print_to_stream to zframe_fprint and kept old name as deprecated macro. * Removed (not deprecated) zctx_set_hwm () as its semantics were not consistent, and confusing to people. * Removed (not deprecated) zctx_hwm (). We now have separate HWMs for normal socket SND and RCV, and for inter-thread pipes. There is no need to provide accessor methods for these. New API methods to simplify common messaging tasks: * Added zpoller class to provide new minimalist interface to zmq_poll. This class makes it very simple to read off a set of sockets, which is an 80% usecase. * Added zstr_sendx () to send multiple strings in one call. Inspired by PyZMQ's multipart send method. * Added zstr_recvx () to receive multiple strings in one call. We do a lot of multipart string reads; this makes it simpler for simple cases. * Added zclock_timestr () to provide date/time as printable string. * Added zmsg_append () that nullifies caller's frame reference; this is more consistent with the API style than zmsg_add (), which is deprecated. New classes used for security infrastructure: * Added zchunk class (from FileMQ), for managing memory blocks. This is a simpler model than zframes, which are optimized for message data. * Added zhash_comment () to add comments to a serialized zhash file. * Added zhash_refresh () to reload a backing file if modified on disk. * Added zconfig_comment () to add comments to saved config file, and added code to save such comments from file when loading it. * Moved zfile (char *filename) methods to zsys, to make place for a new zfile class based on the CLASS object model. The old methods are still provided but are deprecated. * Added zfile class (from FileMQ), for managing files. This provides a rich file class with metadata and operations. This is a component for directory management (zdir). * Added zdir class (from FileMQ), for managing directories. This lets us work with filesystem directories. I wanted this to be able to load certificates for security authentication. * The zdir and zfile classes are slightly stripped down from their FileMQ originals; no symbolic links, no directory difference tools. * Unfortunately to keep the old zfile_size and zfile_time methods, I had to use zfile_cursize and zfile_modified in the new class. This is a little clumsy. * Added zsys_file_modified () to return timestamp for a filename. * Added zcert class to work with Curve certificates. A certificate is a public + secret key pair, plus metadata like name, email, etc. and is saved as two files, a public text file and a secret text file. Certificates are stored in ZPL (ZMQ RFC 4) configuration file format. * Added zauth class to automate ZAP authenticators. This class does a simple plug and play authentication of clients against certificates stored in the $HOME/.curve directory. This can be extended over time with other designs. * Added zcertstore class to work with Curve certificate stores. This is a directory or in-memory store holding a set of certificates. * Extended zsockopt generation to allow use of binary keys in CURVE key options (e.g. zsocket_set_curve_secretkey_bin ()). * Added addons/makecert.c tool to generate CURVE certificates. * Added examples/security directory with several examples. For full details, see git log. CZMQ version 1.4.1 (stable), released on 2013/05/01 =================================================== Changes ------- * Fixed assertion in zbeacon on sendto error. * Fixed packaging of platform scripts in /builds. * See git log for rest. CZMQ version 1.4.0 (stable), released on 2013/04/30 =================================================== Changes ------- * Added zbeacon class. * See git log for rest. CZMQ version 1.3.2 (stable), released on 2012/12/22 =================================================== Changes ------- * See git log. CZMQ version 1.3.1 (stable), released on 2012/10/27 =================================================== Changes ------- * See git log. CZMQ version 1.3.0 (rc), not released ===================================== CZMQ version 1.2.0 (stable), released on 2012/08/06 =================================================== Changes ------- * zsockopt_ functions renamed to zsocket_, for clarity. Old names are still provided for compatibility. * SUB sockets are no longer subscribed to everything. * Fixed issue CZMQ-7, wrong name used for CZMQ man page. * Changed zsocket_connect() to return 0 or -1, since zmq_connect() now checks endpoints properly (issue LIBZMQ-207). * All classes handle memory exhaustion correctly by returning an error instead of asserting. * zsocket_identity implemented correctly. * Added zctx_underlying() to provide access to low-level 0MQ context object, to allow manipulation for extreme cases and tests. * For the rest, check the git history :-) CZMQ version 1.1.0 (stable), released on 2011/08/30 =================================================== Changes ------- * Fixed issue CZMQ-2. (https://zeromq.jira.com/browse/CZMQ-2) * Removed unused ctx argument from zthread_new() call. * zloop works with zmq_pollitem_t * instead of void * sockets; allows use of native FDs in reactor as well as 0MQ sockets. * zloop_reader renamed to zloop_poller. * zloop_cancel renamed to zloop_poller_end, and API changed to work with zmq_pollitem_t * instead of a single 0MQ socket void *. * Added zloop_timer_end, taking same argument as for zloop_timer. * zloop_poller_end cancels ALL handlers for the socket or FD. * Added zmsg_content_size method to report full content size of message. * zmsg_save returns 0/-1 depending on success/failure (previously returned void). * zmsg_dump limited to first 10 frames, to allow mix of large and small messages in applications. * zframe_print truncates output at 70 chars to prevent over-long output. * Added ability for zsocket_bind to bind to ephemeral port in range 0xc000 to 0xffff. * zmq_bind always returns port number bound to, if successful. * Added zfile class with minimal helper functions. * Added zfile_size method to return file size, as ssize_t. * Added socket multipart flush to zctx_destroy to work around libzmq issue 134, which asserts if a fair-queuing socket still has input at close. * Added zframe_eq method to compare two frames' size and content. * Changed zmsg_load to append to an optional existing message. * Fixed zloop to allow timers to be added after reactor was started. Without this fix, the reactor would spin at max speed instead of properly calculating the timer. (Luc Heinrich) * Modified zmsg_pushstr and zmsg_addstr to accept variable argument list and do vsnprintf formatting of provided string. * Added zhash_rename function to allow soft renaming of item keys. * Added tblsize and tbllast macros, so very useful when you need them. * Added zmsg_encode and zmsg_decode functions to serialize messages to and from a byte buffer. * Added zframe_recv_nowait method to read frame without blocking. CZMQ version 1.0.0 (stable), released on 2011/04/26 =================================================== Changes ------- * At build time, reports error if libzmq version isn't at least 2.1. * Renamed project to CZMQ for coherence with other language bindings. libzapi version 1.3.2 (beta), released on 2011/04/15 ==================================================== Changes ------- * Added zsocket_type_str method to return printable socket type. * Added zloop_set_verbose method to enable/disable reactor activity. * Fixed zloop to call right handlers even if handlers register/cancel other handlers. * Fixed zloop to not call handlers when interrupted. * Added zsocket_set_hwm method to emulate 2.x option (sets both send and recv high-water marks). * Several parts of the 3.0 porting didn't work properly - fixed. * Added macro set to aid portability from 2.1 to 3.0: ZMQ_POLL_MSEC, ZMQ_DONTWAIT, zmq_sendmsg, zmq_recvmsg. libzapi version 1.3.1 (beta), released on 2011/04/09 ==================================================== Changes ------- * Added compatibility for new libzmq/3.0 API. libzapi version 1.3.0 (beta), released on 2011/04/08 ==================================================== Changes ------- * Ported to win32, all selftests pass successfully. * New zsockopt class provides API to set/get socket options. * New zsocket class provides API to connect and bind sockets using printf semantics to format endpoints. * Threading API now supports detached and attached threads via zthread class, and zthread_new and zthread_fork methods. * Pipes to attached threads have HWM of 1 (each side) to block runaway writers. * In zframe class, added print, reset, strdup, streq, strhex, dup methods. * In zmsg class, added last, wrap, unwrap, popstr, pushstr, addstr, dup methods. * In zclock class, added log method. * In zstr class, added sendm and recv_nowait methods. * Added Valgrind suppression file for libzmq. Bug Fixes --------- * Fixed error in thread pipe handling which sometimes provoked libzmq assertion failure at shutdown. libzapi version 1.2.1 (beta), released on 2011/04/01 ==================================================== Changes ------- * Rewrote zctx class, which was wrongly working with sockets in two threads. Much simpler, and properly stable now. * Project renamed to 'libzapi' for consistency with 'libzmq'. * Expanded main documentation page significantly. zapi version 1.2.0 (beta), released on 2011/03/24 ================================================= Changes ------- * Added zclock class for portable millisecond timers and delays. * Expanded documentation significantly. zapi version 1.1.0 (beta), released on 2011/03/23 ================================================= Changes ------- * Added zctx_thread_new method to create child threads with a PAIR pipe to talk to them. * Made zapi threadsafe, specifically multiple threads can share the same context and thus talk to each other. zapi version 1.0.0 (beta), released on 2011/03/22 ================================================= Changes ------- * Initial version of library finished, tested, documented, and packaged. czmq-3.0.2/Makefile.in0000664000175000017500000033332212535241735013652 0ustar00phph00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ # Project-local changes to auto-generated content VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = $(am__EXEEXT_1) noinst_PROGRAMS = $(am__EXEEXT_2) check_PROGRAMS = src/czmq_selftest$(EXEEXT) TESTS = DIST_COMMON = $(am__configure_deps) $(include_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/src/Makemodule-local.am $(srcdir)/src/Makemodule.am \ $(top_srcdir)/configure $(top_srcdir)/src/libczmq.pc.in \ $(top_srcdir)/src/platform.h.in AUTHORS INSTALL NEWS \ config/compile config/config.guess config/config.sub \ config/depcomp config/install-sh config/ltmain.sh \ config/missing # Programs need to link the c++ runtime if everything was compiled statically. @ENABLE_SHARED_FALSE@am__append_1 = -lstdc++ @ON_MINGW_TRUE@am__append_2 = \ @ON_MINGW_TRUE@ -no-undefined \ @ON_MINGW_TRUE@ -avoid-version @ON_CYGWIN_TRUE@am__append_3 = \ @ON_CYGWIN_TRUE@ -no-undefined \ @ON_CYGWIN_TRUE@ -avoid-version @WITH_MAKECERT_TRUE@am__append_4 = src/makecert @WITH_TEST_ZGOSSIP_TRUE@am__append_5 = src/test_zgossip # Android-qt requires this special link dependency @ON_ANDROID_TRUE@am__append_6 = -llog subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \ $(top_srcdir)/config/ltoptions.m4 \ $(top_srcdir)/config/ltsugar.m4 \ $(top_srcdir)/config/ltversion.m4 \ $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/platform.h CONFIG_CLEAN_FILES = src/libczmq.pc CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) src_libczmq_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_1) am__dirstamp = $(am__leading_dot)dirstamp am_src_libczmq_la_OBJECTS = src/src_libczmq_la-zactor.lo \ src/src_libczmq_la-zauth.lo src/src_libczmq_la-zarmour.lo \ src/src_libczmq_la-zbeacon.lo src/src_libczmq_la-zcert.lo \ src/src_libczmq_la-zcertstore.lo src/src_libczmq_la-zchunk.lo \ src/src_libczmq_la-zclock.lo src/src_libczmq_la-zconfig.lo \ src/src_libczmq_la-zdigest.lo src/src_libczmq_la-zdir.lo \ src/src_libczmq_la-zdir_patch.lo src/src_libczmq_la-zfile.lo \ src/src_libczmq_la-zframe.lo src/src_libczmq_la-zgossip.lo \ src/src_libczmq_la-zhashx.lo src/src_libczmq_la-ziflist.lo \ src/src_libczmq_la-zlistx.lo src/src_libczmq_la-zloop.lo \ src/src_libczmq_la-zmonitor.lo src/src_libczmq_la-zmsg.lo \ src/src_libczmq_la-zpoller.lo src/src_libczmq_la-zproxy.lo \ src/src_libczmq_la-zrex.lo src/src_libczmq_la-zsock.lo \ src/src_libczmq_la-zsock_option.lo src/src_libczmq_la-zstr.lo \ src/src_libczmq_la-zsys.lo src/src_libczmq_la-zuuid.lo \ src/src_libczmq_la-zgossip_msg.lo \ src/src_libczmq_la-zauth_v2.lo \ src/src_libczmq_la-zbeacon_v2.lo src/src_libczmq_la-zctx.lo \ src/src_libczmq_la-zhash.lo src/src_libczmq_la-zlist.lo \ src/src_libczmq_la-zmonitor_v2.lo src/src_libczmq_la-zmutex.lo \ src/src_libczmq_la-zproxy_v2.lo src/src_libczmq_la-zsocket.lo \ src/src_libczmq_la-zsockopt.lo src/src_libczmq_la-zthread.lo src_libczmq_la_OBJECTS = $(am_src_libczmq_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent src_libczmq_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(src_libczmq_la_LDFLAGS) $(LDFLAGS) -o \ $@ @WITH_MAKECERT_TRUE@am__EXEEXT_1 = src/makecert$(EXEEXT) @WITH_TEST_ZGOSSIP_TRUE@am__EXEEXT_2 = src/test_zgossip$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am_src_czmq_selftest_OBJECTS = \ src/src_czmq_selftest-czmq_selftest.$(OBJEXT) src_czmq_selftest_OBJECTS = $(am_src_czmq_selftest_OBJECTS) am__DEPENDENCIES_3 = src/libczmq.la $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_1) src_czmq_selftest_DEPENDENCIES = $(am__DEPENDENCIES_3) am__src_makecert_SOURCES_DIST = src/makecert.c @WITH_MAKECERT_TRUE@am_src_makecert_OBJECTS = \ @WITH_MAKECERT_TRUE@ src/src_makecert-makecert.$(OBJEXT) src_makecert_OBJECTS = $(am_src_makecert_OBJECTS) @WITH_MAKECERT_TRUE@src_makecert_DEPENDENCIES = $(am__DEPENDENCIES_3) am__src_test_zgossip_SOURCES_DIST = src/test_zgossip.c @WITH_TEST_ZGOSSIP_TRUE@am_src_test_zgossip_OBJECTS = src/src_test_zgossip-test_zgossip.$(OBJEXT) src_test_zgossip_OBJECTS = $(am_src_test_zgossip_OBJECTS) @WITH_TEST_ZGOSSIP_TRUE@src_test_zgossip_DEPENDENCIES = \ @WITH_TEST_ZGOSSIP_TRUE@ $(am__DEPENDENCIES_3) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(src_libczmq_la_SOURCES) $(src_czmq_selftest_SOURCES) \ $(src_makecert_SOURCES) $(src_test_zgossip_SOURCES) DIST_SOURCES = $(src_libczmq_la_SOURCES) $(src_czmq_selftest_SOURCES) \ $(am__src_makecert_SOURCES_DIST) \ $(am__src_test_zgossip_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive DATA = $(pkgconfig_DATA) HEADERS = $(include_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LTVER = @LTVER@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ czmq_have_asciidoc = @czmq_have_asciidoc@ czmq_have_xmlto = @czmq_have_xmlto@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ zmq_CFLAGS = @zmq_CFLAGS@ zmq_LIBS = @zmq_LIBS@ ACLOCAL_AMFLAGS = -I config AM_CPPFLAGS = \ ${zmq_CFLAGS} \ -I$(srcdir)/include project_libs = \ ${zmq_LIBS} SUBDIRS = doc DIST_SUBDIRS = doc lib_LTLIBRARIES = src/libczmq.la noinst_LTLIBRARIES = EXTRA_DIST = \ src/zgossip_engine.inc \ src/zhash_primes.inc \ src/zclass_example.xml \ src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h \ src/foreign/slre/readme.txt \ src/zgossip_msg.h \ src/czmq_classes.h \ LICENSE \ README.txt \ README.md \ CONTRIBUTING.md \ version.sh ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ program_libs = src/libczmq.la ${project_libs} $(am__append_1) pkgconfig_DATA = src/libczmq.pc include_HEADERS = \ include/czmq_prelude.h \ include/czmq.h \ include/zactor.h \ include/zauth.h \ include/zarmour.h \ include/zbeacon.h \ include/zcert.h \ include/zcertstore.h \ include/zchunk.h \ include/zclock.h \ include/zconfig.h \ include/zdigest.h \ include/zdir.h \ include/zdir_patch.h \ include/zfile.h \ include/zframe.h \ include/zgossip.h \ include/zhashx.h \ include/ziflist.h \ include/zlistx.h \ include/zloop.h \ include/zmonitor.h \ include/zmsg.h \ include/zpoller.h \ include/zproxy.h \ include/zrex.h \ include/zsock.h \ include/zsock_option.h \ include/zstr.h \ include/zsys.h \ include/zuuid.h \ include/zauth_v2.h \ include/zbeacon_v2.h \ include/zctx.h \ include/zhash.h \ include/zlist.h \ include/zmonitor_v2.h \ include/zmutex.h \ include/zproxy_v2.h \ include/zsocket.h \ include/zsockopt.h \ include/zthread.h \ include/czmq_library.h src_libczmq_la_SOURCES = \ src/zactor.c \ src/zauth.c \ src/zarmour.c \ src/zbeacon.c \ src/zcert.c \ src/zcertstore.c \ src/zchunk.c \ src/zclock.c \ src/zconfig.c \ src/zdigest.c \ src/zdir.c \ src/zdir_patch.c \ src/zfile.c \ src/zframe.c \ src/zgossip.c \ src/zhashx.c \ src/ziflist.c \ src/zlistx.c \ src/zloop.c \ src/zmonitor.c \ src/zmsg.c \ src/zpoller.c \ src/zproxy.c \ src/zrex.c \ src/zsock.c \ src/zsock_option.c \ src/zstr.c \ src/zsys.c \ src/zuuid.c \ src/zgossip_msg.c \ src/zauth_v2.c \ src/zbeacon_v2.c \ src/zctx.c \ src/zhash.c \ src/zlist.c \ src/zmonitor_v2.c \ src/zmutex.c \ src/zproxy_v2.c \ src/zsocket.c \ src/zsockopt.c \ src/zthread.c \ src/zgossip_engine.inc \ src/zhash_primes.inc \ src/zclass_example.xml \ src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h \ src/foreign/slre/readme.txt \ src/platform.h src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS} src_libczmq_la_LDFLAGS = -version-info @LTVER@ \ $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_2) $(am__append_3) src_libczmq_la_LIBADD = ${project_libs} $(am__append_6) @WITH_MAKECERT_TRUE@src_makecert_CPPFLAGS = ${AM_CPPFLAGS} @WITH_MAKECERT_TRUE@src_makecert_LDADD = ${program_libs} @WITH_MAKECERT_TRUE@src_makecert_SOURCES = src/makecert.c @WITH_TEST_ZGOSSIP_TRUE@src_test_zgossip_CPPFLAGS = ${AM_CPPFLAGS} @WITH_TEST_ZGOSSIP_TRUE@src_test_zgossip_LDADD = ${program_libs} @WITH_TEST_ZGOSSIP_TRUE@src_test_zgossip_SOURCES = src/test_zgossip.c src_czmq_selftest_CPPFLAGS = ${src_libczmq_la_CPPFLAGS} src_czmq_selftest_LDADD = ${program_libs} src_czmq_selftest_SOURCES = src/czmq_selftest.c all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/src/Makemodule.am $(srcdir)/src/Makemodule-local.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(srcdir)/src/Makemodule.am $(srcdir)/src/Makemodule-local.am: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): src/platform.h: src/stamp-h1 @if test ! -f $@; then rm -f src/stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) src/stamp-h1; else :; fi src/stamp-h1: $(top_srcdir)/src/platform.h.in $(top_builddir)/config.status @rm -f src/stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status src/platform.h $(top_srcdir)/src/platform.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f src/stamp-h1 touch $@ distclean-hdr: -rm -f src/platform.h src/stamp-h1 src/libczmq.pc: $(top_builddir)/config.status $(top_srcdir)/src/libczmq.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done src/$(am__dirstamp): @$(MKDIR_P) src @: > src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/$(DEPDIR) @: > src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zactor.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zauth.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zarmour.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zbeacon.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zcert.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zcertstore.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zchunk.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zclock.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zconfig.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zdigest.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zdir.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zdir_patch.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zfile.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zframe.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zgossip.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zhashx.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-ziflist.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zlistx.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zloop.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zmonitor.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zmsg.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zpoller.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zproxy.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zrex.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsock.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsock_option.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zstr.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsys.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zuuid.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zgossip_msg.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zauth_v2.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zbeacon_v2.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zctx.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zhash.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zlist.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zmonitor_v2.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zmutex.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zproxy_v2.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsocket.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsockopt.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zthread.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/libczmq.la: $(src_libczmq_la_OBJECTS) $(src_libczmq_la_DEPENDENCIES) $(EXTRA_src_libczmq_la_DEPENDENCIES) src/$(am__dirstamp) $(AM_V_CCLD)$(src_libczmq_la_LINK) -rpath $(libdir) $(src_libczmq_la_OBJECTS) $(src_libczmq_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list src/src_czmq_selftest-czmq_selftest.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/czmq_selftest$(EXEEXT): $(src_czmq_selftest_OBJECTS) $(src_czmq_selftest_DEPENDENCIES) $(EXTRA_src_czmq_selftest_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/czmq_selftest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_czmq_selftest_OBJECTS) $(src_czmq_selftest_LDADD) $(LIBS) src/src_makecert-makecert.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/makecert$(EXEEXT): $(src_makecert_OBJECTS) $(src_makecert_DEPENDENCIES) $(EXTRA_src_makecert_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/makecert$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_makecert_OBJECTS) $(src_makecert_LDADD) $(LIBS) src/src_test_zgossip-test_zgossip.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/test_zgossip$(EXEEXT): $(src_test_zgossip_OBJECTS) $(src_test_zgossip_DEPENDENCIES) $(EXTRA_src_test_zgossip_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/test_zgossip$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_test_zgossip_OBJECTS) $(src_test_zgossip_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f src/src_czmq_selftest-czmq_selftest.$(OBJEXT) -rm -f src/src_libczmq_la-zactor.$(OBJEXT) -rm -f src/src_libczmq_la-zactor.lo -rm -f src/src_libczmq_la-zarmour.$(OBJEXT) -rm -f src/src_libczmq_la-zarmour.lo -rm -f src/src_libczmq_la-zauth.$(OBJEXT) -rm -f src/src_libczmq_la-zauth.lo -rm -f src/src_libczmq_la-zauth_v2.$(OBJEXT) -rm -f src/src_libczmq_la-zauth_v2.lo -rm -f src/src_libczmq_la-zbeacon.$(OBJEXT) -rm -f src/src_libczmq_la-zbeacon.lo -rm -f src/src_libczmq_la-zbeacon_v2.$(OBJEXT) -rm -f src/src_libczmq_la-zbeacon_v2.lo -rm -f src/src_libczmq_la-zcert.$(OBJEXT) -rm -f src/src_libczmq_la-zcert.lo -rm -f src/src_libczmq_la-zcertstore.$(OBJEXT) -rm -f src/src_libczmq_la-zcertstore.lo -rm -f src/src_libczmq_la-zchunk.$(OBJEXT) -rm -f src/src_libczmq_la-zchunk.lo -rm -f src/src_libczmq_la-zclock.$(OBJEXT) -rm -f src/src_libczmq_la-zclock.lo -rm -f src/src_libczmq_la-zconfig.$(OBJEXT) -rm -f src/src_libczmq_la-zconfig.lo -rm -f src/src_libczmq_la-zctx.$(OBJEXT) -rm -f src/src_libczmq_la-zctx.lo -rm -f src/src_libczmq_la-zdigest.$(OBJEXT) -rm -f src/src_libczmq_la-zdigest.lo -rm -f src/src_libczmq_la-zdir.$(OBJEXT) -rm -f src/src_libczmq_la-zdir.lo -rm -f src/src_libczmq_la-zdir_patch.$(OBJEXT) -rm -f src/src_libczmq_la-zdir_patch.lo -rm -f src/src_libczmq_la-zfile.$(OBJEXT) -rm -f src/src_libczmq_la-zfile.lo -rm -f src/src_libczmq_la-zframe.$(OBJEXT) -rm -f src/src_libczmq_la-zframe.lo -rm -f src/src_libczmq_la-zgossip.$(OBJEXT) -rm -f src/src_libczmq_la-zgossip.lo -rm -f src/src_libczmq_la-zgossip_msg.$(OBJEXT) -rm -f src/src_libczmq_la-zgossip_msg.lo -rm -f src/src_libczmq_la-zhash.$(OBJEXT) -rm -f src/src_libczmq_la-zhash.lo -rm -f src/src_libczmq_la-zhashx.$(OBJEXT) -rm -f src/src_libczmq_la-zhashx.lo -rm -f src/src_libczmq_la-ziflist.$(OBJEXT) -rm -f src/src_libczmq_la-ziflist.lo -rm -f src/src_libczmq_la-zlist.$(OBJEXT) -rm -f src/src_libczmq_la-zlist.lo -rm -f src/src_libczmq_la-zlistx.$(OBJEXT) -rm -f src/src_libczmq_la-zlistx.lo -rm -f src/src_libczmq_la-zloop.$(OBJEXT) -rm -f src/src_libczmq_la-zloop.lo -rm -f src/src_libczmq_la-zmonitor.$(OBJEXT) -rm -f src/src_libczmq_la-zmonitor.lo -rm -f src/src_libczmq_la-zmonitor_v2.$(OBJEXT) -rm -f src/src_libczmq_la-zmonitor_v2.lo -rm -f src/src_libczmq_la-zmsg.$(OBJEXT) -rm -f src/src_libczmq_la-zmsg.lo -rm -f src/src_libczmq_la-zmutex.$(OBJEXT) -rm -f src/src_libczmq_la-zmutex.lo -rm -f src/src_libczmq_la-zpoller.$(OBJEXT) -rm -f src/src_libczmq_la-zpoller.lo -rm -f src/src_libczmq_la-zproxy.$(OBJEXT) -rm -f src/src_libczmq_la-zproxy.lo -rm -f src/src_libczmq_la-zproxy_v2.$(OBJEXT) -rm -f src/src_libczmq_la-zproxy_v2.lo -rm -f src/src_libczmq_la-zrex.$(OBJEXT) -rm -f src/src_libczmq_la-zrex.lo -rm -f src/src_libczmq_la-zsock.$(OBJEXT) -rm -f src/src_libczmq_la-zsock.lo -rm -f src/src_libczmq_la-zsock_option.$(OBJEXT) -rm -f src/src_libczmq_la-zsock_option.lo -rm -f src/src_libczmq_la-zsocket.$(OBJEXT) -rm -f src/src_libczmq_la-zsocket.lo -rm -f src/src_libczmq_la-zsockopt.$(OBJEXT) -rm -f src/src_libczmq_la-zsockopt.lo -rm -f src/src_libczmq_la-zstr.$(OBJEXT) -rm -f src/src_libczmq_la-zstr.lo -rm -f src/src_libczmq_la-zsys.$(OBJEXT) -rm -f src/src_libczmq_la-zsys.lo -rm -f src/src_libczmq_la-zthread.$(OBJEXT) -rm -f src/src_libczmq_la-zthread.lo -rm -f src/src_libczmq_la-zuuid.$(OBJEXT) -rm -f src/src_libczmq_la-zuuid.lo -rm -f src/src_makecert-makecert.$(OBJEXT) -rm -f src/src_test_zgossip-test_zgossip.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zactor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zarmour.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zauth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zauth_v2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zbeacon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zbeacon_v2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zcert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zcertstore.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zchunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zclock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zconfig.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zctx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zdigest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zdir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zdir_patch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zfile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zframe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zgossip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zhash.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zhashx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-ziflist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zlist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zlistx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zloop.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zmonitor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zmonitor_v2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zmsg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zmutex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zpoller.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zproxy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zproxy_v2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zrex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsock_option.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsocket.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsockopt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zstr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsys.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zthread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zuuid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_makecert-makecert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_test_zgossip-test_zgossip.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< src/src_libczmq_la-zactor.lo: src/zactor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zactor.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zactor.Tpo -c -o src/src_libczmq_la-zactor.lo `test -f 'src/zactor.c' || echo '$(srcdir)/'`src/zactor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zactor.Tpo src/$(DEPDIR)/src_libczmq_la-zactor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zactor.c' object='src/src_libczmq_la-zactor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zactor.lo `test -f 'src/zactor.c' || echo '$(srcdir)/'`src/zactor.c src/src_libczmq_la-zauth.lo: src/zauth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zauth.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zauth.Tpo -c -o src/src_libczmq_la-zauth.lo `test -f 'src/zauth.c' || echo '$(srcdir)/'`src/zauth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zauth.Tpo src/$(DEPDIR)/src_libczmq_la-zauth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zauth.c' object='src/src_libczmq_la-zauth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zauth.lo `test -f 'src/zauth.c' || echo '$(srcdir)/'`src/zauth.c src/src_libczmq_la-zarmour.lo: src/zarmour.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zarmour.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zarmour.Tpo -c -o src/src_libczmq_la-zarmour.lo `test -f 'src/zarmour.c' || echo '$(srcdir)/'`src/zarmour.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zarmour.Tpo src/$(DEPDIR)/src_libczmq_la-zarmour.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zarmour.c' object='src/src_libczmq_la-zarmour.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zarmour.lo `test -f 'src/zarmour.c' || echo '$(srcdir)/'`src/zarmour.c src/src_libczmq_la-zbeacon.lo: src/zbeacon.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zbeacon.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zbeacon.Tpo -c -o src/src_libczmq_la-zbeacon.lo `test -f 'src/zbeacon.c' || echo '$(srcdir)/'`src/zbeacon.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zbeacon.Tpo src/$(DEPDIR)/src_libczmq_la-zbeacon.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zbeacon.c' object='src/src_libczmq_la-zbeacon.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zbeacon.lo `test -f 'src/zbeacon.c' || echo '$(srcdir)/'`src/zbeacon.c src/src_libczmq_la-zcert.lo: src/zcert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zcert.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zcert.Tpo -c -o src/src_libczmq_la-zcert.lo `test -f 'src/zcert.c' || echo '$(srcdir)/'`src/zcert.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zcert.Tpo src/$(DEPDIR)/src_libczmq_la-zcert.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zcert.c' object='src/src_libczmq_la-zcert.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zcert.lo `test -f 'src/zcert.c' || echo '$(srcdir)/'`src/zcert.c src/src_libczmq_la-zcertstore.lo: src/zcertstore.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zcertstore.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zcertstore.Tpo -c -o src/src_libczmq_la-zcertstore.lo `test -f 'src/zcertstore.c' || echo '$(srcdir)/'`src/zcertstore.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zcertstore.Tpo src/$(DEPDIR)/src_libczmq_la-zcertstore.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zcertstore.c' object='src/src_libczmq_la-zcertstore.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zcertstore.lo `test -f 'src/zcertstore.c' || echo '$(srcdir)/'`src/zcertstore.c src/src_libczmq_la-zchunk.lo: src/zchunk.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zchunk.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zchunk.Tpo -c -o src/src_libczmq_la-zchunk.lo `test -f 'src/zchunk.c' || echo '$(srcdir)/'`src/zchunk.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zchunk.Tpo src/$(DEPDIR)/src_libczmq_la-zchunk.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zchunk.c' object='src/src_libczmq_la-zchunk.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zchunk.lo `test -f 'src/zchunk.c' || echo '$(srcdir)/'`src/zchunk.c src/src_libczmq_la-zclock.lo: src/zclock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zclock.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zclock.Tpo -c -o src/src_libczmq_la-zclock.lo `test -f 'src/zclock.c' || echo '$(srcdir)/'`src/zclock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zclock.Tpo src/$(DEPDIR)/src_libczmq_la-zclock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zclock.c' object='src/src_libczmq_la-zclock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zclock.lo `test -f 'src/zclock.c' || echo '$(srcdir)/'`src/zclock.c src/src_libczmq_la-zconfig.lo: src/zconfig.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zconfig.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zconfig.Tpo -c -o src/src_libczmq_la-zconfig.lo `test -f 'src/zconfig.c' || echo '$(srcdir)/'`src/zconfig.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zconfig.Tpo src/$(DEPDIR)/src_libczmq_la-zconfig.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zconfig.c' object='src/src_libczmq_la-zconfig.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zconfig.lo `test -f 'src/zconfig.c' || echo '$(srcdir)/'`src/zconfig.c src/src_libczmq_la-zdigest.lo: src/zdigest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zdigest.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zdigest.Tpo -c -o src/src_libczmq_la-zdigest.lo `test -f 'src/zdigest.c' || echo '$(srcdir)/'`src/zdigest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zdigest.Tpo src/$(DEPDIR)/src_libczmq_la-zdigest.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zdigest.c' object='src/src_libczmq_la-zdigest.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zdigest.lo `test -f 'src/zdigest.c' || echo '$(srcdir)/'`src/zdigest.c src/src_libczmq_la-zdir.lo: src/zdir.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zdir.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zdir.Tpo -c -o src/src_libczmq_la-zdir.lo `test -f 'src/zdir.c' || echo '$(srcdir)/'`src/zdir.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zdir.Tpo src/$(DEPDIR)/src_libczmq_la-zdir.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zdir.c' object='src/src_libczmq_la-zdir.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zdir.lo `test -f 'src/zdir.c' || echo '$(srcdir)/'`src/zdir.c src/src_libczmq_la-zdir_patch.lo: src/zdir_patch.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zdir_patch.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zdir_patch.Tpo -c -o src/src_libczmq_la-zdir_patch.lo `test -f 'src/zdir_patch.c' || echo '$(srcdir)/'`src/zdir_patch.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zdir_patch.Tpo src/$(DEPDIR)/src_libczmq_la-zdir_patch.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zdir_patch.c' object='src/src_libczmq_la-zdir_patch.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zdir_patch.lo `test -f 'src/zdir_patch.c' || echo '$(srcdir)/'`src/zdir_patch.c src/src_libczmq_la-zfile.lo: src/zfile.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zfile.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zfile.Tpo -c -o src/src_libczmq_la-zfile.lo `test -f 'src/zfile.c' || echo '$(srcdir)/'`src/zfile.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zfile.Tpo src/$(DEPDIR)/src_libczmq_la-zfile.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zfile.c' object='src/src_libczmq_la-zfile.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zfile.lo `test -f 'src/zfile.c' || echo '$(srcdir)/'`src/zfile.c src/src_libczmq_la-zframe.lo: src/zframe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zframe.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zframe.Tpo -c -o src/src_libczmq_la-zframe.lo `test -f 'src/zframe.c' || echo '$(srcdir)/'`src/zframe.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zframe.Tpo src/$(DEPDIR)/src_libczmq_la-zframe.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zframe.c' object='src/src_libczmq_la-zframe.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zframe.lo `test -f 'src/zframe.c' || echo '$(srcdir)/'`src/zframe.c src/src_libczmq_la-zgossip.lo: src/zgossip.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zgossip.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zgossip.Tpo -c -o src/src_libczmq_la-zgossip.lo `test -f 'src/zgossip.c' || echo '$(srcdir)/'`src/zgossip.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zgossip.Tpo src/$(DEPDIR)/src_libczmq_la-zgossip.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zgossip.c' object='src/src_libczmq_la-zgossip.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zgossip.lo `test -f 'src/zgossip.c' || echo '$(srcdir)/'`src/zgossip.c src/src_libczmq_la-zhashx.lo: src/zhashx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zhashx.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zhashx.Tpo -c -o src/src_libczmq_la-zhashx.lo `test -f 'src/zhashx.c' || echo '$(srcdir)/'`src/zhashx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zhashx.Tpo src/$(DEPDIR)/src_libczmq_la-zhashx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zhashx.c' object='src/src_libczmq_la-zhashx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zhashx.lo `test -f 'src/zhashx.c' || echo '$(srcdir)/'`src/zhashx.c src/src_libczmq_la-ziflist.lo: src/ziflist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-ziflist.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-ziflist.Tpo -c -o src/src_libczmq_la-ziflist.lo `test -f 'src/ziflist.c' || echo '$(srcdir)/'`src/ziflist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-ziflist.Tpo src/$(DEPDIR)/src_libczmq_la-ziflist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ziflist.c' object='src/src_libczmq_la-ziflist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-ziflist.lo `test -f 'src/ziflist.c' || echo '$(srcdir)/'`src/ziflist.c src/src_libczmq_la-zlistx.lo: src/zlistx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zlistx.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zlistx.Tpo -c -o src/src_libczmq_la-zlistx.lo `test -f 'src/zlistx.c' || echo '$(srcdir)/'`src/zlistx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zlistx.Tpo src/$(DEPDIR)/src_libczmq_la-zlistx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zlistx.c' object='src/src_libczmq_la-zlistx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zlistx.lo `test -f 'src/zlistx.c' || echo '$(srcdir)/'`src/zlistx.c src/src_libczmq_la-zloop.lo: src/zloop.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zloop.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zloop.Tpo -c -o src/src_libczmq_la-zloop.lo `test -f 'src/zloop.c' || echo '$(srcdir)/'`src/zloop.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zloop.Tpo src/$(DEPDIR)/src_libczmq_la-zloop.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zloop.c' object='src/src_libczmq_la-zloop.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zloop.lo `test -f 'src/zloop.c' || echo '$(srcdir)/'`src/zloop.c src/src_libczmq_la-zmonitor.lo: src/zmonitor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zmonitor.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zmonitor.Tpo -c -o src/src_libczmq_la-zmonitor.lo `test -f 'src/zmonitor.c' || echo '$(srcdir)/'`src/zmonitor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zmonitor.Tpo src/$(DEPDIR)/src_libczmq_la-zmonitor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmonitor.c' object='src/src_libczmq_la-zmonitor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zmonitor.lo `test -f 'src/zmonitor.c' || echo '$(srcdir)/'`src/zmonitor.c src/src_libczmq_la-zmsg.lo: src/zmsg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zmsg.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zmsg.Tpo -c -o src/src_libczmq_la-zmsg.lo `test -f 'src/zmsg.c' || echo '$(srcdir)/'`src/zmsg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zmsg.Tpo src/$(DEPDIR)/src_libczmq_la-zmsg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmsg.c' object='src/src_libczmq_la-zmsg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zmsg.lo `test -f 'src/zmsg.c' || echo '$(srcdir)/'`src/zmsg.c src/src_libczmq_la-zpoller.lo: src/zpoller.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zpoller.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zpoller.Tpo -c -o src/src_libczmq_la-zpoller.lo `test -f 'src/zpoller.c' || echo '$(srcdir)/'`src/zpoller.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zpoller.Tpo src/$(DEPDIR)/src_libczmq_la-zpoller.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zpoller.c' object='src/src_libczmq_la-zpoller.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zpoller.lo `test -f 'src/zpoller.c' || echo '$(srcdir)/'`src/zpoller.c src/src_libczmq_la-zproxy.lo: src/zproxy.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zproxy.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zproxy.Tpo -c -o src/src_libczmq_la-zproxy.lo `test -f 'src/zproxy.c' || echo '$(srcdir)/'`src/zproxy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zproxy.Tpo src/$(DEPDIR)/src_libczmq_la-zproxy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zproxy.c' object='src/src_libczmq_la-zproxy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zproxy.lo `test -f 'src/zproxy.c' || echo '$(srcdir)/'`src/zproxy.c src/src_libczmq_la-zrex.lo: src/zrex.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zrex.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zrex.Tpo -c -o src/src_libczmq_la-zrex.lo `test -f 'src/zrex.c' || echo '$(srcdir)/'`src/zrex.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zrex.Tpo src/$(DEPDIR)/src_libczmq_la-zrex.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zrex.c' object='src/src_libczmq_la-zrex.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zrex.lo `test -f 'src/zrex.c' || echo '$(srcdir)/'`src/zrex.c src/src_libczmq_la-zsock.lo: src/zsock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsock.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsock.Tpo -c -o src/src_libczmq_la-zsock.lo `test -f 'src/zsock.c' || echo '$(srcdir)/'`src/zsock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsock.Tpo src/$(DEPDIR)/src_libczmq_la-zsock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsock.c' object='src/src_libczmq_la-zsock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsock.lo `test -f 'src/zsock.c' || echo '$(srcdir)/'`src/zsock.c src/src_libczmq_la-zsock_option.lo: src/zsock_option.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsock_option.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsock_option.Tpo -c -o src/src_libczmq_la-zsock_option.lo `test -f 'src/zsock_option.c' || echo '$(srcdir)/'`src/zsock_option.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsock_option.Tpo src/$(DEPDIR)/src_libczmq_la-zsock_option.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsock_option.c' object='src/src_libczmq_la-zsock_option.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsock_option.lo `test -f 'src/zsock_option.c' || echo '$(srcdir)/'`src/zsock_option.c src/src_libczmq_la-zstr.lo: src/zstr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zstr.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zstr.Tpo -c -o src/src_libczmq_la-zstr.lo `test -f 'src/zstr.c' || echo '$(srcdir)/'`src/zstr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zstr.Tpo src/$(DEPDIR)/src_libczmq_la-zstr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zstr.c' object='src/src_libczmq_la-zstr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zstr.lo `test -f 'src/zstr.c' || echo '$(srcdir)/'`src/zstr.c src/src_libczmq_la-zsys.lo: src/zsys.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsys.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsys.Tpo -c -o src/src_libczmq_la-zsys.lo `test -f 'src/zsys.c' || echo '$(srcdir)/'`src/zsys.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsys.Tpo src/$(DEPDIR)/src_libczmq_la-zsys.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsys.c' object='src/src_libczmq_la-zsys.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsys.lo `test -f 'src/zsys.c' || echo '$(srcdir)/'`src/zsys.c src/src_libczmq_la-zuuid.lo: src/zuuid.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zuuid.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zuuid.Tpo -c -o src/src_libczmq_la-zuuid.lo `test -f 'src/zuuid.c' || echo '$(srcdir)/'`src/zuuid.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zuuid.Tpo src/$(DEPDIR)/src_libczmq_la-zuuid.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zuuid.c' object='src/src_libczmq_la-zuuid.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zuuid.lo `test -f 'src/zuuid.c' || echo '$(srcdir)/'`src/zuuid.c src/src_libczmq_la-zgossip_msg.lo: src/zgossip_msg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zgossip_msg.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Tpo -c -o src/src_libczmq_la-zgossip_msg.lo `test -f 'src/zgossip_msg.c' || echo '$(srcdir)/'`src/zgossip_msg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Tpo src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zgossip_msg.c' object='src/src_libczmq_la-zgossip_msg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zgossip_msg.lo `test -f 'src/zgossip_msg.c' || echo '$(srcdir)/'`src/zgossip_msg.c src/src_libczmq_la-zauth_v2.lo: src/zauth_v2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zauth_v2.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zauth_v2.Tpo -c -o src/src_libczmq_la-zauth_v2.lo `test -f 'src/zauth_v2.c' || echo '$(srcdir)/'`src/zauth_v2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zauth_v2.Tpo src/$(DEPDIR)/src_libczmq_la-zauth_v2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zauth_v2.c' object='src/src_libczmq_la-zauth_v2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zauth_v2.lo `test -f 'src/zauth_v2.c' || echo '$(srcdir)/'`src/zauth_v2.c src/src_libczmq_la-zbeacon_v2.lo: src/zbeacon_v2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zbeacon_v2.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zbeacon_v2.Tpo -c -o src/src_libczmq_la-zbeacon_v2.lo `test -f 'src/zbeacon_v2.c' || echo '$(srcdir)/'`src/zbeacon_v2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zbeacon_v2.Tpo src/$(DEPDIR)/src_libczmq_la-zbeacon_v2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zbeacon_v2.c' object='src/src_libczmq_la-zbeacon_v2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zbeacon_v2.lo `test -f 'src/zbeacon_v2.c' || echo '$(srcdir)/'`src/zbeacon_v2.c src/src_libczmq_la-zctx.lo: src/zctx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zctx.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zctx.Tpo -c -o src/src_libczmq_la-zctx.lo `test -f 'src/zctx.c' || echo '$(srcdir)/'`src/zctx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zctx.Tpo src/$(DEPDIR)/src_libczmq_la-zctx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zctx.c' object='src/src_libczmq_la-zctx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zctx.lo `test -f 'src/zctx.c' || echo '$(srcdir)/'`src/zctx.c src/src_libczmq_la-zhash.lo: src/zhash.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zhash.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zhash.Tpo -c -o src/src_libczmq_la-zhash.lo `test -f 'src/zhash.c' || echo '$(srcdir)/'`src/zhash.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zhash.Tpo src/$(DEPDIR)/src_libczmq_la-zhash.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zhash.c' object='src/src_libczmq_la-zhash.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zhash.lo `test -f 'src/zhash.c' || echo '$(srcdir)/'`src/zhash.c src/src_libczmq_la-zlist.lo: src/zlist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zlist.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zlist.Tpo -c -o src/src_libczmq_la-zlist.lo `test -f 'src/zlist.c' || echo '$(srcdir)/'`src/zlist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zlist.Tpo src/$(DEPDIR)/src_libczmq_la-zlist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zlist.c' object='src/src_libczmq_la-zlist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zlist.lo `test -f 'src/zlist.c' || echo '$(srcdir)/'`src/zlist.c src/src_libczmq_la-zmonitor_v2.lo: src/zmonitor_v2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zmonitor_v2.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zmonitor_v2.Tpo -c -o src/src_libczmq_la-zmonitor_v2.lo `test -f 'src/zmonitor_v2.c' || echo '$(srcdir)/'`src/zmonitor_v2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zmonitor_v2.Tpo src/$(DEPDIR)/src_libczmq_la-zmonitor_v2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmonitor_v2.c' object='src/src_libczmq_la-zmonitor_v2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zmonitor_v2.lo `test -f 'src/zmonitor_v2.c' || echo '$(srcdir)/'`src/zmonitor_v2.c src/src_libczmq_la-zmutex.lo: src/zmutex.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zmutex.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zmutex.Tpo -c -o src/src_libczmq_la-zmutex.lo `test -f 'src/zmutex.c' || echo '$(srcdir)/'`src/zmutex.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zmutex.Tpo src/$(DEPDIR)/src_libczmq_la-zmutex.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmutex.c' object='src/src_libczmq_la-zmutex.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zmutex.lo `test -f 'src/zmutex.c' || echo '$(srcdir)/'`src/zmutex.c src/src_libczmq_la-zproxy_v2.lo: src/zproxy_v2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zproxy_v2.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zproxy_v2.Tpo -c -o src/src_libczmq_la-zproxy_v2.lo `test -f 'src/zproxy_v2.c' || echo '$(srcdir)/'`src/zproxy_v2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zproxy_v2.Tpo src/$(DEPDIR)/src_libczmq_la-zproxy_v2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zproxy_v2.c' object='src/src_libczmq_la-zproxy_v2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zproxy_v2.lo `test -f 'src/zproxy_v2.c' || echo '$(srcdir)/'`src/zproxy_v2.c src/src_libczmq_la-zsocket.lo: src/zsocket.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsocket.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsocket.Tpo -c -o src/src_libczmq_la-zsocket.lo `test -f 'src/zsocket.c' || echo '$(srcdir)/'`src/zsocket.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsocket.Tpo src/$(DEPDIR)/src_libczmq_la-zsocket.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsocket.c' object='src/src_libczmq_la-zsocket.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsocket.lo `test -f 'src/zsocket.c' || echo '$(srcdir)/'`src/zsocket.c src/src_libczmq_la-zsockopt.lo: src/zsockopt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsockopt.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsockopt.Tpo -c -o src/src_libczmq_la-zsockopt.lo `test -f 'src/zsockopt.c' || echo '$(srcdir)/'`src/zsockopt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsockopt.Tpo src/$(DEPDIR)/src_libczmq_la-zsockopt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsockopt.c' object='src/src_libczmq_la-zsockopt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsockopt.lo `test -f 'src/zsockopt.c' || echo '$(srcdir)/'`src/zsockopt.c src/src_libczmq_la-zthread.lo: src/zthread.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zthread.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zthread.Tpo -c -o src/src_libczmq_la-zthread.lo `test -f 'src/zthread.c' || echo '$(srcdir)/'`src/zthread.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zthread.Tpo src/$(DEPDIR)/src_libczmq_la-zthread.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zthread.c' object='src/src_libczmq_la-zthread.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zthread.lo `test -f 'src/zthread.c' || echo '$(srcdir)/'`src/zthread.c src/src_czmq_selftest-czmq_selftest.o: src/czmq_selftest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_czmq_selftest-czmq_selftest.o -MD -MP -MF src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo -c -o src/src_czmq_selftest-czmq_selftest.o `test -f 'src/czmq_selftest.c' || echo '$(srcdir)/'`src/czmq_selftest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/czmq_selftest.c' object='src/src_czmq_selftest-czmq_selftest.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_czmq_selftest-czmq_selftest.o `test -f 'src/czmq_selftest.c' || echo '$(srcdir)/'`src/czmq_selftest.c src/src_czmq_selftest-czmq_selftest.obj: src/czmq_selftest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_czmq_selftest-czmq_selftest.obj -MD -MP -MF src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo -c -o src/src_czmq_selftest-czmq_selftest.obj `if test -f 'src/czmq_selftest.c'; then $(CYGPATH_W) 'src/czmq_selftest.c'; else $(CYGPATH_W) '$(srcdir)/src/czmq_selftest.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/czmq_selftest.c' object='src/src_czmq_selftest-czmq_selftest.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_czmq_selftest-czmq_selftest.obj `if test -f 'src/czmq_selftest.c'; then $(CYGPATH_W) 'src/czmq_selftest.c'; else $(CYGPATH_W) '$(srcdir)/src/czmq_selftest.c'; fi` src/src_makecert-makecert.o: src/makecert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_makecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_makecert-makecert.o -MD -MP -MF src/$(DEPDIR)/src_makecert-makecert.Tpo -c -o src/src_makecert-makecert.o `test -f 'src/makecert.c' || echo '$(srcdir)/'`src/makecert.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_makecert-makecert.Tpo src/$(DEPDIR)/src_makecert-makecert.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/makecert.c' object='src/src_makecert-makecert.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_makecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_makecert-makecert.o `test -f 'src/makecert.c' || echo '$(srcdir)/'`src/makecert.c src/src_makecert-makecert.obj: src/makecert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_makecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_makecert-makecert.obj -MD -MP -MF src/$(DEPDIR)/src_makecert-makecert.Tpo -c -o src/src_makecert-makecert.obj `if test -f 'src/makecert.c'; then $(CYGPATH_W) 'src/makecert.c'; else $(CYGPATH_W) '$(srcdir)/src/makecert.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_makecert-makecert.Tpo src/$(DEPDIR)/src_makecert-makecert.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/makecert.c' object='src/src_makecert-makecert.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_makecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_makecert-makecert.obj `if test -f 'src/makecert.c'; then $(CYGPATH_W) 'src/makecert.c'; else $(CYGPATH_W) '$(srcdir)/src/makecert.c'; fi` src/src_test_zgossip-test_zgossip.o: src/test_zgossip.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_zgossip_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_test_zgossip-test_zgossip.o -MD -MP -MF src/$(DEPDIR)/src_test_zgossip-test_zgossip.Tpo -c -o src/src_test_zgossip-test_zgossip.o `test -f 'src/test_zgossip.c' || echo '$(srcdir)/'`src/test_zgossip.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_test_zgossip-test_zgossip.Tpo src/$(DEPDIR)/src_test_zgossip-test_zgossip.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/test_zgossip.c' object='src/src_test_zgossip-test_zgossip.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_zgossip_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_test_zgossip-test_zgossip.o `test -f 'src/test_zgossip.c' || echo '$(srcdir)/'`src/test_zgossip.c src/src_test_zgossip-test_zgossip.obj: src/test_zgossip.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_zgossip_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_test_zgossip-test_zgossip.obj -MD -MP -MF src/$(DEPDIR)/src_test_zgossip-test_zgossip.Tpo -c -o src/src_test_zgossip-test_zgossip.obj `if test -f 'src/test_zgossip.c'; then $(CYGPATH_W) 'src/test_zgossip.c'; else $(CYGPATH_W) '$(srcdir)/src/test_zgossip.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_test_zgossip-test_zgossip.Tpo src/$(DEPDIR)/src_test_zgossip-test_zgossip.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/test_zgossip.c' object='src/src_test_zgossip-test_zgossip.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_zgossip_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_test_zgossip-test_zgossip.obj `if test -f 'src/test_zgossip.c'; then $(CYGPATH_W) 'src/test_zgossip.c'; else $(CYGPATH_W) '$(srcdir)/src/test_zgossip.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf src/.libs src/_libs distclean-libtool: -rm -f libtool config.lt install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ col="$$grn"; \ else \ col="$$red"; \ fi; \ echo "$${col}$$dashes$${std}"; \ echo "$${col}$$banner$${std}"; \ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ test -z "$$report" || echo "$${col}$$report$${std}"; \ echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local check: check-recursive all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f src/$(DEPDIR)/$(am__dirstamp) -rm -f src/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf src/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-includeHEADERS install-pkgconfigDATA install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf src/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-pkgconfigDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) check-am \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-TESTS check-am check-local \ clean clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ clean-noinstPROGRAMS ctags ctags-recursive dist dist-all \ dist-bzip2 dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ \ dist-xz dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-libtool \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-includeHEADERS install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-includeHEADERS uninstall-libLTLIBRARIES \ uninstall-pkgconfigDATA # define custom target for all products of /src src: src/libczmq.la src/czmq_selftest # Produce generated code from models in the src directory code: cd $(srcdir)/src; gsl -q sockopts.xml cd $(srcdir)/src; gsl -q zgossip.xml cd $(srcdir)/src; gsl -q zgossip_msg.xml check-local: src/czmq_selftest $(LIBTOOL) --mode=execute $(srcdir)/src/czmq_selftest check-verbose: src/czmq_selftest $(LIBTOOL) --mode=execute $(srcdir)/src/czmq_selftest -v # Run the selftest binary under valgrind to check for memory leaks memcheck: src/czmq_selftest $(LIBTOOL) --mode=execute valgrind --tool=memcheck \ --leak-check=full --show-reachable=yes --error-exitcode=1 \ --suppressions=$(srcdir)/src/.valgrind.supp \ $(srcdir)/src/czmq_selftest # Run the selftest binary under gdb for debugging debug: src/czmq_selftest $(LIBTOOL) --mode=execute gdb -q \ $(srcdir)/src/czmq_selftest # Run the selftest binary with verbose switch for tracing animate: src/czmq_selftest $(LIBTOOL) --mode=execute $(srcdir)/src/czmq_selftest -v ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ check-py: src/libczmq.la $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: czmq-3.0.2/version.sh0000775000175000017500000000261012535241704013616 0ustar00phph00000000000000#!/usr/bin/env sh ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ # # This script extracts the version from the project header file # project=$1 appendix="_library" if [ ! -f include/$project$appendix.h ]; then echo 3.0.2 | tr -d '\n' exit 0 fi MAJOR=`egrep '^#define .*_VERSION_MAJOR +[0-9]+$' include/$project$appendix.h` MINOR=`egrep '^#define .*_VERSION_MINOR +[0-9]+$' include/$project$appendix.h` PATCH=`egrep '^#define .*_VERSION_PATCH +[0-9]+$' include/$project$appendix.h` if [ -z "$MAJOR" -o -z "$MINOR" -o -z "$PATCH" ]; then echo "version.sh: error: could not extract version from include/$project$appendix.h" 1>&2 exit 1 fi MAJOR=`echo $MAJOR | awk '{ print $3 }'` MINOR=`echo $MINOR | awk '{ print $3 }'` PATCH=`echo $PATCH | awk '{ print $3 }'` echo $MAJOR.$MINOR.$PATCH | tr -d '\n' ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ czmq-3.0.2/AUTHORS0000664000175000017500000000157012505070716012646 0ustar00phph00000000000000Corporate Copyright Statements ============================== Copyright (c) 1991-2014 iMatix Corporation Contributors ============ Pieter Hintjens Uli Köhler KIU Shueng Chuan Brian Knox Felipe cruz Chris Laws AJ Lewis Shannen Saez Kevin Sapper Michael Haberler Momo the Monster Stephen Hemminger Felipe Cruz Matt Connolly Steven McCoy Timothee "TTimo" Besset evoskuil Javier Lopez Lourens Naude Shane Hubred TJ Holowaychuk William Roberts Mikko Koppanen HughPowell Akira Kitada Amir Taaki Apostolis Xekoukoulotakis James Tucker Juan López Rubio Martin Hurton Augusto Henrique Hentz Bruno D. Rodrigues Bulat Shakirzyanov Dan Colish Dongmin Yu Gavin Jason Ziglar Kaustubh Rawoorkar Luc Heinrich MilfordTea Timothee Besset jpulver woldan Patrick Noffke Brandon Ehle Mike Gatny Chris Busbey Goswin von Brederlow Svein L. Ellingsen oikosdevczmq-3.0.2/include/0000775000175000017500000000000012535242314013214 5ustar00phph00000000000000czmq-3.0.2/include/zdir.h0000664000175000017500000001375012535241704014345 0ustar00phph00000000000000/* ========================================================================= zdir - work with file-system directories Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZDIR_H_INCLUDED__ #define __ZDIR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zdir.xml" to make changes. // @interface // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. CZMQ_EXPORT zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. CZMQ_EXPORT void zdir_destroy (zdir_t **self_p); // Return directory path CZMQ_EXPORT const char * zdir_path (zdir_t *self); // Return last modification time for directory. CZMQ_EXPORT time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. CZMQ_EXPORT off_t zdir_cursize (zdir_t *self); // Return directory count CZMQ_EXPORT size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. CZMQ_EXPORT void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream CZMQ_EXPORT void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout CZMQ_EXPORT void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); CZMQ_EXPORT void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. CZMQ_EXPORT void zdir_test (bool verbose); // @end // Returns a sorted array of zfile objects; returns a single block of memory, // that you destroy by calling zstr_free(). Each entry in the array is a pointer // to a zfile_t item already allocated in the zdir tree. The array ends with // a null pointer. Do not destroy the original zdir tree until you are done // with this array. CZMQ_EXPORT zfile_t ** zdir_flatten (zdir_t *self); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zdir_flatten_free (zfile_t ***files_p); #ifdef __cplusplus } #endif // Deprecated method aliases #define zdir_dump(s,i) zdir_print(s,i) #endif czmq-3.0.2/include/zcertstore.h0000664000175000017500000000455212505070716015601 0ustar00phph00000000000000/* ========================================================================= zcertstore - work with CURVE security certificate stores Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCERTSTORE_H_INCLUDED__ #define __ZCERTSTORE_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. CZMQ_EXPORT zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. CZMQ_EXPORT void zcertstore_destroy (zcertstore_t **self_p); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. CZMQ_EXPORT zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. CZMQ_EXPORT void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Print list of certificates in store to logging facility CZMQ_EXPORT void zcertstore_print (zcertstore_t *self); // DEPRECATED as incompatible with centralized logging // Print list of certificates in store to open stream CZMQ_EXPORT void zcertstore_fprint (zcertstore_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcertstore_test (bool verbose); // @end #ifdef __cplusplus } #endif // Deprecated method aliases #define zcertstore_dump(s) zcertstore_print(s) #endif czmq-3.0.2/include/zsys.h0000664000175000017500000003365412505070716014412 0ustar00phph00000000000000/* ========================================================================= zsys - system-level methods Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSYS_H_INCLUDED__ #define __ZSYS_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface #define UDP_FRAME_MAX 255 // Max size of UDP frame // Callback for interrupt signal handler typedef void (zsys_handler_fn) (int signal_value); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. CZMQ_EXPORT void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. CZMQ_EXPORT void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. CZMQ_EXPORT zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. CZMQ_EXPORT void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed CZMQ_EXPORT void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_catch_interrupts (void); // Return 1 if file exists, else zero CZMQ_EXPORT bool zsys_file_exists (const char *filename); // Return size of file, or -1 if not found CZMQ_EXPORT ssize_t zsys_file_size (const char *filename); // Return file modification time. Returns 0 if the file does not exist. CZMQ_EXPORT time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. CZMQ_EXPORT int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent CZMQ_EXPORT int zsys_file_delete (const char *filename); // Check if file is 'stable' CZMQ_EXPORT bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as a // printf format. CZMQ_EXPORT int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. CZMQ_EXPORT int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. CZMQ_EXPORT int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. CZMQ_EXPORT void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. CZMQ_EXPORT void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. CZMQ_EXPORT void zsys_version (int *major, int *minor, int *patch); // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. CZMQ_EXPORT char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. CZMQ_EXPORT int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. CZMQ_EXPORT int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. CZMQ_EXPORT bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. CZMQ_EXPORT size_t zsys_socket_limit (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. CZMQ_EXPORT void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. CZMQ_EXPORT size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. CZMQ_EXPORT void zsys_set_ipv6 (int ipv6); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zsys_interface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). CZMQ_EXPORT void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority CZMQ_EXPORT void zsys_error (const char *format, ...); // Log warning condition - high priority CZMQ_EXPORT void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zsys_notice (const char *format, ...); // Log informational message - low priority CZMQ_EXPORT void zsys_info (const char *format, ...); // Log debug-level message - lowest priority CZMQ_EXPORT void zsys_debug (const char *format, ...); // Self test of this class CZMQ_EXPORT void zsys_test (bool verbose); // Global signal indicator, TRUE when user presses Ctrl-C or the process // gets a SIGTERM signal. CZMQ_EXPORT extern volatile int zsys_interrupted; // Deprecated name for this variable CZMQ_EXPORT extern volatile int zctx_interrupted; // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zauth_v2.h0000664000175000017500000000657112505070716015142 0ustar00phph00000000000000/* ========================================================================= zauth_v2 - authentication for ZeroMQ servers (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZAUTH_V2_H_INCLUDED__ #define __ZAUTH_V2_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface #ifndef CURVE_ALLOW_ANY # define CURVE_ALLOW_ANY "*" #endif // Constructor // Install authentication for the specified context. Returns a new zauth // object that you can use to configure authentication. Note that until you // add policies, all incoming NULL connections are allowed (classic ZeroMQ // behaviour), and all PLAIN and CURVE connections are denied. If there was // an error during initialization, returns NULL. CZMQ_EXPORT zauth_t * zauth_new (zctx_t *ctx); // Destructor CZMQ_EXPORT void zauth_destroy (zauth_t **self_p); // Allow (whitelist) a single IP address. For NULL, all clients from this // address will be accepted. For PLAIN and CURVE, they will be allowed to // continue with authentication. You can call this method multiple times // to whitelist multiple IP addresses. If you whitelist a single address, // any non-whitelisted addresses are treated as blacklisted. CZMQ_EXPORT void zauth_allow (zauth_t *self, const char *address); // Deny (blacklist) a single IP address. For all security mechanisms, this // rejects the connection without any further authentication. Use either a // whitelist, or a blacklist, not not both. If you define both a whitelist // and a blacklist, only the whitelist takes effect. CZMQ_EXPORT void zauth_deny (zauth_t *self, const char *address); // Configure PLAIN authentication for a given domain. PLAIN authentication // uses a plain-text password file. To cover all domains, use "*". You can // modify the password file at any time; it is reloaded automatically. CZMQ_EXPORT void zauth_configure_plain (zauth_t *self, const char *domain, const char *filename); // Configure CURVE authentication for a given domain. CURVE authentication // uses a directory that holds all public client certificates, i.e. their // public keys. The certificates must be in zcert_save () format. To cover // all domains, use "*". You can add and remove certificates in that // directory at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the location. CZMQ_EXPORT void zauth_configure_curve (zauth_t *self, const char *domain, const char *location); // Configure GSSAPI authentication for a given domain. GSSAPI authentication // uses an underlying mechanism (usually Kerberos) to establish a secure // context and perform mutual authentication. To cover all domains, use "*". CZMQ_EXPORT void zauth_configure_gssapi (zauth_t *self, char *domain); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zauth_set_verbose (zauth_t *self, bool verbose); // Selftest CZMQ_EXPORT void zauth_v2_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zsock_option.h0000664000175000017500000003074612533132116016114 0ustar00phph00000000000000/* ========================================================================= zsock_option - get/set 0MQ socket options **************************************************** * GENERATED SOURCE CODE, DO NOT EDIT!! * * TO CHANGE THIS, EDIT scripts/sockopts.gsl * * AND RUN ./generate in models/. * **************************************************** Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSOCK_OPTION_H_INCLUDED__ #define __ZSOCK_OPTION_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsock_tos (void *self); CZMQ_EXPORT char * zsock_zap_domain (void *self); CZMQ_EXPORT int zsock_mechanism (void *self); CZMQ_EXPORT int zsock_plain_server (void *self); CZMQ_EXPORT char * zsock_plain_username (void *self); CZMQ_EXPORT char * zsock_plain_password (void *self); CZMQ_EXPORT int zsock_curve_server (void *self); CZMQ_EXPORT char * zsock_curve_publickey (void *self); CZMQ_EXPORT char * zsock_curve_secretkey (void *self); CZMQ_EXPORT char * zsock_curve_serverkey (void *self); CZMQ_EXPORT int zsock_gssapi_server (void *self); CZMQ_EXPORT int zsock_gssapi_plaintext (void *self); CZMQ_EXPORT char * zsock_gssapi_principal (void *self); CZMQ_EXPORT char * zsock_gssapi_service_principal (void *self); CZMQ_EXPORT int zsock_ipv6 (void *self); CZMQ_EXPORT int zsock_immediate (void *self); CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_tos (void *self, int tos); CZMQ_EXPORT void zsock_set_router_handover (void *self, int router_handover); CZMQ_EXPORT void zsock_set_router_mandatory (void *self, int router_mandatory); CZMQ_EXPORT void zsock_set_probe_router (void *self, int probe_router); CZMQ_EXPORT void zsock_set_req_relaxed (void *self, int req_relaxed); CZMQ_EXPORT void zsock_set_req_correlate (void *self, int req_correlate); CZMQ_EXPORT void zsock_set_conflate (void *self, int conflate); CZMQ_EXPORT void zsock_set_zap_domain (void *self, const char * zap_domain); CZMQ_EXPORT void zsock_set_plain_server (void *self, int plain_server); CZMQ_EXPORT void zsock_set_plain_username (void *self, const char * plain_username); CZMQ_EXPORT void zsock_set_plain_password (void *self, const char * plain_password); CZMQ_EXPORT void zsock_set_curve_server (void *self, int curve_server); CZMQ_EXPORT void zsock_set_curve_publickey (void *self, const char * curve_publickey); CZMQ_EXPORT void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); CZMQ_EXPORT void zsock_set_curve_secretkey (void *self, const char * curve_secretkey); CZMQ_EXPORT void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); CZMQ_EXPORT void zsock_set_curve_serverkey (void *self, const char * curve_serverkey); CZMQ_EXPORT void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); CZMQ_EXPORT void zsock_set_gssapi_server (void *self, int gssapi_server); CZMQ_EXPORT void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); CZMQ_EXPORT void zsock_set_gssapi_principal (void *self, const char * gssapi_principal); CZMQ_EXPORT void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal); CZMQ_EXPORT void zsock_set_ipv6 (void *self, int ipv6); CZMQ_EXPORT void zsock_set_immediate (void *self, int immediate); CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsock_ipv4only (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_sndhwm (void *self); CZMQ_EXPORT int zsock_rcvhwm (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_maxmsgsize (void *self); CZMQ_EXPORT int zsock_multicast_hops (void *self); CZMQ_EXPORT int zsock_rcvtimeo (void *self); CZMQ_EXPORT int zsock_sndtimeo (void *self); CZMQ_EXPORT int zsock_tcp_keepalive (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket options CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsock_hwm (void *self); CZMQ_EXPORT int zsock_swap (void *self); CZMQ_EXPORT int zsock_affinity (void *self); CZMQ_EXPORT char * zsock_identity (void *self); CZMQ_EXPORT int zsock_rate (void *self); CZMQ_EXPORT int zsock_recovery_ivl (void *self); CZMQ_EXPORT int zsock_recovery_ivl_msec (void *self); CZMQ_EXPORT int zsock_mcast_loop (void *self); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_rcvtimeo (void *self); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsock_sndtimeo (void *self); # endif CZMQ_EXPORT int zsock_sndbuf (void *self); CZMQ_EXPORT int zsock_rcvbuf (void *self); CZMQ_EXPORT int zsock_linger (void *self); CZMQ_EXPORT int zsock_reconnect_ivl (void *self); CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); CZMQ_EXPORT int zsock_backlog (void *self); CZMQ_EXPORT int zsock_type (void *self); CZMQ_EXPORT int zsock_rcvmore (void *self); CZMQ_EXPORT SOCKET zsock_fd (void *self); CZMQ_EXPORT int zsock_events (void *self); // Set socket options CZMQ_EXPORT void zsock_set_hwm (void *self, int hwm); CZMQ_EXPORT void zsock_set_swap (void *self, int swap); CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); CZMQ_EXPORT void zsock_set_identity (void *self, const char * identity); CZMQ_EXPORT void zsock_set_rate (void *self, int rate); CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); CZMQ_EXPORT void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); CZMQ_EXPORT void zsock_set_mcast_loop (void *self, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); # endif CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); CZMQ_EXPORT void zsock_set_linger (void *self, int linger); CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); CZMQ_EXPORT void zsock_set_subscribe (void *self, const char * subscribe); CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsock_option_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zstr.h0000664000175000017500000000645712505070716014405 0ustar00phph00000000000000/* ========================================================================= zstr - sending and receiving strings Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSTR_H_INCLUDED__ #define __ZSTR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. CZMQ_EXPORT char * zstr_recv (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". CZMQ_EXPORT int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. CZMQ_EXPORT int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. CZMQ_EXPORT int zstr_sendfm (void *dest, const char *format, ...); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. CZMQ_EXPORT int zstr_sendx (void *dest, const char *string, ...); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. CZMQ_EXPORT int zstr_recvx (void *source, char **string_p, ...); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zstr_free (char **string_p); // Self test of this class CZMQ_EXPORT void zstr_test (bool verbose); // @end // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive C string from socket, if socket had input ready. Caller must // free returned string using zstr_free. Returns NULL if there was no input // waiting, or if the context was terminated. Use zctx_interrupted to exit // any loop that relies on this method. CZMQ_EXPORT char * zstr_recv_nowait (void *source); // Compiler hints CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2); #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/czmq_library.h0000664000175000017500000001312112535241704016063 0ustar00phph00000000000000/* ========================================================================= czmq - CZMQ wrapper Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ ========================================================================= */ #ifndef czmq_library_H_INCLUDED #define czmq_library_H_INCLUDED // Set up environment for the application #include "czmq_prelude.h" // External dependencies #include // CZMQ version macros for compile-time API detection #define CZMQ_VERSION_MAJOR 3 #define CZMQ_VERSION_MINOR 0 #define CZMQ_VERSION_PATCH 2 #define CZMQ_MAKE_VERSION(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) #define CZMQ_VERSION \ CZMQ_MAKE_VERSION(CZMQ_VERSION_MAJOR, CZMQ_VERSION_MINOR, CZMQ_VERSION_PATCH) #if defined (__WINDOWS__) # if defined LIBCZMQ_STATIC # define CZMQ_EXPORT # elif defined LIBCZMQ_EXPORTS # define CZMQ_EXPORT __declspec(dllexport) # else # define CZMQ_EXPORT __declspec(dllimport) # endif #else # define CZMQ_EXPORT #endif // Opaque class structures to allow forward references typedef struct _zactor_t zactor_t; #define ZACTOR_T_DEFINED typedef struct _zauth_t zauth_t; #define ZAUTH_T_DEFINED typedef struct _zarmour_t zarmour_t; #define ZARMOUR_T_DEFINED typedef struct _zbeacon_t zbeacon_t; #define ZBEACON_T_DEFINED typedef struct _zcert_t zcert_t; #define ZCERT_T_DEFINED typedef struct _zcertstore_t zcertstore_t; #define ZCERTSTORE_T_DEFINED typedef struct _zchunk_t zchunk_t; #define ZCHUNK_T_DEFINED typedef struct _zclock_t zclock_t; #define ZCLOCK_T_DEFINED typedef struct _zconfig_t zconfig_t; #define ZCONFIG_T_DEFINED typedef struct _zdigest_t zdigest_t; #define ZDIGEST_T_DEFINED typedef struct _zdir_t zdir_t; #define ZDIR_T_DEFINED typedef struct _zdir_patch_t zdir_patch_t; #define ZDIR_PATCH_T_DEFINED typedef struct _zfile_t zfile_t; #define ZFILE_T_DEFINED typedef struct _zframe_t zframe_t; #define ZFRAME_T_DEFINED typedef struct _zgossip_t zgossip_t; #define ZGOSSIP_T_DEFINED typedef struct _zhashx_t zhashx_t; #define ZHASHX_T_DEFINED typedef struct _ziflist_t ziflist_t; #define ZIFLIST_T_DEFINED typedef struct _zlistx_t zlistx_t; #define ZLISTX_T_DEFINED typedef struct _zloop_t zloop_t; #define ZLOOP_T_DEFINED typedef struct _zmonitor_t zmonitor_t; #define ZMONITOR_T_DEFINED typedef struct _zmsg_t zmsg_t; #define ZMSG_T_DEFINED typedef struct _zpoller_t zpoller_t; #define ZPOLLER_T_DEFINED typedef struct _zproxy_t zproxy_t; #define ZPROXY_T_DEFINED typedef struct _zrex_t zrex_t; #define ZREX_T_DEFINED typedef struct _zsock_t zsock_t; #define ZSOCK_T_DEFINED typedef struct _zsock_option_t zsock_option_t; #define ZSOCK_OPTION_T_DEFINED typedef struct _zstr_t zstr_t; #define ZSTR_T_DEFINED typedef struct _zsys_t zsys_t; #define ZSYS_T_DEFINED typedef struct _zuuid_t zuuid_t; #define ZUUID_T_DEFINED typedef struct _zauth_v2_t zauth_v2_t; #define ZAUTH_V2_T_DEFINED typedef struct _zbeacon_v2_t zbeacon_v2_t; #define ZBEACON_V2_T_DEFINED typedef struct _zctx_t zctx_t; #define ZCTX_T_DEFINED typedef struct _zhash_t zhash_t; #define ZHASH_T_DEFINED typedef struct _zlist_t zlist_t; #define ZLIST_T_DEFINED typedef struct _zmonitor_v2_t zmonitor_v2_t; #define ZMONITOR_V2_T_DEFINED typedef struct _zmutex_t zmutex_t; #define ZMUTEX_T_DEFINED typedef struct _zproxy_v2_t zproxy_v2_t; #define ZPROXY_V2_T_DEFINED typedef struct _zsocket_t zsocket_t; #define ZSOCKET_T_DEFINED typedef struct _zsockopt_t zsockopt_t; #define ZSOCKOPT_T_DEFINED typedef struct _zthread_t zthread_t; #define ZTHREAD_T_DEFINED // Public API classes #include "zactor.h" #include "zauth.h" #include "zarmour.h" #include "zbeacon.h" #include "zcert.h" #include "zcertstore.h" #include "zchunk.h" #include "zclock.h" #include "zconfig.h" #include "zdigest.h" #include "zdir.h" #include "zdir_patch.h" #include "zfile.h" #include "zframe.h" #include "zgossip.h" #include "zhashx.h" #include "ziflist.h" #include "zlistx.h" #include "zloop.h" #include "zmonitor.h" #include "zmsg.h" #include "zpoller.h" #include "zproxy.h" #include "zrex.h" #include "zsock.h" #include "zsock_option.h" #include "zstr.h" #include "zsys.h" #include "zuuid.h" #include "zauth_v2.h" #include "zbeacon_v2.h" #include "zctx.h" #include "zhash.h" #include "zlist.h" #include "zmonitor_v2.h" #include "zmutex.h" #include "zproxy_v2.h" #include "zsocket.h" #include "zsockopt.h" #include "zthread.h" #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Please refer to the README for information about making permanent changes. # ################################################################################ */ czmq-3.0.2/include/zchunk.h0000775000175000017500000001157312525412362014702 0ustar00phph00000000000000/* ========================================================================= zchunk - work with memory chunks Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCHUNK_H_INCLUDED__ #define __ZCHUNK_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. CZMQ_EXPORT zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk CZMQ_EXPORT void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero CZMQ_EXPORT void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size CZMQ_EXPORT size_t zchunk_size (zchunk_t *self); // Return chunk max size CZMQ_EXPORT size_t zchunk_max_size (zchunk_t *self); // Return chunk data CZMQ_EXPORT byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk CZMQ_EXPORT size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet CZMQ_EXPORT size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeed the available space, it is truncated. If you want to // grow the chunk to accomodate new data, use the zchunk_extend method. CZMQ_EXPORT size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeed the available space, the chunk grows in size. CZMQ_EXPORT size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. CZMQ_EXPORT size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. CZMQ_EXPORT bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor CZMQ_EXPORT zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor CZMQ_EXPORT int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. CZMQ_EXPORT zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. CZMQ_EXPORT zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. CZMQ_EXPORT char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. CZMQ_EXPORT char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator CZMQ_EXPORT bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. CZMQ_EXPORT zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. CZMQ_EXPORT zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. CZMQ_EXPORT const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. CZMQ_EXPORT void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details CZMQ_EXPORT void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. CZMQ_EXPORT bool zchunk_is (void *self); // Self test of this class CZMQ_EXPORT void zchunk_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zmonitor.h0000664000175000017500000000354112505070716015253 0ustar00phph00000000000000/* ========================================================================= zmonitor - socket event monitor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZMONITOR_H_INCLUDED__ #define __ZMONITOR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new zmonitor actor instance to monitor a zsock_t socket: // // zactor_t *monitor = zactor_new (zmonitor, mysocket); // // Destroy zmonitor instance. // // zactor_destroy (&monitor); // // Enable verbose logging of commands and activity. // // zstr_send (monitor, "VERBOSE"); // // Listen to monitor event type (zero or types, ending in NULL): // zstr_sendx (monitor, "LISTEN", type, ..., NULL); // // Events: // CONNECTED // CONNECT_DELAYED // CONNECT_RETRIED // LISTENING // BIND_FAILED // ACCEPTED // ACCEPT_FAILED // CLOSED // CLOSE_FAILED // DISCONNECTED // MONITOR_STOPPED // ALL // // Start monitor; after this, any further LISTEN commands are ignored. // // zstr_send (monitor, "START"); // zsock_wait (monitor); // // Receive next monitor event: // // zmsg_t *msg = zmsg_recv (monitor); // // This is the zmonitor constructor as a zactor_fn; the argument can be // a zactor_t, zsock_t, or libzmq void * socket: CZMQ_EXPORT void zmonitor (zsock_t *pipe, void *sock); // Selftest CZMQ_EXPORT void zmonitor_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zpoller.h0000775000175000017500000000553512505070716015071 0ustar00phph00000000000000/* ========================================================================= zpoller - trivial socket poller class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __zpoller_H_INCLUDED__ #define __zpoller_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new poller; the reader can be a libzmq socket (void *), a zsock_t // instance, or a zactor_t instance. CZMQ_EXPORT zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller CZMQ_EXPORT void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. CZMQ_EXPORT int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The // reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t // instance. CZMQ_EXPORT int zpoller_remove (zpoller_t *self, void *reader); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. CZMQ_EXPORT void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. CZMQ_EXPORT bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. CZMQ_EXPORT bool zpoller_terminated (zpoller_t *self); // Ignore zsys_interrupted flag in this poller. By default, a zpoller_wait will // return immediately if detects zsys_interrupted is set to something other than // zero. Calling zpoller_ignore_interrupts will supress this behavior. CZMQ_EXPORT void zpoller_ignore_interrupts(zpoller_t *self); // Self test of this class CZMQ_EXPORT void zpoller_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zmonitor_v2.h0000664000175000017500000000305612505070716015663 0ustar00phph00000000000000/* ========================================================================= zmonitor_v2 - socket event monitor (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZMONITOR_V2_H_INCLUDED__ #define __ZMONITOR_V2_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // This code needs backporting to work with ZMQ v3.2 #if (ZMQ_VERSION_MAJOR == 4) // Create a new socket monitor CZMQ_EXPORT zmonitor_t * zmonitor_new (zctx_t *ctx, void *socket, int events); // Destroy a socket monitor CZMQ_EXPORT void zmonitor_destroy (zmonitor_t **self_p); // Receive a status message from the monitor; if no message arrives within // 500 msec, or the call was interrupted, returns NULL. CZMQ_EXPORT zmsg_t * zmonitor_recv (zmonitor_t *self); // Get the ZeroMQ socket, for polling CZMQ_EXPORT void * zmonitor_socket (zmonitor_t *self); // Enable verbose tracing of commands and activity CZMQ_EXPORT void zmonitor_set_verbose (zmonitor_t *self, bool verbose); #endif // ZeroMQ 4.0 or later // Self test of this class CZMQ_EXPORT void zmonitor_v2_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zdigest.h0000775000175000017500000000334212505070716015045 0ustar00phph00000000000000/* ========================================================================= zdigest - provides hashing functions (SHA-1 at present) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZDIGEST_H_INCLUDED__ #define __ZDIGEST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. CZMQ_EXPORT zdigest_t * zdigest_new (void); // Destroy a digest object CZMQ_EXPORT void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation CZMQ_EXPORT void zdigest_update (zdigest_t *self, byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, returns // NULL. CZMQ_EXPORT byte * zdigest_data (zdigest_t *self); // Return final digest hash size CZMQ_EXPORT size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. CZMQ_EXPORT char * zdigest_string (zdigest_t *self); // Self test of this class CZMQ_EXPORT void zdigest_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zrex.h0000664000175000017500000000552712505070716014370 0ustar00phph00000000000000/* ========================================================================= zrex - work with regular expressions Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZREX_H_INCLUDED__ #define __ZREX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. CZMQ_EXPORT zrex_t * zrex_new (const char *expression); // Destructor CZMQ_EXPORT void zrex_destroy (zrex_t **self_p); // Return true if the expression was valid and compiled without errors. CZMQ_EXPORT bool zrex_valid (zrex_t *self); // Return the error message generated during compilation of the expression. CZMQ_EXPORT const char * zrex_strerror (zrex_t *self); // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. CZMQ_EXPORT bool zrex_matches (zrex_t *self, const char *text); // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. CZMQ_EXPORT bool zrex_eq (zrex_t *self, const char *text, const char *expression); // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). CZMQ_EXPORT int zrex_hits (zrex_t *self); // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. CZMQ_EXPORT const char * zrex_hit (zrex_t *self, uint index); // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. CZMQ_EXPORT int zrex_fetch (zrex_t *self, const char **string_p, ...); // Self test of this class CZMQ_EXPORT void zrex_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zctx.h0000664000175000017500000000670012505070716014362 0ustar00phph00000000000000/* ========================================================================= zctx - working with 0MQ contexts Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCTX_H_INCLUDED__ #define __ZCTX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new context, returns context object, replaces zmq_init CZMQ_EXPORT zctx_t * zctx_new (void); // Destroy context and all sockets in it, replaces zmq_term CZMQ_EXPORT void zctx_destroy (zctx_t **self_p); // Create new shadow context, returns context object CZMQ_EXPORT zctx_t * zctx_shadow (zctx_t *self); // @end // Create a new context by shadowing a plain zmq context CZMQ_EXPORT zctx_t * zctx_shadow_zmq_ctx (void *zmqctx); // @interface // Raise default I/O threads from 1, for crazy heavy applications // The rule of thumb is one I/O thread per gigabyte of traffic in // or out. Call this method before creating any sockets on the context, // or calling zctx_shadow, or the setting will have no effect. CZMQ_EXPORT void zctx_set_iothreads (zctx_t *self, int iothreads); // Set msecs to flush sockets when closing them, see the ZMQ_LINGER // man page section for more details. By default, set to zero, so // any in-transit messages are discarded when you destroy a socket or // a context. CZMQ_EXPORT void zctx_set_linger (zctx_t *self, int linger); // Set initial high-water mark for inter-thread pipe sockets. Note that // this setting is separate from the default for normal sockets. You // should change the default for pipe sockets *with care*. Too low values // will cause blocked threads, and an infinite setting can cause memory // exhaustion. The default, no matter the underlying ZeroMQ version, is // 1,000. CZMQ_EXPORT void zctx_set_pipehwm (zctx_t *self, int pipehwm); // Set initial send HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. CZMQ_EXPORT void zctx_set_sndhwm (zctx_t *self, int sndhwm); // Set initial receive HWM for all new normal sockets created in context. // You can set this per-socket after the socket is created. // The default, no matter the underlying ZeroMQ version, is 1,000. CZMQ_EXPORT void zctx_set_rcvhwm (zctx_t *self, int rcvhwm); // Return low-level 0MQ context object, will be NULL before first socket // is created. Use with care. CZMQ_EXPORT void * zctx_underlying (zctx_t *self); // Self test of this class CZMQ_EXPORT void zctx_test (bool verbose); // @end // Create socket within this context, for CZMQ use only void * zctx__socket_new (zctx_t *self, int type); // Create pipe socket within this context, for CZMQ use only void * zctx__socket_pipe (zctx_t *self); // Destroy socket within this context, for CZMQ use only void zctx__socket_destroy (zctx_t *self, void *socket); // Initialize the low-level 0MQ context object, for CZMQ use only void zctx__initialize_underlying(zctx_t *self); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zmsg.h0000664000175000017500000002546512535241704014363 0ustar00phph00000000000000/* ========================================================================= zmsg - working with multipart messages Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZMSG_H_INCLUDED__ #define __ZMSG_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zmsg.xml" to make changes. // @interface // Create a new empty message object CZMQ_EXPORT zmsg_t * zmsg_new (); // Destroy a message object and all frames it contains CZMQ_EXPORT void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_recv (void *source); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_sendm (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). CZMQ_EXPORT size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. CZMQ_EXPORT size_t zmsg_content_size (zmsg_t *self); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. CZMQ_EXPORT int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. CZMQ_EXPORT int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushmem (zmsg_t *self, const void *src, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addmem (zmsg_t *self, const void *src, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. CZMQ_EXPORT int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not succesfull. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. CZMQ_EXPORT void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. CZMQ_EXPORT zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. CZMQ_EXPORT zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. CZMQ_EXPORT zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. CZMQ_EXPORT int zmsg_save (zmsg_t *self, FILE *file); // Load/append an open file into message, create new message if // null message provided. Returns NULL if the message could not // be loaded. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_load (zmsg_t *self, FILE *file); // Serialize multipart message to a single buffer. Use this method to send // structured messages across transports that do not support multipart data. // Allocates and returns a new buffer containing the serialized message. // To decode a serialized message buffer, use zmsg_decode (). CZMQ_EXPORT size_t zmsg_encode (zmsg_t *self, byte **buffer); // Decodes a serialized message buffer created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the buffer was badly formatted or // there was insufficient memory to work. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_decode (const byte *buffer, size_t buffer_size); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). CZMQ_EXPORT void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. CZMQ_EXPORT bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zmsg_new_signal (byte status); // Return signal value, 0 or greater, if message is a signal, -1 if not. CZMQ_EXPORT int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. CZMQ_EXPORT bool zmsg_is (void *self); // Self test of this class CZMQ_EXPORT void zmsg_test (bool verbose); // @end // DEPRECATED as over-engineered, poor style // Pop frame off front of message, caller now owns frame // If next frame is empty, pops and destroys that empty frame. CZMQ_EXPORT zframe_t * zmsg_unwrap (zmsg_t *self); // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive message from socket, returns zmsg_t object, or NULL either if // there was no input waiting, or the recv was interrupted. CZMQ_EXPORT zmsg_t * zmsg_recv_nowait (void *source); // DEPRECATED as unsafe -- does not nullify frame reference. // Push frame plus empty frame to front of message, before first frame. // Message takes ownership of frame, will destroy it when message is sent. CZMQ_EXPORT void zmsg_wrap (zmsg_t *self, zframe_t *frame); // DEPRECATED - will be removed for next + 1 stable release // Add frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_push (zmsg_t *self, zframe_t *frame); // DEPRECATED - will be removed for next stable release CZMQ_EXPORT int zmsg_add (zmsg_t *self, zframe_t *frame); // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Print message to open stream // Truncates to first 10 frames, for readability. CZMQ_EXPORT void zmsg_fprint (zmsg_t *self, FILE *file); // Compiler hints CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); #ifdef __cplusplus } #endif // Deprecated method aliases #define zmsg_dump(s) zmsg_print(s) #define zmsg_dump_to_stream(s,F) zmsg_fprint(s,F) #endif czmq-3.0.2/include/zsocket.h0000664000175000017500000000754312505070716015062 0ustar00phph00000000000000/* ========================================================================= zsocket - working with 0MQ sockets Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSOCKET_H_INCLUDED__ #define __ZSOCKET_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding. #define ZSOCKET_DYNFROM 0xc000 #define ZSOCKET_DYNTO 0xffff // Callback function for zero-copy methods typedef void (zsocket_free_fn) (void *data, void *arg); // Create a new socket within our CZMQ context, replaces zmq_socket. // Use this to get automatic management of the socket at shutdown. // Note: SUB sockets do not automatically subscribe to everything; you // must set filters explicitly. CZMQ_EXPORT void * zsocket_new (zctx_t *self, int type); // Destroy a socket within our CZMQ context, replaces zmq_close. CZMQ_EXPORT void zsocket_destroy (zctx_t *ctx, void *self); // Bind a socket to a formatted endpoint. If the port is specified as // '*', binds to any free port from ZSOCKET_DYNFROM to ZSOCKET_DYNTO // and returns the actual port number used. Otherwise asserts that the // bind succeeded with the specified port number. Always returns the // port number if successful. CZMQ_EXPORT int zsocket_bind (void *self, const char *format, ...); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsocket_unbind (void *self, const char *format, ...); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsocket_connect (void *self, const char *format, ...); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsocket_disconnect (void *self, const char *format, ...); // Poll for input events on the socket. Returns TRUE if there is input // ready on the socket, else FALSE. CZMQ_EXPORT bool zsocket_poll (void *self, int msecs); // Returns socket type as printable constant string CZMQ_EXPORT const char * zsocket_type_str (void *self); // Send data over a socket as a single message frame. // Accepts these flags: ZFRAME_MORE and ZFRAME_DONTWAIT. // Returns -1 on error, 0 on success CZMQ_EXPORT int zsocket_sendmem (void *self, const void *data, size_t size, int flags); // Send a signal over a socket. A signal is a zero-byte message. // Signals are used primarily between threads, over pipe sockets. // Returns -1 if there was an error sending the signal. CZMQ_EXPORT int zsocket_signal (void *self); // Wait on a signal. Use this to coordinate between threads, over // pipe pairs. Returns -1 on error, 0 on success. CZMQ_EXPORT int zsocket_wait (void *self); // Self test of this class CZMQ_EXPORT void zsocket_test (bool verbose); // @end // Compiler hints CZMQ_EXPORT int zsocket_bind (void *self, const char *format, ...) CHECK_PRINTF (2); CZMQ_EXPORT int zsocket_unbind (void *self, const char *format, ...) CHECK_PRINTF (2); CZMQ_EXPORT int zsocket_connect (void *self, const char *format, ...) CHECK_PRINTF (2); CZMQ_EXPORT int zsocket_disconnect (void *self, const char *format, ...) CHECK_PRINTF (2); // Emulation of widely-used 2.x socket options CZMQ_EXPORT void zsocket_set_hwm (void *self, int hwm); #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zhash.h0000664000175000017500000002120712535241704014506 0ustar00phph00000000000000/* ========================================================================= zhash - generic type-free hash container (simple) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZHASH_H_INCLUDED__ #define __ZHASH_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zhash.xml" to make changes. // @interface // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // DEPRECATED as clumsy -- use zhash_first/_next instead typedef int (zhash_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhash_t * zhash_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhash_destroy (zhash_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. CZMQ_EXPORT void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null CZMQ_EXPORT void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhash_comment (zhash_t *self, const char *format, ...) CHECK_PRINTF (2); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zhash_pack (zhash_t *self); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhash_t * zhash_unpack (zframe_t *frame); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction CZMQ_EXPORT void zhash_autofree (zhash_t *self); // DEPRECATED as clumsy -- use zhash_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). // Callback function for zhash_foreach method CZMQ_EXPORT int zhash_foreach (zhash_t *self, zhash_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhash_test (int verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zgossip.h0000664000175000017500000000562412533132116015066 0ustar00phph00000000000000/* ========================================================================= zgossip - zgossip server ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip.xml, or * The code generation script that built this file: zproto_server_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZGOSSIP_H_INCLUDED #define ZGOSSIP_H_INCLUDED #include "czmq.h" #ifdef __cplusplus extern "C" { #endif // @interface // To work with zgossip, use the CZMQ zactor API: // // Create new zgossip instance, passing logging prefix: // // zactor_t *zgossip = zactor_new (zgossip, "myname"); // // Destroy zgossip instance // // zactor_destroy (&zgossip); // // Enable verbose logging of commands and activity: // // zstr_send (zgossip, "VERBOSE"); // // Bind zgossip to specified endpoint. TCP endpoints may specify // the port number as "*" to aquire an ephemeral port: // // zstr_sendx (zgossip, "BIND", endpoint, NULL); // // Return assigned port number, specifically when BIND was done using an // an ephemeral port: // // zstr_sendx (zgossip, "PORT", NULL); // char *command, *port_str; // zstr_recvx (zgossip, &command, &port_str, NULL); // assert (streq (command, "PORT")); // // Specify configuration file to load, overwriting any previous loaded // configuration file or options: // // zstr_sendx (zgossip, "LOAD", filename, NULL); // // Set configuration path value: // // zstr_sendx (zgossip, "SET", path, value, NULL); // // Save configuration data to config file on disk: // // zstr_sendx (zgossip, "SAVE", filename, NULL); // // Send zmsg_t instance to zgossip: // // zactor_send (zgossip, &msg); // // Receive zmsg_t instance from zgossip: // // zmsg_t *msg = zactor_recv (zgossip); // // This is the zgossip constructor as a zactor_fn: // CZMQ_EXPORT void zgossip (zsock_t *pipe, void *args); // Self test of this class CZMQ_EXPORT void zgossip_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zproxy.h0000664000175000017500000000567312505070716014755 0ustar00phph00000000000000/* ========================================================================= zproxy - run a steerable proxy in the background Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZPROXY_H_INCLUDED__ #define __ZPROXY_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new zproxy actor instance. The proxy switches messages between // a frontend socket and a backend socket; use the FRONTEND and BACKEND // commands to configure these: // // zactor_t *proxy = zactor_new (zproxy, NULL); // // Destroy zproxy instance. This destroys the two sockets and stops any // message flow between them: // // zactor_destroy (&proxy); // // Note that all zproxy commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity: // // zstr_send (proxy, "VERBOSE"); // zsock_wait (proxy); // // Specify frontend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); // zsock_wait (proxy); // // Specify backend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); // zsock_wait (proxy); // // Capture all proxied messages; these are delivered to the application // via an inproc PULL socket that you have already bound to the specified // endpoint: // // zstr_sendx (proxy, "CAPTURE", endpoint, NULL); // zsock_wait (proxy); // // Pause the proxy. A paused proxy will cease processing messages, causing // them to be queued up and potentially hit the high-water mark on the // frontend or backend socket, causing messages to be dropped, or writing // applications to block: // // zstr_sendx (proxy, "PAUSE", NULL); // zsock_wait (proxy); // // Resume the proxy. Note that the proxy starts automatically as soon as it // has a properly attached frontend and backend socket: // // zstr_sendx (proxy, "RESUME", NULL); // zsock_wait (proxy); // // This is the zproxy constructor as a zactor_fn; the argument is a // character string specifying frontend and backend socket types as two // uppercase strings separated by a hyphen: CZMQ_EXPORT void zproxy (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zproxy_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zdir_patch.h0000775000175000017500000000442212535241704015523 0ustar00phph00000000000000/* ========================================================================= zdir_patch - work with directory patches Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZDIR_PATCH_H_INCLUDED__ #define __ZDIR_PATCH_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // un-namespaced enumeration values #define patch_create ZDIR_PATCH_CREATE #define patch_delete ZDIR_PATCH_DELETE // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zdir_patch.xml" to make changes. // @interface typedef enum { ZDIR_PATCH_CREATE = 1, ZDIR_PATCH_DELETE = 2 } zdir_patch_op_t; // Create new patch CZMQ_EXPORT zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, zdir_patch_op_t op, const char *alias); // Destroy a patch CZMQ_EXPORT void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path CZMQ_EXPORT const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item CZMQ_EXPORT zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation CZMQ_EXPORT zdir_patch_op_t zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path CZMQ_EXPORT const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) CZMQ_EXPORT void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file CZMQ_EXPORT const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. CZMQ_EXPORT void zdir_patch_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zsock.h0000664000175000017500000004637712535241704014541 0ustar00phph00000000000000/* ========================================================================= zsock - high-level socket API that hides libzmq contexts and sockets Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSOCK_H_INCLUDED__ #define __ZSOCK_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // This interface includes some smart constructors, which create sockets with // additional set-up. In all of these, the endpoint is NULL, or starts with // '@' (bind) or '>' (connect). Multiple endpoints are allowed, separated by // commas. If endpoint does not start with '@' or '>', default action depends // on socket type. // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zsock.xml" to make changes. // @interface // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. CZMQ_EXPORT zsock_t * zsock_new (int type); // Destroy the socket. You must use this for any socket created via the // zsock_new method. CZMQ_EXPORT void zsock_destroy (zsock_t **self_p); // Create a PUB socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zsock_t * zsock_new_stream (const char *endpoint); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. CZMQ_EXPORT int zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Returns last bound endpoint, if any. CZMQ_EXPORT const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). CZMQ_EXPORT int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. CZMQ_EXPORT const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. CZMQ_EXPORT int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. CZMQ_EXPORT int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. CZMQ_EXPORT int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. CZMQ_EXPORT int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. CZMQ_EXPORT int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. Do not modify or destroy the returned // values. Returns 0 if successful, or -1 if it failed to read a message. CZMQ_EXPORT int zsock_brecv (void *self, const char *picture, ...); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. CZMQ_EXPORT void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. CZMQ_EXPORT void zsock_flush (void *self); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. CZMQ_EXPORT bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. CZMQ_EXPORT void * zsock_resolve (void *self); // Self test of this class CZMQ_EXPORT void zsock_test (bool verbose); // @end // zsock leak detection - not a part of the official interface to zsock. This // enables CZMQ to report socket leaks intelligently. #if defined ZSOCK_NOCHECK // no checking active - use the above interface methods directly. #else # define zsock_new(t) zsock_new_checked((t), __FILE__, __LINE__) # define zsock_new_pub(e) zsock_new_pub_checked((e), __FILE__, __LINE__) # define zsock_new_sub(e,s) zsock_new_sub_checked((e), (s), __FILE__, __LINE__) # define zsock_new_req(e) zsock_new_req_checked((e), __FILE__, __LINE__) # define zsock_new_rep(e) zsock_new_rep_checked((e), __FILE__, __LINE__) # define zsock_new_dealer(e) zsock_new_dealer_checked((e), __FILE__, __LINE__) # define zsock_new_router(e) zsock_new_router_checked((e), __FILE__, __LINE__) # define zsock_new_pull(e) zsock_new_pull_checked((e), __FILE__, __LINE__) # define zsock_new_push(e) zsock_new_push_checked((e), __FILE__, __LINE__) # define zsock_new_xpub(e) zsock_new_xpub_checked((e), __FILE__, __LINE__) # define zsock_new_xsub(e) zsock_new_xsub_checked((e), __FILE__, __LINE__) # define zsock_new_pair(e) zsock_new_pair_checked((e), __FILE__, __LINE__) # define zsock_new_stream(e) zsock_new_stream_checked((e), __FILE__, __LINE__) # define zsock_destroy(t) zsock_destroy_checked((t), __FILE__, __LINE__) #endif CZMQ_EXPORT zsock_t * zsock_new_checked (int type, const char *filename, size_t line_nbr); CZMQ_EXPORT void zsock_destroy_checked (zsock_t **self_p, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_pub_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_sub_checked (const char *endpoint, const char *subscribe, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_req_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_rep_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_dealer_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_router_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_push_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_pull_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_xpub_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_xsub_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_pair_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_stream_checked (const char *endpoint, const char *filename, size_t line_nbr); #ifdef __cplusplus } #endif // include generated code #include "zsock_option.h" #endif czmq-3.0.2/include/zsockopt.h0000664000175000017500000003231312533132116015237 0ustar00phph00000000000000/* ========================================================================= zsockopt - get/set 0MQ socket options (deprecated) **************************************************** * GENERATED SOURCE CODE, DO NOT EDIT!! * * TO CHANGE THIS, EDIT scripts/sockopts.gsl * * AND RUN ./generate in models/. * **************************************************** Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSOCKOPT_H_INCLUDED__ #define __ZSOCKOPT_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface #if (ZMQ_VERSION_MAJOR == 4) // Get socket options CZMQ_EXPORT int zsocket_tos (void *zocket); CZMQ_EXPORT char * zsocket_zap_domain (void *zocket); CZMQ_EXPORT int zsocket_mechanism (void *zocket); CZMQ_EXPORT int zsocket_plain_server (void *zocket); CZMQ_EXPORT char * zsocket_plain_username (void *zocket); CZMQ_EXPORT char * zsocket_plain_password (void *zocket); CZMQ_EXPORT int zsocket_curve_server (void *zocket); CZMQ_EXPORT char * zsocket_curve_publickey (void *zocket); CZMQ_EXPORT char * zsocket_curve_secretkey (void *zocket); CZMQ_EXPORT char * zsocket_curve_serverkey (void *zocket); CZMQ_EXPORT int zsocket_gssapi_server (void *zocket); CZMQ_EXPORT int zsocket_gssapi_plaintext (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_principal (void *zocket); CZMQ_EXPORT char * zsocket_gssapi_service_principal (void *zocket); CZMQ_EXPORT int zsocket_ipv6 (void *zocket); CZMQ_EXPORT int zsocket_immediate (void *zocket); CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_tos (void *zocket, int tos); CZMQ_EXPORT void zsocket_set_router_handover (void *zocket, int router_handover); CZMQ_EXPORT void zsocket_set_router_mandatory (void *zocket, int router_mandatory); CZMQ_EXPORT void zsocket_set_probe_router (void *zocket, int probe_router); CZMQ_EXPORT void zsocket_set_req_relaxed (void *zocket, int req_relaxed); CZMQ_EXPORT void zsocket_set_req_correlate (void *zocket, int req_correlate); CZMQ_EXPORT void zsocket_set_conflate (void *zocket, int conflate); CZMQ_EXPORT void zsocket_set_zap_domain (void *zocket, const char * zap_domain); CZMQ_EXPORT void zsocket_set_plain_server (void *zocket, int plain_server); CZMQ_EXPORT void zsocket_set_plain_username (void *zocket, const char * plain_username); CZMQ_EXPORT void zsocket_set_plain_password (void *zocket, const char * plain_password); CZMQ_EXPORT void zsocket_set_curve_server (void *zocket, int curve_server); CZMQ_EXPORT void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey); CZMQ_EXPORT void zsocket_set_curve_publickey_bin (void *zocket, const byte *curve_publickey); CZMQ_EXPORT void zsocket_set_curve_secretkey (void *zocket, const char * curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_secretkey_bin (void *zocket, const byte *curve_secretkey); CZMQ_EXPORT void zsocket_set_curve_serverkey (void *zocket, const char * curve_serverkey); CZMQ_EXPORT void zsocket_set_curve_serverkey_bin (void *zocket, const byte *curve_serverkey); CZMQ_EXPORT void zsocket_set_gssapi_server (void *zocket, int gssapi_server); CZMQ_EXPORT void zsocket_set_gssapi_plaintext (void *zocket, int gssapi_plaintext); CZMQ_EXPORT void zsocket_set_gssapi_principal (void *zocket, const char * gssapi_principal); CZMQ_EXPORT void zsocket_set_gssapi_service_principal (void *zocket, const char * gssapi_service_principal); CZMQ_EXPORT void zsocket_set_ipv6 (void *zocket, int ipv6); CZMQ_EXPORT void zsocket_set_immediate (void *zocket, int immediate); CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 3) // Get socket options CZMQ_EXPORT int zsocket_ipv4only (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_sndhwm (void *zocket); CZMQ_EXPORT int zsocket_rcvhwm (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_maxmsgsize (void *zocket); CZMQ_EXPORT int zsocket_multicast_hops (void *zocket); CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_idle (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_cnt (void *zocket); CZMQ_EXPORT int zsocket_tcp_keepalive_intvl (void *zocket); CZMQ_EXPORT char * zsocket_tcp_accept_filter (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); CZMQ_EXPORT char * zsocket_last_endpoint (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_router_raw (void *zocket, int router_raw); CZMQ_EXPORT void zsocket_set_ipv4only (void *zocket, int ipv4only); CZMQ_EXPORT void zsocket_set_delay_attach_on_connect (void *zocket, int delay_attach_on_connect); CZMQ_EXPORT void zsocket_set_sndhwm (void *zocket, int sndhwm); CZMQ_EXPORT void zsocket_set_rcvhwm (void *zocket, int rcvhwm); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_maxmsgsize (void *zocket, int maxmsgsize); CZMQ_EXPORT void zsocket_set_multicast_hops (void *zocket, int multicast_hops); CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); CZMQ_EXPORT void zsocket_set_xpub_verbose (void *zocket, int xpub_verbose); CZMQ_EXPORT void zsocket_set_tcp_keepalive (void *zocket, int tcp_keepalive); CZMQ_EXPORT void zsocket_set_tcp_keepalive_idle (void *zocket, int tcp_keepalive_idle); CZMQ_EXPORT void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); CZMQ_EXPORT void zsocket_set_tcp_keepalive_intvl (void *zocket, int tcp_keepalive_intvl); CZMQ_EXPORT void zsocket_set_tcp_accept_filter (void *zocket, const char * tcp_accept_filter); #endif #if (ZMQ_VERSION_MAJOR == 2) // Get socket options CZMQ_EXPORT int zsocket_hwm (void *zocket); CZMQ_EXPORT int zsocket_swap (void *zocket); CZMQ_EXPORT int zsocket_affinity (void *zocket); CZMQ_EXPORT char * zsocket_identity (void *zocket); CZMQ_EXPORT int zsocket_rate (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl (void *zocket); CZMQ_EXPORT int zsocket_recovery_ivl_msec (void *zocket); CZMQ_EXPORT int zsocket_mcast_loop (void *zocket); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_rcvtimeo (void *zocket); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT int zsocket_sndtimeo (void *zocket); # endif CZMQ_EXPORT int zsocket_sndbuf (void *zocket); CZMQ_EXPORT int zsocket_rcvbuf (void *zocket); CZMQ_EXPORT int zsocket_linger (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl (void *zocket); CZMQ_EXPORT int zsocket_reconnect_ivl_max (void *zocket); CZMQ_EXPORT int zsocket_backlog (void *zocket); CZMQ_EXPORT int zsocket_type (void *zocket); CZMQ_EXPORT int zsocket_rcvmore (void *zocket); CZMQ_EXPORT SOCKET zsocket_fd (void *zocket); CZMQ_EXPORT int zsocket_events (void *zocket); // Set socket options CZMQ_EXPORT void zsocket_set_hwm (void *zocket, int hwm); CZMQ_EXPORT void zsocket_set_swap (void *zocket, int swap); CZMQ_EXPORT void zsocket_set_affinity (void *zocket, int affinity); CZMQ_EXPORT void zsocket_set_identity (void *zocket, const char * identity); CZMQ_EXPORT void zsocket_set_rate (void *zocket, int rate); CZMQ_EXPORT void zsocket_set_recovery_ivl (void *zocket, int recovery_ivl); CZMQ_EXPORT void zsocket_set_recovery_ivl_msec (void *zocket, int recovery_ivl_msec); CZMQ_EXPORT void zsocket_set_mcast_loop (void *zocket, int mcast_loop); # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_rcvtimeo (void *zocket, int rcvtimeo); # endif # if (ZMQ_VERSION_MINOR == 2) CZMQ_EXPORT void zsocket_set_sndtimeo (void *zocket, int sndtimeo); # endif CZMQ_EXPORT void zsocket_set_sndbuf (void *zocket, int sndbuf); CZMQ_EXPORT void zsocket_set_rcvbuf (void *zocket, int rcvbuf); CZMQ_EXPORT void zsocket_set_linger (void *zocket, int linger); CZMQ_EXPORT void zsocket_set_reconnect_ivl (void *zocket, int reconnect_ivl); CZMQ_EXPORT void zsocket_set_reconnect_ivl_max (void *zocket, int reconnect_ivl_max); CZMQ_EXPORT void zsocket_set_backlog (void *zocket, int backlog); CZMQ_EXPORT void zsocket_set_subscribe (void *zocket, const char * subscribe); CZMQ_EXPORT void zsocket_set_unsubscribe (void *zocket, const char * unsubscribe); #endif // Self test of this class CZMQ_EXPORT void zsockopt_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zmutex.h0000664000175000017500000000223512505070716014725 0ustar00phph00000000000000/* ========================================================================= zmutex - working with mutexes Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZMUTEX_H_INCLUDED__ #define __ZMUTEX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create a new mutex container CZMQ_EXPORT zmutex_t * zmutex_new (void); // Destroy a mutex container CZMQ_EXPORT void zmutex_destroy (zmutex_t **self_p); // Lock mutex CZMQ_EXPORT void zmutex_lock (zmutex_t *self); // Unlock mutex CZMQ_EXPORT void zmutex_unlock (zmutex_t *self); // Try to lock mutex CZMQ_EXPORT int zmutex_try_lock (zmutex_t *self); // Self test of this class CZMQ_EXPORT void zmutex_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zthread.h0000664000175000017500000000313012505070716015025 0ustar00phph00000000000000/* ========================================================================= zthread - working with system threads (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZTHREAD_H_INCLUDED__ #define __ZTHREAD_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Detached threads follow POSIX pthreads API typedef void *(zthread_detached_fn) (void *args); // Attached threads get context and pipe from parent typedef void (zthread_attached_fn) (void *args, zctx_t *ctx, void *pipe); // Create a detached thread. A detached thread operates autonomously // and is used to simulate a separate process. It gets no ctx, and no // pipe. CZMQ_EXPORT int zthread_new (zthread_detached_fn *thread_fn, void *args); // Create an attached thread. An attached thread gets a ctx and a PAIR // pipe back to its parent. It must monitor its pipe, and exit if the // pipe becomes unreadable. Do not destroy the ctx, the thread does this // automatically when it ends. CZMQ_EXPORT void * zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args); // Self test of this class CZMQ_EXPORT void zthread_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zuuid.h0000664000175000017500000000456212523062466014541 0ustar00phph00000000000000/* ========================================================================= zuuid - UUID support class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZUUID_H_INCLUDED__ #define __ZUUID_H_INCLUDED__ #define ZUUID_LEN 16 #define ZUUID_STR_LEN (ZUUID_LEN * 2) #ifdef __cplusplus extern "C" { #endif // @interface // Constructor CZMQ_EXPORT zuuid_t * zuuid_new (void); // Destructor CZMQ_EXPORT void zuuid_destroy (zuuid_t **self_p); // Create UUID object from supplied ZUUID_LEN-octet value CZMQ_EXPORT zuuid_t * zuuid_new_from (const byte *source); // Set UUID to new supplied ZUUID_LEN-octet value CZMQ_EXPORT void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. CZMQ_EXPORT int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data CZMQ_EXPORT const byte * zuuid_data (zuuid_t *self); // Return UUID binary size CZMQ_EXPORT size_t zuuid_size (zuuid_t *self); // Returns UUID as string CZMQ_EXPORT const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier CZMQ_EXPORT const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array CZMQ_EXPORT void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value CZMQ_EXPORT bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value CZMQ_EXPORT bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. CZMQ_EXPORT zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class CZMQ_EXPORT void zuuid_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zframe.h0000664000175000017500000001220212535241704014650 0ustar00phph00000000000000/* ========================================================================= zframe - working with single message frames Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZFRAME_H_INCLUDED__ #define __ZFRAME_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zframe.xml" to make changes. // @interface #define ZFRAME_MORE 1 // #define ZFRAME_REUSE 2 // #define ZFRAME_DONTWAIT 4 // // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. CZMQ_EXPORT zframe_t * zframe_new (const void *data, size_t size); // Destroy a frame CZMQ_EXPORT void zframe_destroy (zframe_t **self_p); // Create an empty (zero-sized) frame // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_new_empty (); // Create a frame with a specified string content. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data CZMQ_EXPORT size_t zframe_size (zframe_t *self); // Return address of frame data CZMQ_EXPORT byte * zframe_data (zframe_t *self); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator CZMQ_EXPORT bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method CZMQ_EXPORT int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. CZMQ_EXPORT void zframe_set_more (zframe_t *self, int more); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. CZMQ_EXPORT bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame CZMQ_EXPORT void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. CZMQ_EXPORT void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. CZMQ_EXPORT bool zframe_is (void *self); // Self test of this class CZMQ_EXPORT void zframe_test (bool verbose); // @end // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive a new frame off the socket. Returns newly allocated frame, or // NULL if there was no input waiting, or if the read was interrupted. CZMQ_EXPORT zframe_t * zframe_recv_nowait (void *source); // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Print contents of the frame to FILE stream. CZMQ_EXPORT void zframe_fprint (zframe_t *self, const char *prefix, FILE *file); // Deprecated method aliases #define zframe_print_to_stream(s,p,F) zframe_fprint(s,p,F) #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zcert.h0000664000175000017500000000704612505070716014525 0ustar00phph00000000000000/* ========================================================================= zcert - work with CURVE security certificates Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCERT_H_INCLUDED__ #define __ZCERT_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create and initialize a new certificate in memory CZMQ_EXPORT zcert_t * zcert_new (void); // Constructor, accepts public/secret key pair from caller CZMQ_EXPORT zcert_t * zcert_new_from (byte *public_key, byte *secret_key); // Destroy a certificate in memory CZMQ_EXPORT void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string CZMQ_EXPORT byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string CZMQ_EXPORT byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string CZMQ_EXPORT char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. CZMQ_EXPORT void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. CZMQ_EXPORT char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. CZMQ_EXPORT zlist_t * zcert_meta_keys (zcert_t *self); // Load certificate from file (constructor) CZMQ_EXPORT zcert_t * zcert_load (const char *filename); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). CZMQ_EXPORT int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. CZMQ_EXPORT void zcert_apply (zcert_t *self, void *zocket); // Return copy of certificate; if certificate is null or we exhausted // heap memory, returns null. CZMQ_EXPORT zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys CZMQ_EXPORT bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout CZMQ_EXPORT void zcert_print (zcert_t *self); // DEPRECATED as incompatible with centralized logging // Print certificate contents to open stream CZMQ_EXPORT void zcert_fprint (zcert_t *self, FILE *file); // Self test of this class CZMQ_EXPORT void zcert_test (bool verbose); // @end #ifdef __cplusplus } #endif // Deprecated method aliases #define zcert_dump(s) zcert_print(s) #endif czmq-3.0.2/include/czmq.h0000664000175000017500000000247312505070716014347 0ustar00phph00000000000000/* ========================================================================= czmq - an open-source framework for proximity-based P2P apps Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ -- See http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __CZMQ_H_INCLUDED__ #define __CZMQ_H_INCLUDED__ // These are signatures for handler functions that customize the // behavior of CZMQ containers. These are shared between all CZMQ // container types. // -- destroy an item typedef void (czmq_destructor) (void **item); // -- duplicate an item typedef void *(czmq_duplicator) (const void *item); // - compare two items, for sorting typedef int (czmq_comparator) (const void *item1, const void *item2); // Include the project library file #include "czmq_library.h" #endif czmq-3.0.2/include/zproxy_v2.h0000664000175000017500000000364512505070716015361 0ustar00phph00000000000000/* ========================================================================= zproxy_v2 - run a steerable proxy in the background (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZPROXY_V2_H_INCLUDED__ #define __ZPROXY_V2_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Constructor // Create a new zproxy object. You must create the frontend and backend // sockets, configure them, and connect or bind them, before you pass them // to the constructor. Do NOT use the sockets again, after passing them to // this method. CZMQ_EXPORT zproxy_t * zproxy_new (zctx_t *ctx, void *frontend, void *backend); // Destructor // Destroy a zproxy object; note this first stops the proxy. CZMQ_EXPORT void zproxy_destroy (zproxy_t **self_p); // Copy all proxied messages to specified endpoint; if this is NULL, any // in-progress capturing will be stopped. You must already have bound the // endpoint to a PULL socket. CZMQ_EXPORT void zproxy_capture (zproxy_t *self, const char *endpoint); // Pauses a zproxy object; a paused proxy will cease processing messages, // causing them to be queued up and potentially hit the high-water mark on // the frontend socket, causing messages to be dropped, or writing // applications to block. CZMQ_EXPORT void zproxy_pause (zproxy_t *self); // Resume a zproxy object CZMQ_EXPORT void zproxy_resume (zproxy_t *self); // Self test of this class CZMQ_EXPORT void zproxy_v2_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zlistx.h0000664000175000017500000001552612527573434014746 0ustar00phph00000000000000/* ========================================================================= zlistx - extended generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZLISTX_H_INCLUDED__ #define __ZLISTX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create a new, empty list. CZMQ_EXPORT zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. CZMQ_EXPORT void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list CZMQ_EXPORT size_t zlistx_size (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). CZMQ_EXPORT void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). CZMQ_EXPORT void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. CZMQ_EXPORT void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. CZMQ_EXPORT void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. CZMQ_EXPORT int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. CZMQ_EXPORT void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. CZMQ_EXPORT void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. CZMQ_EXPORT void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. CZMQ_EXPORT void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. CZMQ_EXPORT void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. CZMQ_EXPORT void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. CZMQ_EXPORT zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. CZMQ_EXPORT void zlistx_set_destructor (zlistx_t *self, czmq_destructor destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. CZMQ_EXPORT void zlistx_set_duplicator (zlistx_t *self, czmq_duplicator duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. CZMQ_EXPORT void zlistx_set_comparator (zlistx_t *self, czmq_comparator comparator); // Runs selftest of class CZMQ_EXPORT void zlistx_test (int verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zclock.h0000664000175000017500000000405712505070716014662 0ustar00phph00000000000000/* ========================================================================= zclock - millisecond clocks and delays Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCLOCK_H_INCLUDED__ #define __ZCLOCK_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Sleep for a number of milliseconds CZMQ_EXPORT void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. CZMQ_EXPORT int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). CZMQ_EXPORT char * zclock_timestr (void); // Self test of this class CZMQ_EXPORT void zclock_test (bool verbose); // @end // DEPRECATED in favor of zsys logging, see issue #519 // Print formatted string to stdout, prefixed by date/time and // terminated with a newline. CZMQ_EXPORT void zclock_log (const char *format, ...); // Compiler hints CZMQ_EXPORT void zclock_log (const char *format, ...) CHECK_PRINTF (1); #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zbeacon.h0000664000175000017500000000545012505070716015014 0ustar00phph00000000000000/* ========================================================================= zbeacon - LAN discovery and presence Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZBEACON_H_INCLUDED__ #define __ZBEACON_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new zbeacon actor instance: // // zactor_t *beacon = zactor_new (zbeacon, NULL); // // Destroy zbeacon instance: // // zactor_destroy (&beacon); // // Enable verbose logging of commands and activity: // // zstr_send (beacon, "VERBOSE"); // // Configure beacon to run on specified UDP port, and return the name of // the host, which can be used as endpoint for incoming connections. To // force the beacon to operate on a given interface, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating // the beacon. If the system does not support UDP broadcasts (lacking a // workable interface), returns an empty hostname: // // // Pictures: 's' = C string, 'i' = int // zsock_send (beacon, "si", "CONFIGURE", port_number); // char *hostname = zstr_recv (beacon); // // Start broadcasting a beacon at a specified interval in msec. The beacon // data can be at most UDP_FRAME_MAX bytes; this constant is defined in // zsys.h to be 255: // // // Pictures: 'b' = byte * data + size_t size // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); // // Stop broadcasting the beacon: // // zstr_sendx (beacon, "SILENCE", NULL); // // Start listening to beacons from peers. The filter is used to do a prefix // match on received beacons, to remove junk. Note that any received data // that is identical to our broadcast beacon_data is discarded in any case. // If the filter size is zero, we get all peer beacons: // // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); // // Stop listening to other peers // // zstr_sendx (beacon, "UNSUBSCRIBE", NULL); // // Receive next beacon from a peer. Received beacons are always a 2-frame // message containing the ipaddress of the sender, and then the binary // beacon data as published by the sender: // // zmsg_t *msg = zmsg_recv (beacon); // // This is the zbeacon constructor as a zactor_fn: CZMQ_EXPORT void zbeacon (zsock_t *pipe, void *unused); // Self test of this class CZMQ_EXPORT void zbeacon_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zconfig.h0000664000175000017500000001270112512446175015033 0ustar00phph00000000000000/* ========================================================================= zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCONFIG_H_INCLUDED__ #define __ZCONFIG_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Function that executes config typedef int (zconfig_fct) (zconfig_t *self, void *arg, int level); // Create new config item CZMQ_EXPORT zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children CZMQ_EXPORT void zconfig_destroy (zconfig_t **self_p); // Return name of config item CZMQ_EXPORT char * zconfig_name (zconfig_t *self); // Return value of config item CZMQ_EXPORT char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value CZMQ_EXPORT void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. CZMQ_EXPORT void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...); // Get value for config item into a string value; leading slash is optional // and ignored. CZMQ_EXPORT char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...); // Find our first child, if any CZMQ_EXPORT zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any CZMQ_EXPORT zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. CZMQ_EXPORT zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth CZMQ_EXPORT zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. CZMQ_EXPORT int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. CZMQ_EXPORT void zconfig_set_comment (zconfig_t *self, const char *format, ...); // Return comments of config item, as zlist. CZMQ_EXPORT zlist_t * zconfig_comments (zconfig_t *self); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. CZMQ_EXPORT zconfig_t * zconfig_load (const char *filename); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. CZMQ_EXPORT int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. CZMQ_EXPORT zconfig_t * zconfig_loadf (const char *format, ...); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. CZMQ_EXPORT int zconfig_savef (zconfig_t *self, const char *format, ...); // Report filename used during zconfig_load, or NULL if none CZMQ_EXPORT const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). CZMQ_EXPORT int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk CZMQ_EXPORT zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk CZMQ_EXPORT zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string CZMQ_EXPORT zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string CZMQ_EXPORT char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. CZMQ_EXPORT bool zconfig_has_changed (zconfig_t *self); // Print the config file to open stream CZMQ_EXPORT void zconfig_fprint (zconfig_t *self, FILE *file); // Print the config file to stdout CZMQ_EXPORT void zconfig_print (zconfig_t *self); // @end // Self test of this class CZMQ_EXPORT void zconfig_test (bool verbose); // Compiler hints CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); #ifdef __cplusplus } #endif // Deprecated method aliases #define zconfig_dump(s) zconfig_print(s) #define zconfig_resolve(s,p,d) zconfig_get((s),(p),(d)) #endif czmq-3.0.2/include/zloop.h0000664000175000017500000001534212535241704014537 0ustar00phph00000000000000/* ========================================================================= zloop - event-driven reactor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZLOOP_H_INCLUDED__ #define __ZLOOP_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zloop.xml" to make changes. // @interface // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Create a new zloop reactor CZMQ_EXPORT zloop_t * zloop_new (); // Destroy a reactor CZMQ_EXPORT void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. CZMQ_EXPORT int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. CZMQ_EXPORT void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. CZMQ_EXPORT int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. CZMQ_EXPORT void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. CZMQ_EXPORT int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). CZMQ_EXPORT int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. CZMQ_EXPORT void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. CZMQ_EXPORT void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. CZMQ_EXPORT void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. CZMQ_EXPORT void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. CZMQ_EXPORT void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off CZMQ_EXPORT void zloop_set_verbose (zloop_t *self, bool verbose); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if cancelled by a handler. CZMQ_EXPORT int zloop_start (zloop_t *self); // Ignore zsys_interrupted flag in this loop. By default, a zloop_start will // exit as soon as it detects zsys_interrupted is set to something other than // zero. Calling zloop_ignore_interrupts will supress this behavior. CZMQ_EXPORT void zloop_ignore_interrupts (zloop_t *self); // Self test of this class CZMQ_EXPORT void zloop_test (bool verbose); // @end // Deprecated method aliases #define zloop_set_tolerant(s,i) zloop_poller_set_tolerant(s,i) #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zfile.h0000664000175000017500000001405712535241704014507 0ustar00phph00000000000000/* ========================================================================= zfile - helper functions for working with files. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZFILE_H_INCLUDED__ #define __ZFILE_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zfile.xml" to make changes. // @interface // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. CZMQ_EXPORT zfile_t * zfile_new (const char *path, const char *name); // Destroy a file item CZMQ_EXPORT void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided CZMQ_EXPORT const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. CZMQ_EXPORT void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. CZMQ_EXPORT bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. CZMQ_EXPORT bool zfile_has_changed (zfile_t *self); // Remove the file from disk CZMQ_EXPORT void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible CZMQ_EXPORT int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. CZMQ_EXPORT int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. CZMQ_EXPORT bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 CZMQ_EXPORT int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. CZMQ_EXPORT const char * zfile_readln (zfile_t *self); // Close file, if open CZMQ_EXPORT void zfile_close (zfile_t *self); // Return file handle, if opened CZMQ_EXPORT FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. CZMQ_EXPORT const char * zfile_digest (zfile_t *self); // Self test of this class. CZMQ_EXPORT void zfile_test (bool verbose); // @end // @interface // These methods are deprecated, and now moved to zsys class. CZMQ_EXPORT bool zfile_exists (const char *filename); CZMQ_EXPORT ssize_t zfile_size (const char *filename); CZMQ_EXPORT mode_t zfile_mode (const char *filename); CZMQ_EXPORT int zfile_delete (const char *filename); CZMQ_EXPORT bool zfile_stable (const char *filename); CZMQ_EXPORT int zfile_mkdir (const char *pathname); CZMQ_EXPORT int zfile_rmdir (const char *pathname); CZMQ_EXPORT void zfile_mode_private (void); CZMQ_EXPORT void zfile_mode_default (void); // @end #ifdef __cplusplus } #endif #endif // __ZFILE_H_INCLUDED__ czmq-3.0.2/include/zactor.h0000664000175000017500000000452512535241704014677 0ustar00phph00000000000000/* ========================================================================= zactor - actor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZACTOR_H_INCLUDED__ #define __ZACTOR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zactor.xml" to make changes. // @interface // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Create a new actor passing arbitrary arguments reference. CZMQ_EXPORT zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. CZMQ_EXPORT void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. CZMQ_EXPORT int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. CZMQ_EXPORT bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. CZMQ_EXPORT void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. CZMQ_EXPORT zsock_t * zactor_sock (zactor_t *self); // Self test of this class. CZMQ_EXPORT void zactor_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/ziflist.h0000664000175000017500000000415012535241704015053 0ustar00phph00000000000000/* ========================================================================= ziflist - List of network interfaces available on system Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZIFLIST_H_INCLUDED__ #define __ZIFLIST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/ziflist.xml" to make changes. // @interface // Get a list of network interfaces currently defined on the system CZMQ_EXPORT ziflist_t * ziflist_new (); // Destroy a ziflist instance CZMQ_EXPORT void ziflist_destroy (ziflist_t **self_p); // Print properties of the ziflist object. CZMQ_EXPORT void ziflist_print (ziflist_t *self); // Reload network interfaces from system CZMQ_EXPORT void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system CZMQ_EXPORT size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none CZMQ_EXPORT const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one CZMQ_EXPORT const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string CZMQ_EXPORT const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string CZMQ_EXPORT const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string CZMQ_EXPORT const char * ziflist_netmask (ziflist_t *self); // Self test of this class. CZMQ_EXPORT void ziflist_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zhashx.h0000664000175000017500000002754212535241704014706 0ustar00phph00000000000000/* ========================================================================= zhashx - extended generic type-free hash container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZHASHX_H_INCLUDED__ #define __ZHASHX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zhashx.xml" to make changes. // @interface // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // compare two items, for sorting typedef void (zhashx_free_fn) ( void *data); // compare two items, for sorting typedef size_t (zhashx_hash_fn) ( const void *key); // DEPRECATED as clumsy -- use zhashx_first/_next instead typedef int (zhashx_foreach_fn) ( const char *key, void *item, void *argument); // Create a new, empty hash container CZMQ_EXPORT zhashx_t * zhashx_new (); // Destroy a hash container and all items in it CZMQ_EXPORT void zhashx_destroy (zhashx_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. CZMQ_EXPORT void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. CZMQ_EXPORT void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null CZMQ_EXPORT void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhashx_comment (zhashx_t *self, const char *format, ...) CHECK_PRINTF (2); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zframe_t * zhashx_pack (zhashx_t *self); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhashx_t * zhashx_unpack (zframe_t *frame); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. CZMQ_EXPORT void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. CZMQ_EXPORT void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). CZMQ_EXPORT void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. CZMQ_EXPORT void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. CZMQ_EXPORT void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. CZMQ_EXPORT void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. CZMQ_EXPORT zhashx_t * zhashx_dup_v2 (zhashx_t *self); // DEPRECATED as clumsy -- use set_destructor instead // Set hash for automatic value destruction CZMQ_EXPORT void zhashx_autofree (zhashx_t *self); // DEPRECATED as clumsy -- use zhashx_first/_next instead // Apply function to each item in the hash table. Items are iterated in no // defined order. Stops if callback function returns non-zero and returns // final return code from callback function (zero = success). // Callback function for zhashx_foreach method CZMQ_EXPORT int zhashx_foreach (zhashx_t *self, zhashx_foreach_fn callback, void *argument); // Self test of this class CZMQ_EXPORT void zhashx_test (int verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zauth.h0000664000175000017500000000703112505070716014523 0ustar00phph00000000000000/* ========================================================================= zauth - authentication for ZeroMQ security mechanisms Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZAUTH_H_INCLUDED__ #define __ZAUTH_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface #define CURVE_ALLOW_ANY "*" // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated). // // Create new zauth actor instance. This installs authentication on all // zsock sockets. Until you add policies, all incoming NULL connections are // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections // are denied: // // zactor_t *auth = zactor_new (zauth, NULL); // // Destroy zauth instance. This removes authentication and allows all // connections to pass, without authentication: // // zactor_destroy (&auth); // // Note that all zauth commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity. Verbose logging can help // debug non-trivial authentication policies: // // zstr_send (auth, "VERBOSE"); // zsock_wait (auth); // // Allow (whitelist) a list of IP addresses. For NULL, all clients from // these addresses will be accepted. For PLAIN and CURVE, they will be // allowed to continue with authentication. You can call this method // multiple times to whitelist more IP addresses. If you whitelist one // or nmore addresses, any non-whitelisted addresses are treated as // blacklisted: // // zstr_sendx (auth, "ALLOW", "127.0.0.1", "127.0.0.2", NULL); // zsock_wait (auth); // // Deny (blacklist) a list of IP addresses. For all security mechanisms, // this rejects the connection without any further authentication. Use // either a whitelist, or a blacklist, not not both. If you define both // a whitelist and a blacklist, only the whitelist takes effect: // // zstr_sendx (auth, "DENY", "192.168.0.1", "192.168.0.2", NULL); // zsock_wait (auth); // // Configure PLAIN authentication using a plain-text password file. You can // modify the password file at any time; zauth will reload it automatically // if modified externally: // // zstr_sendx (auth, "PLAIN", filename, NULL); // zsock_wait (auth); // // Configure CURVE authentication, using a directory that holds all public // client certificates, i.e. their public keys. The certificates must be in // zcert_save format. You can add and remove certificates in that directory // at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the directory name: // // zstr_sendx (auth, "CURVE", directory, NULL); // zsock_wait (auth); // // Configure GSSAPI authentication, using an underlying mechanism (usually // Kerberos) to establish a secure context and perform mutual authentication: // // zstr_sendx (auth, "GSSAPI", NULL); // zsock_wait (auth); // // This is the zauth constructor as a zactor_fn: CZMQ_EXPORT void zauth (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zauth_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zarmour.h0000664000175000017500000000554312505070716015075 0ustar00phph00000000000000/* ========================================================================= zarmour - armoured text encoding and decoding Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZARMOUR_H_INCLUDED__ #define __ZARMOUR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Enumeration defining different encoding modes typedef enum { ZARMOUR_MODE_BASE64_STD // Standard base 64 , ZARMOUR_MODE_BASE64_URL // URL and filename friendly base 64 , ZARMOUR_MODE_BASE32_STD // Standard base 32 , ZARMOUR_MODE_BASE32_HEX // Extended hex base 32 , ZARMOUR_MODE_BASE16 // Standard base 16 #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 3, 0)) , ZARMOUR_MODE_Z85 // Z85 from ZeroMQ RFC 32 #endif } zarmour_mode_t; // Create a new zarmour CZMQ_EXPORT zarmour_t * zarmour_new (); // Destroy the zarmour CZMQ_EXPORT void zarmour_destroy (zarmour_t **self_p); // Print properties of object CZMQ_EXPORT void zarmour_print (zarmour_t *self); // Get printable string for mode CZMQ_EXPORT const char * zarmour_mode_str (zarmour_t *self); // Encode a stream of bytes into an armoured string. CZMQ_EXPORT char * zarmour_encode (zarmour_t *self, const byte *data, size_t data_size); // Decode an armoured string into a string of bytes. // The decoded output is null-terminated, so it may be treated // as a string, if that's what it was prior to encoding. CZMQ_EXPORT byte * zarmour_decode (zarmour_t *self, const char *data, size_t *decode_size); // Get/set the mode property CZMQ_EXPORT zarmour_mode_t zarmour_mode (zarmour_t *self); CZMQ_EXPORT void zarmour_set_mode (zarmour_t *self, zarmour_mode_t mode); // Get/set the pad property CZMQ_EXPORT bool zarmour_pad (zarmour_t *self); CZMQ_EXPORT void zarmour_set_pad (zarmour_t *self, bool pad); // Get/set the pad_char property CZMQ_EXPORT char zarmour_pad_char (zarmour_t *self); CZMQ_EXPORT void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Get/set the line_breaks property CZMQ_EXPORT bool zarmour_line_breaks (zarmour_t *self); CZMQ_EXPORT void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get/set the line_length property CZMQ_EXPORT size_t zarmour_line_length (zarmour_t *self); CZMQ_EXPORT void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Self test of this class CZMQ_EXPORT int zarmour_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zbeacon_v2.h0000664000175000017500000000442612505070716015425 0ustar00phph00000000000000/* ========================================================================= zbeacon - LAN discovery and presence (deprecated) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZBEACON_V2_H_INCLUDED__ #define __ZBEACON_V2_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create a new beacon on a certain UDP port. If the system does not // support UDP broadcasts (lacking a useful interface), returns NULL. // To force the beacon to operate on a given port, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() beforehand. // If you are using the new zsock API then pass NULL as the ctx here. CZMQ_EXPORT zbeacon_t * zbeacon_new (zctx_t *ctx, int port_nbr); // Destroy a beacon CZMQ_EXPORT void zbeacon_destroy (zbeacon_t **self_p); // Return our own IP address as printable string CZMQ_EXPORT char * zbeacon_hostname (zbeacon_t *self); // Set broadcast interval in milliseconds (default is 1000 msec) CZMQ_EXPORT void zbeacon_set_interval (zbeacon_t *self, int interval); // Filter out any beacon that looks exactly like ours CZMQ_EXPORT void zbeacon_noecho (zbeacon_t *self); // Start broadcasting beacon to peers at the specified interval CZMQ_EXPORT void zbeacon_publish (zbeacon_t *self, byte *transmit, size_t size); // Stop broadcasting beacons CZMQ_EXPORT void zbeacon_silence (zbeacon_t *self); // Start listening to other peers; zero-sized filter means get everything CZMQ_EXPORT void zbeacon_subscribe (zbeacon_t *self, byte *filter, size_t size); // Stop listening to other peers CZMQ_EXPORT void zbeacon_unsubscribe (zbeacon_t *self); // Get beacon ZeroMQ socket, for polling or receiving messages CZMQ_EXPORT void * zbeacon_socket (zbeacon_t *self); // Self test of this class CZMQ_EXPORT void zbeacon_v2_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/zlist.h0000664000175000017500000001340112535241705014534 0ustar00phph00000000000000/* ========================================================================= zlist - simple generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZLIST_H_INCLUDED__ #define __ZLIST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT! // @warning Please edit the model at "api/zlist.xml" to make changes. // @interface // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Create a new list container CZMQ_EXPORT zlist_t * zlist_new (); // Destroy a list container CZMQ_EXPORT void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any CZMQ_EXPORT void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. CZMQ_EXPORT bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present CZMQ_EXPORT void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. // The caller is responsible for destroying the return value when finished with it. CZMQ_EXPORT zlist_t * zlist_dup (zlist_t *self); // Purge all items from list CZMQ_EXPORT void zlist_purge (zlist_t *self); // Return number of items in the list CZMQ_EXPORT size_t zlist_size (zlist_t *self); // Sort the list by ascending key value using a straight ASCII comparison. // The sort is not stable, so may reorder items with the same keys. CZMQ_EXPORT void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. CZMQ_EXPORT void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. CZMQ_EXPORT void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class CZMQ_EXPORT void zlist_test (int verbose); // @end #ifdef __cplusplus } #endif #endif czmq-3.0.2/include/czmq_prelude.h0000664000175000017500000004460112512255240016061 0ustar00phph00000000000000/* ========================================================================= czmq_prelude.h - CZMQ environment Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __CZMQ_PRELUDE_H_INCLUDED__ #define __CZMQ_PRELUDE_H_INCLUDED__ //- Establish the compiler and computer system ------------------------------ /* * Defines zero or more of these symbols, for use in any non-portable * code: * * __WINDOWS__ Microsoft C/C++ with Windows calls * __MSDOS__ System is MS-DOS (set if __WINDOWS__ set) * __VMS__ System is VAX/VMS or Alpha/OpenVMS * __UNIX__ System is UNIX * __OS2__ System is OS/2 * * __IS_32BIT__ OS/compiler is 32 bits * __IS_64BIT__ OS/compiler is 64 bits * * When __UNIX__ is defined, we also define exactly one of these: * * __UTYPE_AUX Apple AUX * __UTYPE_BEOS BeOS * __UTYPE_BSDOS BSD/OS * __UTYPE_DECALPHA Digital UNIX (Alpha) * __UTYPE_IBMAIX IBM RS/6000 AIX * __UTYPE_FREEBSD FreeBSD * __UTYPE_HPUX HP/UX * __UTYPE_ANDROID Android * __UTYPE_LINUX Linux * __UTYPE_MIPS MIPS (BSD 4.3/System V mixture) * __UTYPE_NETBSD NetBSD * __UTYPE_NEXT NeXT * __UTYPE_OPENBSD OpenBSD * __UTYPE_OSX Apple Macintosh OS X * __UTYPE_IOS Apple iOS * __UTYPE_QNX QNX * __UTYPE_IRIX Silicon Graphics IRIX * __UTYPE_SINIX SINIX-N (Siemens-Nixdorf Unix) * __UTYPE_SUNOS SunOS * __UTYPE_SUNSOLARIS Sun Solaris * __UTYPE_UNIXWARE SCO UnixWare * ... these are the ones I know about so far. * __UTYPE_GENERIC Any other UNIX * * When __VMS__ is defined, we may define one or more of these: * * __VMS_XOPEN Supports XOPEN functions */ #if (defined (__64BIT__) || defined (__x86_64__)) # define __IS_64BIT__ // May have 64-bit OS/compiler #else # define __IS_32BIT__ // Else assume 32-bit OS/compiler #endif #if (defined WIN32 || defined _WIN32) # undef __WINDOWS__ # define __WINDOWS__ # undef __MSDOS__ # define __MSDOS__ #endif #if (defined WINDOWS || defined _WINDOWS || defined __WINDOWS__) # undef __WINDOWS__ # define __WINDOWS__ # undef __MSDOS__ # define __MSDOS__ // Stop cheeky warnings about "deprecated" functions like fopen # if _MSC_VER >= 1500 # define _CRT_SECURE_NO_DEPRECATE # pragma warning(disable: 4996) # endif #endif // MSDOS Microsoft C // _MSC_VER Microsoft C #if (defined (MSDOS) || defined (_MSC_VER)) # undef __MSDOS__ # define __MSDOS__ # if (defined (_DEBUG) && !defined (DEBUG)) # define DEBUG # endif #endif #if (defined (__EMX__) && defined (__i386__)) # undef __OS2__ # define __OS2__ #endif // VMS VAX C (VAX/VMS) // __VMS Dec C (Alpha/OpenVMS) // __vax__ gcc #if (defined (VMS) || defined (__VMS) || defined (__vax__)) # undef __VMS__ # define __VMS__ # if (__VMS_VER >= 70000000) # define __VMS_XOPEN # endif #endif // Try to define a __UTYPE_xxx symbol... // unix SunOS at least // __unix__ gcc // _POSIX_SOURCE is various UNIX systems, maybe also VAX/VMS #if (defined (unix) || defined (__unix__) || defined (_POSIX_SOURCE)) # if (!defined (__VMS__)) # undef __UNIX__ # define __UNIX__ # if (defined (__alpha)) // Digital UNIX is 64-bit # undef __IS_32BIT__ # define __IS_64BIT__ # define __UTYPE_DECALPHA # endif # endif #endif #if (defined (_AUX)) # define __UTYPE_AUX # define __UNIX__ #elif (defined (__BEOS__)) # define __UTYPE_BEOS # define __UNIX__ #elif (defined (__hpux)) # define __UTYPE_HPUX # define __UNIX__ # define _INCLUDE_HPUX_SOURCE # define _INCLUDE_XOPEN_SOURCE # define _INCLUDE_POSIX_SOURCE #elif (defined (_AIX) || defined (AIX)) # define __UTYPE_IBMAIX # define __UNIX__ #elif (defined (BSD) || defined (bsd)) # define __UTYPE_BSDOS # define __UNIX__ #elif (defined (__ANDROID__)) # define __UTYPE_ANDROID # define __UNIX__ #elif (defined (LINUX) || defined (linux) || defined (__linux__)) # define __UTYPE_LINUX # define __UNIX__ # ifndef __NO_CTYPE # define __NO_CTYPE // Suppress warnings on tolower() # endif # ifndef _DEFAULT_SOURCE # define _DEFAULT_SOURCE // Include stuff from 4.3 BSD Unix # endif #elif (defined (Mips)) # define __UTYPE_MIPS # define __UNIX__ #elif (defined (FreeBSD) || defined (__FreeBSD__)) # define __UTYPE_FREEBSD # define __UNIX__ #elif (defined (NetBSD) || defined (__NetBSD__)) # define __UTYPE_NETBSD # define __UNIX__ #elif (defined (OpenBSD) || defined (__OpenBSD__)) # define __UTYPE_OPENBSD # define __UNIX__ #elif (defined (APPLE) || defined (__APPLE__)) # include # define __UNIX__ # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR # define __UTYPE_IOS # else # define __UTYPE_OSX # endif #elif (defined (NeXT)) # define __UTYPE_NEXT # define __UNIX__ #elif (defined (__QNX__)) # define __UTYPE_QNX # define __UNIX__ #elif (defined (sgi)) # define __UTYPE_IRIX # define __UNIX__ #elif (defined (sinix)) # define __UTYPE_SINIX # define __UNIX__ #elif (defined (SOLARIS) || defined (__SRV4)) # define __UTYPE_SUNSOLARIS # define __UNIX__ #elif (defined (SUNOS) || defined (SUN) || defined (sun)) # define __UTYPE_SUNOS # define __UNIX__ #elif (defined (__USLC__) || defined (UnixWare)) # define __UTYPE_UNIXWARE # define __UNIX__ #elif (defined (__CYGWIN__)) # define __UTYPE_CYGWIN # define __UNIX__ #elif (defined (__UNIX__)) # define __UTYPE_GENERIC #endif //- Always include ZeroMQ headers ------------------------------------------- #include "zmq.h" #include "zmq_utils.h" //- Standard ANSI include files --------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include //- System-specific include files ------------------------------------------- #if (defined (__MSDOS__)) # if (defined (__WINDOWS__)) # if (_WIN32_WINNT < 0x0501) # undef _WIN32_WINNT # define _WIN32_WINNT 0x0501 # endif # if (!defined (FD_SETSIZE)) # define FD_SETSIZE 1024 // Max. filehandles/sockets # endif # include # include # include # include # include // For getnameinfo () # include // For GetAdaptersAddresses () # endif # include # include # include # include # include # include # include # include #endif #if (defined (__UNIX__)) # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include // Let CZMQ build with libzmq/3.x # include // Must come before arpa/inet.h # if (!defined (__UTYPE_ANDROID)) && (!defined (__UTYPE_IBMAIX)) \ && (!defined (__UTYPE_HPUX)) # include # endif # if defined (__UTYPE_SUNSOLARIS) || defined (__UTYPE_SUNOS) # include # endif # if (!defined (__UTYPE_BEOS)) # include # if (!defined (TCP_NODELAY)) # include # endif # endif # if (defined (__UTYPE_IBMAIX) || defined(__UTYPE_QNX)) # include # endif # if (defined (__UTYPE_BEOS)) # include # endif # if ((defined (_XOPEN_REALTIME) && (_XOPEN_REALTIME >= 1)) \ || (defined (_POSIX_VERSION) && (_POSIX_VERSION >= 199309L))) # include # endif # if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) # include # include // For monotonic clocks # endif # if (defined (__UTYPE_OSX)) # include // For _NSGetEnviron() # endif # if (defined (__UTYPE_ANDROID)) # include # endif #endif #if (defined (__VMS__)) # if (!defined (vaxc)) # include // Not provided by Vax C # endif # include # include # include # include # include # include # include # include # include # include # include # include # include # include #endif #if (defined (__OS2__)) # include // Required near top # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include // Must come before arpa/inet.h # include # include # if (!defined (TCP_NODELAY)) # include # endif #endif // Add missing defines for non-POSIX systems #ifndef S_IRUSR # define S_IRUSR S_IREAD #endif #ifndef S_IWUSR # define S_IWUSR S_IWRITE #endif #ifndef S_ISDIR # define S_ISDIR(m) (((m) & S_IFDIR) != 0) #endif #ifndef S_ISREG # define S_ISREG(m) (((m) & S_IFREG) != 0) #endif //- Check compiler data type sizes ------------------------------------------ #if (UCHAR_MAX != 0xFF) # error "Cannot compile: must change definition of 'byte'." #endif #if (USHRT_MAX != 0xFFFFU) # error "Cannot compile: must change definition of 'dbyte'." #endif #if (UINT_MAX != 0xFFFFFFFFU) # error "Cannot compile: must change definition of 'qbyte'." #endif //- Data types -------------------------------------------------------------- typedef unsigned char byte; // Single unsigned byte = 8 bits typedef unsigned short dbyte; // Double byte = 16 bits typedef unsigned int qbyte; // Quad byte = 32 bits typedef struct sockaddr_in inaddr_t; // Internet socket address structure //- Inevitable macros ------------------------------------------------------- #define streq(s1,s2) (!strcmp ((s1), (s2))) #define strneq(s1,s2) (strcmp ((s1), (s2))) // Provide random number from 0..(num-1) #if (defined (__WINDOWS__)) || (defined (__UTYPE_IBMAIX)) \ || (defined (__UTYPE_HPUX)) || (defined (__UTYPE_SUNOS)) # define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0)) #else # define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0)) #endif // Windows MSVS doesn't have stdbool #if (defined (_MSC_VER)) # if (!defined (__cplusplus) && (!defined (true))) # define true 1 # define false 0 typedef char bool; # endif #else # include #endif //- A number of POSIX and C99 keywords and data types ----------------------- // CZMQ uses uint for array indices; equivalent to unsigned int, but more // convenient in code. We define it in czmq_prelude.h on systems that do // not define it by default. #if (defined (__WINDOWS__)) # if (!defined (__cplusplus) && (!defined (inline))) # define inline __inline # endif # define strtoull _strtoui64 # define atoll _atoi64 # define srandom srand # define TIMEZONE _timezone # if (!defined (__MINGW32__)) # define snprintf _snprintf # define vsnprintf _vsnprintf # endif typedef unsigned long ulong; typedef unsigned int uint; # if (!defined (__MINGW32__)) typedef int mode_t; # if defined (__IS_64BIT__) typedef long long ssize_t; # else typedef long ssize_t; # endif # endif # if ((!defined (__MINGW32__) \ || (defined (__MINGW32__) && defined (__IS_64BIT__))) \ && !defined (ZMQ_DEFINED_STDINT)) typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; # endif typedef uint32_t in_addr_t; # if (!defined (PRId8)) # define PRId8 "d" # endif # if (!defined (PRId16)) # define PRId16 "d" # endif # if (!defined (PRId32)) # define PRId32 "d" # endif # if (!defined (PRId64)) # define PRId64 "I64d" # endif # if (!defined (PRIu8)) # define PRIu8 "u" # endif # if (!defined (PRIu16)) # define PRIu16 "u" # endif # if (!defined (PRIu32)) # define PRIu32 "u" # endif # if (!defined (PRIu64)) # define PRIu64 "I64u" # endif # if (!defined (va_copy)) // MSVC does not support C99's va_copy so we use a regular assignment # define va_copy(dest,src) (dest) = (src) # endif #elif (defined (__UTYPE_OSX)) typedef unsigned long ulong; typedef unsigned int uint; // This fixes header-order dependence problem with some Linux versions #elif (defined (__UTYPE_LINUX)) # if (__STDC_VERSION__ >= 199901L && !defined (__USE_MISC)) typedef unsigned int uint; # endif #endif //- Non-portable declaration specifiers ------------------------------------- #if defined (__WINDOWS__) # if defined LIBCZMQ_STATIC # define CZMQ_EXPORT # elif defined LIBCZMQ_EXPORTS # define CZMQ_EXPORT __declspec(dllexport) # else # define CZMQ_EXPORT __declspec(dllimport) # endif #else # define CZMQ_EXPORT #endif // For thread-local storage #if defined (__WINDOWS__) # define CZMQ_THREADLS __declspec(thread) #else # define CZMQ_THREADLS __thread #endif //- Memory allocations ------------------------------------------------------ #if defined(__cplusplus) extern "C" CZMQ_EXPORT volatile uint64_t zsys_allocs; #else extern CZMQ_EXPORT volatile uint64_t zsys_allocs; #endif // Replacement for malloc() which asserts if we run out of heap, and // which zeroes the allocated block. static inline void * safe_malloc (size_t size, const char *file, unsigned line) { // printf ("%s:%u %08d\n", file, line, (int) size); #if defined (__UTYPE_LINUX) && defined (__IS_64BIT__) // On GCC we count zmalloc memory allocations __sync_add_and_fetch (&zsys_allocs, 1); #endif void *mem = calloc (1, size); if (mem == NULL) { fprintf (stderr, "FATAL ERROR at %s:%u\n", file, line); fprintf (stderr, "OUT OF MEMORY (malloc returned NULL)\n"); fflush (stderr); abort (); } return mem; } // Define _ZMALLOC_DEBUG if you need to trace memory leaks using e.g. mtrace, // otherwise all allocations will claim to come from czmq_prelude.h. For best // results, compile all classes so you see dangling object allocations. // _ZMALLOC_PEDANTIC does the same thing, but its intention is to propagate // out of memory condition back up the call stack. #if defined _ZMALLOC_DEBUG || _ZMALLOC_PEDANTIC # define zmalloc(size) calloc(1,(size)) #else # define zmalloc(size) safe_malloc((size), __FILE__, __LINE__) #endif // GCC supports validating format strings for functions that act like printf #if defined (__GNUC__) && (__GNUC__ >= 2) # define CHECK_PRINTF(a) __attribute__((format (printf, a, a + 1))) #else # define CHECK_PRINTF(a) #endif // Lets us write code that compiles both on Windows and normal platforms #if !defined (__WINDOWS__) typedef int SOCKET; # define closesocket close # define INVALID_SOCKET -1 # define SOCKET_ERROR -1 # define O_BINARY 0 #endif //- Include non-portable header files based on platform.h ------------------- #if defined (HAVE_LINUX_WIRELESS_H) # include #else # if defined (HAVE_NET_IF_H) # include # endif # if defined (HAVE_NET_IF_MEDIA_H) # include # endif #endif #if defined (__WINDOWS__) && !defined (HAVE_LIBUUID) # define HAVE_LIBUUID 1 #endif #if defined (__UTYPE_OSX) && !defined (HAVE_LIBUUID) # define HAVE_LIBUUID 1 #endif #if defined (HAVE_LIBUUID) # if defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) # include # elif defined __UTYPE_HPUX # include # elif defined (__UNIX__) # include # endif #endif // ZMQ compatibility macros #if ZMQ_VERSION_MAJOR == 4 # define ZMQ_POLL_MSEC 1 // zmq_poll is msec #elif ZMQ_VERSION_MAJOR == 3 # define ZMQ_POLL_MSEC 1 // zmq_poll is msec # if ZMQ_VERSION_MINOR < 2 # define zmq_ctx_new zmq_init # endif # define zmq_ctx_term zmq_term #elif ZMQ_VERSION_MAJOR == 2 # define ZMQ_POLL_MSEC 1000 // zmq_poll is usec # define zmq_sendmsg zmq_send // Smooth out 2.x changes # define zmq_recvmsg zmq_recv # define zmq_ctx_new zmq_init # define zmq_ctx_term zmq_term # define zmq_msg_send(m,s,f) zmq_sendmsg ((s),(m),(f)) # define zmq_msg_recv(m,s,f) zmq_recvmsg ((s),(m),(f)) // Older libzmq APIs may be missing some aspects of libzmq v3.0 # ifndef ZMQ_ROUTER # define ZMQ_ROUTER ZMQ_XREP # endif # ifndef ZMQ_DEALER # define ZMQ_DEALER ZMQ_XREQ # endif # ifndef ZMQ_DONTWAIT # define ZMQ_DONTWAIT ZMQ_NOBLOCK # endif # ifndef ZMQ_XSUB # error "please upgrade your libzmq from http://zeromq.org" # endif # if ZMQ_VERSION_MINOR == 0 \ || (ZMQ_VERSION_MINOR == 1 && ZMQ_VERSION_PATCH < 7) # error "CZMQ requires at least libzmq/2.1.7 stable" # endif #endif #endif