Codebase list czmq / upstream/4.1.1
New upstream version 4.1.1 Luca Boccassi 6 years ago
98 changed file(s) with 6935 addition(s) and 3066 deletion(s). Raw diff Collapse all Expand all
1414 set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
1515 # Select flags
1616 SET(CMAKE_C_FLAGS_RELEASE "-O3")
17
18 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)
1719
1820 # Will be used to add flags to pkg-config useful when apps want to statically link
1921 set(pkg_config_libs_private "")
163165 ########################################################################
164166 set(CZMQ_VERSION_MAJOR 4)
165167 set(CZMQ_VERSION_MINOR 1)
166 set(CZMQ_VERSION_PATCH 0)
168 set(CZMQ_VERSION_PATCH 1)
167169 set(CZMQ_VERSION "${CZMQ_VERSION_MAJOR}.${CZMQ_VERSION_MINOR}.${CZMQ_VERSION_PATCH}")
168170 message(STATUS "Detected CZMQ Version - ${CZMQ_VERSION}")
169171
231233 ########################################################################
232234 # library
233235 ########################################################################
236
237
234238 include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include")
235239 set (czmq_sources
236240 src/zactor.c
294298 IF (NOT MSVC)
295299 # avoid building everything twice for shared + static
296300 # only on *nix, as Windows needs different preprocessor defines in static builds
297 add_library (objects OBJECT ${czmq_sources})
298 set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON)
301 add_library (czmq_objects OBJECT ${czmq_sources})
302 set_property(TARGET czmq_objects PROPERTY POSITION_INDEPENDENT_CODE ON)
299303 ENDIF (NOT MSVC)
300304
301305 # shared
303307 IF (MSVC)
304308 add_library(czmq SHARED ${czmq_sources})
305309 ELSE (MSVC)
306 add_library(czmq SHARED $<TARGET_OBJECTS:objects>)
310 add_library(czmq SHARED $<TARGET_OBJECTS:czmq_objects>)
307311 ENDIF (MSVC)
308312
309313 set_target_properties (czmq PROPERTIES
336340 IF (MSVC)
337341 add_library(czmq-static STATIC ${czmq_sources})
338342 ELSE (MSVC)
339 add_library(czmq-static STATIC $<TARGET_OBJECTS:objects>)
343 add_library(czmq-static STATIC $<TARGET_OBJECTS:czmq_objects>)
340344 ENDIF (MSVC)
341345
342346 set_target_properties(czmq-static PROPERTIES
371375 ########################################################################
372376 # pkgconfig
373377 ########################################################################
374 set (VERSION "4.1.0")
378 set (VERSION "4.1.1")
375379 set (prefix "${CMAKE_INSTALL_PREFIX}")
376380 set (exec_prefix "\${prefix}")
377381 set (libdir "\${prefix}/lib${LIB_SUFFIX}")
603607 TARGET distclean
604608 )
605609
610 include(ClangFormat)
611
606612 ########################################################################
607613 # summary
608614 ########################################################################
1818 project_libs = ${libzmq_LIBS} ${uuid_LIBS} ${systemd_LIBS} ${lz4_LIBS}
1919
2020 SUBDIRS = doc
21 SUBDIRS += include
2122 DIST_SUBDIRS = doc
23 DIST_SUBDIRS += include
24
2225 lib_LTLIBRARIES =
2326 bin_PROGRAMS =
2427 noinst_PROGRAMS =
1919 ################################################################################
2020
2121 # Project-local changes to auto-generated content
22
2322
2423
2524
104103 $(srcdir)/Makefile.am $(top_srcdir)/configure \
105104 $(am__configure_deps) $(top_srcdir)/src/platform.h.in \
106105 $(top_srcdir)/src/libczmq.pc.in $(top_srcdir)/config/depcomp \
107 $(dist_api_DATA) $(am__include_HEADERS_DIST) \
108 $(top_srcdir)/config/test-driver AUTHORS NEWS config/compile \
109 config/config.guess config/config.sub config/depcomp \
110 config/install-sh config/missing config/ltmain.sh \
111 $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \
106 $(dist_api_DATA) $(top_srcdir)/config/test-driver AUTHORS NEWS \
107 config/compile config/config.guess config/config.sub \
108 config/depcomp config/install-sh config/missing \
109 config/ltmain.sh $(top_srcdir)/config/compile \
110 $(top_srcdir)/config/config.guess \
112111 $(top_srcdir)/config/config.sub \
113112 $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
114113 $(top_srcdir)/config/missing
115114
116115 # Programs need to link the c++ runtime if everything was compiled statically.
117116 @ENABLE_SHARED_FALSE@am__append_2 = -lstdc++ -lm
118 @ENABLE_DRAFTS_TRUE@am__append_3 = \
119 @ENABLE_DRAFTS_TRUE@ include/zargs.h \
120 @ENABLE_DRAFTS_TRUE@ include/zproc.h \
121 @ENABLE_DRAFTS_TRUE@ include/ztimerset.h \
122 @ENABLE_DRAFTS_TRUE@ include/ztrie.h
123
124 @ENABLE_DRAFTS_TRUE@am__append_4 = src/zargs.c src/zproc.c \
117 @ENABLE_DRAFTS_TRUE@am__append_3 = src/zargs.c src/zproc.c \
125118 @ENABLE_DRAFTS_TRUE@ src/ztimerset.c src/ztrie.c \
126119 @ENABLE_DRAFTS_TRUE@ src/czmq_private_selftest.c
127 @ON_MINGW_TRUE@am__append_5 = \
120 @ON_MINGW_TRUE@am__append_4 = \
128121 @ON_MINGW_TRUE@ -no-undefined \
129122 @ON_MINGW_TRUE@ -avoid-version
130123
131 @ON_CYGWIN_TRUE@am__append_6 = \
124 @ON_CYGWIN_TRUE@am__append_5 = \
132125 @ON_CYGWIN_TRUE@ -no-undefined \
133126 @ON_CYGWIN_TRUE@ -avoid-version
134127
135 @ENABLE_ZMAKECERT_TRUE@am__append_7 = src/zmakecert
136 @ENABLE_ZSP_TRUE@am__append_8 = src/zsp
137 @ENABLE_TEST_RANDOF_TRUE@am__append_9 = src/test_randof
128 @ENABLE_ZMAKECERT_TRUE@am__append_6 = src/zmakecert
129 @ENABLE_ZSP_TRUE@am__append_7 = src/zsp
130 @ENABLE_TEST_RANDOF_TRUE@am__append_8 = src/test_randof
131 @ENABLE_CZMQ_SELFTEST_TRUE@am__append_9 = src/czmq_selftest
138132 @ENABLE_CZMQ_SELFTEST_TRUE@am__append_10 = src/czmq_selftest
139 @ENABLE_CZMQ_SELFTEST_TRUE@am__append_11 = src/czmq_selftest
133 @WITH_CLANG_FORMAT_TRUE@am__append_11 = clang-format-check
140134
141135 # Android-qt requires this special link dependency
142136 @ON_ANDROID_TRUE@am__append_12 = -llog
184178 $(am__cd) "$$dir" && rm -f $$files; }; \
185179 }
186180 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
187 "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" \
188 "$(DESTDIR)$(includedir)"
181 "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)"
189182 LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
190183 am__DEPENDENCIES_1 =
191184 am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
320313 *) (install-info --version) >/dev/null 2>&1;; \
321314 esac
322315 DATA = $(dist_api_DATA) $(pkgconfig_DATA)
323 am__include_HEADERS_DIST = include/czmq_prelude.h include/czmq.h \
324 include/zactor.h include/zarmour.h include/zcert.h \
325 include/zcertstore.h include/zchunk.h include/zclock.h \
326 include/zconfig.h include/zdigest.h include/zdir.h \
327 include/zdir_patch.h include/zfile.h include/zframe.h \
328 include/zhash.h include/zhashx.h include/ziflist.h \
329 include/zlist.h include/zlistx.h include/zloop.h \
330 include/zmsg.h include/zpoller.h include/zsock.h \
331 include/zstr.h include/zsys.h include/zuuid.h include/zauth.h \
332 include/zbeacon.h include/zgossip.h include/zmonitor.h \
333 include/zproxy.h include/zrex.h include/czmq_library.h \
334 include/zargs.h include/zproc.h include/ztimerset.h \
335 include/ztrie.h
336 HEADERS = $(include_HEADERS)
337316 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
338317 distclean-recursive maintainer-clean-recursive
339318 am__recursive_targets = \
595574 CC = @CC@
596575 CCDEPMODE = @CCDEPMODE@
597576 CFLAGS = @CFLAGS@
577 CLANG_FORMAT = @CLANG_FORMAT@
598578 CPP = @CPP@
599579 CPPFLAGS = @CPPFLAGS@
600580 CYGPATH_W = @CYGPATH_W@
650630 SHELL = @SHELL@
651631 STRIP = @STRIP@
652632 VERSION = @VERSION@
633 WITH_CLANG_FORMAT = @WITH_CLANG_FORMAT@
634 WITH_CPPCHECK = @WITH_CPPCHECK@
653635 abs_builddir = @abs_builddir@
654636 abs_srcdir = @abs_srcdir@
655637 abs_top_builddir = @abs_top_builddir@
731713 -I$(srcdir)/include
732714
733715 project_libs = ${libzmq_LIBS} ${uuid_LIBS} ${systemd_LIBS} ${lz4_LIBS}
734 SUBDIRS = doc
735 DIST_SUBDIRS = doc
716 SUBDIRS = doc include
717 DIST_SUBDIRS = doc include
736718 lib_LTLIBRARIES = src/libczmq.la
737719 noinst_LTLIBRARIES =
738720 # Prepare variables that can be populated (appended) in generated Makefiles or
755737 ################################################################################
756738 program_libs = src/libczmq.la ${project_libs} $(am__append_2)
757739 pkgconfig_DATA = src/libczmq.pc
758 include_HEADERS = include/czmq_prelude.h include/czmq.h \
759 include/zactor.h include/zarmour.h include/zcert.h \
760 include/zcertstore.h include/zchunk.h include/zclock.h \
761 include/zconfig.h include/zdigest.h include/zdir.h \
762 include/zdir_patch.h include/zfile.h include/zframe.h \
763 include/zhash.h include/zhashx.h include/ziflist.h \
764 include/zlist.h include/zlistx.h include/zloop.h \
765 include/zmsg.h include/zpoller.h include/zsock.h \
766 include/zstr.h include/zsys.h include/zuuid.h include/zauth.h \
767 include/zbeacon.h include/zgossip.h include/zmonitor.h \
768 include/zproxy.h include/zrex.h include/czmq_library.h \
769 $(am__append_3)
770740 src_libczmq_la_SOURCES = src/zactor.c src/zarmour.c src/zcert.c \
771741 src/zcertstore.c src/zchunk.c src/zclock.c src/zconfig.c \
772742 src/zdigest.c src/zdir.c src/zdir_patch.c src/zfile.c \
779749 src/zhash_primes.inc src/foreign/sha1/sha1.inc_c \
780750 src/foreign/sha1/sha1.h src/foreign/slre/slre.inc_c \
781751 src/foreign/slre/slre.h src/foreign/slre/readme.txt \
782 src/platform.h $(am__append_4)
752 src/platform.h $(am__append_3)
783753 src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS}
784754 src_libczmq_la_LDFLAGS = -version-info @LTVER@ \
785 $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_5) $(am__append_6)
755 $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_4) $(am__append_5)
786756 src_libczmq_la_LIBADD = ${project_libs} $(am__append_12)
787757 @ENABLE_ZMAKECERT_TRUE@src_zmakecert_CPPFLAGS = ${AM_CPPFLAGS}
788758 @ENABLE_ZMAKECERT_TRUE@src_zmakecert_LDADD = ${program_libs}
804774 # Install api files into /usr/local/share/zproject
805775 apidir = @datadir@/zproject/czmq
806776 dist_api_DATA = \
777 api/python_cffi.slurp \
807778 api/zactor.api \
808779 api/zargs.api \
809780 api/zarmour.api \
848819 # The RW directory will be automatically wiped by "make distclean".
849820 SELFTEST_DIR_RO = src/selftest-ro
850821 SELFTEST_DIR_RW = src/selftest-rw
822
823 # A series of tests that the codebase and recipes are pretty, easy
824 # to maintain and with predictable behavior. These generally are not
825 # expected to directly expose functional issues in the code, but
826 # still - there can be many reasons for failing such tests, and
827 # many lurking issues uncoverable by making code stylish again.
828 CHECK_STYLE_DEPS = check-gitignore $(am__append_11)
829 @WITH_CLANG_FORMAT_TRUE@ALL_SOURCE_FILES = $(wildcard \
830 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.c \
831 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.cc \
832 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.cpp \
833 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.h \
834 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.hpp \
835 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.c \
836 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.cc \
837 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.cpp \
838 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.h \
839 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.hpp \
840 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.c \
841 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.cc \
842 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.cpp \
843 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.h \
844 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.hpp \
845 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.c \
846 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.cc \
847 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.cpp \
848 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.h \
849 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.hpp \
850 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/include/*.h \
851 @WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/include/*.hpp \
852 @WITH_CLANG_FORMAT_TRUE@ )
853
851854 all: all-recursive
852855
853856 .SUFFIXES:
15551558 @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
15561559 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
15571560 dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
1558 install-includeHEADERS: $(include_HEADERS)
1559 @$(NORMAL_INSTALL)
1560 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
1561 if test -n "$$list"; then \
1562 echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
1563 $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
1564 fi; \
1565 for p in $$list; do \
1566 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
1567 echo "$$d$$p"; \
1568 done | $(am__base_list) | \
1569 while read files; do \
1570 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
1571 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
1572 done
1573
1574 uninstall-includeHEADERS:
1575 @$(NORMAL_UNINSTALL)
1576 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
1577 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
1578 dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
15791561
15801562 # This directory's subdirectories are mostly independent; you can cd
15811563 # into them and run 'make' without going through this Makefile.
20302012 $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
20312013 $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local
20322014 check: check-recursive
2033 all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS)
2015 all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA)
20342016 install-binPROGRAMS: install-libLTLIBRARIES
20352017
20362018 installdirs: installdirs-recursive
20372019 installdirs-am:
2038 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \
2020 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)"; do \
20392021 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
20402022 done
20412023 install: install-recursive
21002082
21012083 info-am:
21022084
2103 install-data-am: install-dist_apiDATA install-includeHEADERS \
2104 install-pkgconfigDATA
2085 install-data-am: install-dist_apiDATA install-pkgconfigDATA
21052086
21062087 install-dvi: install-dvi-recursive
21072088
21502131 ps-am:
21512132
21522133 uninstall-am: uninstall-binPROGRAMS uninstall-dist_apiDATA \
2153 uninstall-includeHEADERS uninstall-libLTLIBRARIES \
2154 uninstall-pkgconfigDATA
2134 uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
21552135
21562136 .MAKE: $(am__recursive_targets) check-am install-am install-strip
21572137
21682148 info-am install install-am install-binPROGRAMS install-data \
21692149 install-data-am install-dist_apiDATA install-dvi \
21702150 install-dvi-am install-exec install-exec-am install-html \
2171 install-html-am install-includeHEADERS install-info \
2172 install-info-am install-libLTLIBRARIES install-man install-pdf \
2173 install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
2174 install-strip installcheck installcheck-am installdirs \
2175 installdirs-am maintainer-clean maintainer-clean-generic \
2176 mostlyclean mostlyclean-compile mostlyclean-generic \
2177 mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \
2178 uninstall uninstall-am uninstall-binPROGRAMS \
2179 uninstall-dist_apiDATA uninstall-includeHEADERS \
2151 install-html-am install-info install-info-am \
2152 install-libLTLIBRARIES install-man install-pdf install-pdf-am \
2153 install-pkgconfigDATA install-ps install-ps-am install-strip \
2154 installcheck installcheck-am installdirs installdirs-am \
2155 maintainer-clean maintainer-clean-generic mostlyclean \
2156 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
2157 pdf pdf-am ps ps-am recheck tags tags-am uninstall \
2158 uninstall-am uninstall-binPROGRAMS uninstall-dist_apiDATA \
21802159 uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
21812160
21822161
23082287 @WITH_GCOV_FALSE@coverage: src/czmq_selftest
23092288 @WITH_GCOV_FALSE@ @echo "call make clean && configure --with-gcov to enable code coverage"
23102289 @WITH_GCOV_FALSE@ @exit 1
2290 check-style: $(CHECK_STYLE_DEPS)
2291
2292 # Check if any sources need to be fixed, report the filenames and an error code
2293 @WITH_CLANG_FORMAT_TRUE@clang-format-check: $(ALL_SOURCE_FILES)
2294 @WITH_CLANG_FORMAT_TRUE@ @if test -z "$(CLANG_FORMAT)" ; then \
2295 @WITH_CLANG_FORMAT_TRUE@ echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \
2296 @WITH_CLANG_FORMAT_TRUE@ exit 1 ; \
2297 @WITH_CLANG_FORMAT_TRUE@ fi
2298 @WITH_CLANG_FORMAT_TRUE@ @FAILED=0 ; IFS=";" ; IDS="`printf '\n\b'`" ; export IFS IDS; \
2299 @WITH_CLANG_FORMAT_TRUE@ for FILE in $(ALL_SOURCE_FILES) ; do \
2300 @WITH_CLANG_FORMAT_TRUE@ test -s $$FILE || continue ; \
2301 @WITH_CLANG_FORMAT_TRUE@ $(CLANG_FORMAT) -style=file -output-replacements-xml "$$FILE" | grep "<replacement " >/dev/null && \
2302 @WITH_CLANG_FORMAT_TRUE@ { echo "$$FILE is not correctly formatted" >&2 ; FAILED=1; } ; \
2303 @WITH_CLANG_FORMAT_TRUE@ done; \
2304 @WITH_CLANG_FORMAT_TRUE@ if test "$$FAILED" != 0 ; then \
2305 @WITH_CLANG_FORMAT_TRUE@ exit 1 ; \
2306 @WITH_CLANG_FORMAT_TRUE@ fi
2307
2308 # Change source formatting
2309 @WITH_CLANG_FORMAT_TRUE@clang-format: $(ALL_SOURCE_FILES)
2310 @WITH_CLANG_FORMAT_TRUE@ @if test -z "$(CLANG_FORMAT)" ; then \
2311 @WITH_CLANG_FORMAT_TRUE@ echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \
2312 @WITH_CLANG_FORMAT_TRUE@ exit 1 ; \
2313 @WITH_CLANG_FORMAT_TRUE@ fi
2314 @WITH_CLANG_FORMAT_TRUE@ $(CLANG_FORMAT) -style=file -i $(ALL_SOURCE_FILES)
2315
2316 # Change source formatting AND report the diff
2317 @WITH_CLANG_FORMAT_TRUE@clang-format-diff: clang-format
2318 @WITH_CLANG_FORMAT_TRUE@ git diff $(ALL_SOURCE_FILES)
2319
2320 # A destructive (will change code in workspace) but informative check; this is
2321 # primarily intended for CI temporary workspaces where mutilation is acceptable.
2322 # The envvar/makearg CI_REQUIRE_GOOD_CLANG_FORMAT manages if this test is fatal.
2323 @WITH_CLANG_FORMAT_TRUE@clang-format-check-CI:
2324 @WITH_CLANG_FORMAT_TRUE@ @echo "CI-checking code style ..." >&2
2325 @WITH_CLANG_FORMAT_TRUE@ @if $(MAKE) clang-format-check ; then \
2326 @WITH_CLANG_FORMAT_TRUE@ echo "SUCCESS : Style checks have passed" >&2 ; \
2327 @WITH_CLANG_FORMAT_TRUE@ else \
2328 @WITH_CLANG_FORMAT_TRUE@ echo "" >&2 ; \
2329 @WITH_CLANG_FORMAT_TRUE@ if test -n "$(CLANG_FORMAT)" ; then \
2330 @WITH_CLANG_FORMAT_TRUE@ echo "Style mismatches were found by clang-format; detailing below:" >&2 ; \
2331 @WITH_CLANG_FORMAT_TRUE@ $(MAKE) VERBOSE=1 clang-format-diff ; \
2332 @WITH_CLANG_FORMAT_TRUE@ fi ; \
2333 @WITH_CLANG_FORMAT_TRUE@ if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \
2334 @WITH_CLANG_FORMAT_TRUE@ echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \
2335 @WITH_CLANG_FORMAT_TRUE@ exit 1 ; \
2336 @WITH_CLANG_FORMAT_TRUE@ fi ; \
2337 @WITH_CLANG_FORMAT_TRUE@ echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 ; \
2338 @WITH_CLANG_FORMAT_TRUE@ fi
2339
2340 @WITH_CLANG_FORMAT_FALSE@clang-format clang-format-check clang-format-diff:
2341 @WITH_CLANG_FORMAT_FALSE@ @echo "Install the clang-format program, reconfigure and re-run this request"
2342 @WITH_CLANG_FORMAT_FALSE@ @exit 1
2343
2344 @WITH_CLANG_FORMAT_FALSE@clang-format-check-CI:
2345 @WITH_CLANG_FORMAT_FALSE@ @echo "Install the clang-format program, reconfigure and re-run this request"
2346 @WITH_CLANG_FORMAT_FALSE@ @if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \
2347 @WITH_CLANG_FORMAT_FALSE@ echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \
2348 @WITH_CLANG_FORMAT_FALSE@ exit 1 ; \
2349 @WITH_CLANG_FORMAT_FALSE@ fi ; \
2350 @WITH_CLANG_FORMAT_FALSE@ echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2
2351
2352 # Note: analysis is not a target executed by default, so there is no
2353 # safety-net for the "cppcheck.xml" recipe; there is one for the wrapper.
2354 # A developer is expected to install tools in build environment, if needed.
2355 # The results can be used to produce some statistics how project quality
2356 # changes over many builds (with a relevant Jenkins plugin, for example).
2357 @WITH_CPPCHECK_TRUE@cppcheck: cppcheck.xml
2358 @WITH_CPPCHECK_FALSE@cppcheck:
2359 @WITH_CPPCHECK_FALSE@ @echo "NOT ENABLED: cppcheck static analysis. Please install the toolkit and reconfigure, and/or make cppcheck.xml directly."
2360
2361 cppcheck.xml:
2362 @echo "Performing cppcheck static analysis..."
2363 cppcheck --enable=all --inconclusive --xml --xml-version=2 . 2>"$@"
2364 @echo "The cppcheck static analysis is done"
2365
2366 # Note: this recipe tests that the Git-based workspace reports no changed
2367 # or untracked files - meaning there are no unexpected behaviors in the
2368 # recipes (when checking after a build), and nothing was missed while
2369 # updating the project structure (when checking in the midst of development
2370 # or after regenerating the zproject skeletons), for example. For best
2371 # results, developers are advised to also run this after executing their
2372 # tests, to make sure they are stateless and clean as well. Caller may
2373 # export envvar (or pass make argument) CI_REQUIRE_GOOD_GITIGNORE=false
2374 # to explicitly disable fatality of this check, while still logging it.
2375
2376 # This recipe is "stateless" by itself, not causing any workspace changes:
2377 check-gitignore:
2378 @(if which git >/dev/null 2>&1 ; then \
2379 RES=0; \
2380 echo "Checking for untracked and not-ignored files in the workspace (should have no output below)..."; \
2381 git status -s | egrep '^\?\? ' && RES=1 ; \
2382 echo "Checking for modified tracked files in the workspace (should have no output below)..."; \
2383 git status -s | egrep '^ *M ' && RES=1 && git diff | cat ; \
2384 if [ "$$RES" = 0 ]; then \
2385 echo "PASS: $@"; exit 0 ; \
2386 else \
2387 if [ x"$(CI_REQUIRE_GOOD_GITIGNORE)" = xfalse ] ; then \
2388 echo "WARNING: $@ found newly changed or untracked and not-ignored files (not a test failure due to CI_REQUIRE_GOOD_GITIGNORE==false)"; exit 0 ; \
2389 fi; \
2390 echo "FAIL: $@ (see workspace checks above)"; exit 1; \
2391 fi; \
2392 else \
2393 echo "SKIP: $@ (no git)"; exit 0 ; \
2394 fi )
2395
2396 # This calls the recipe above after building the project products and
2397 # the selftest binary, and preparing the workspace for self-testing:
2398 check-gitignore-all: all src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
2399 $@$(MAKE) check-gitignore
23112400
23122401 ################################################################################
23132402 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
23142403 # Read the zproject/README.md for information about making permanent changes. #
23152404 ################################################################################
23162405
2406 # Make sure there is the helper utility for the zproc tests
2407 @ENABLE_ZSP_TRUE@coverage \
2408 @ENABLE_ZSP_TRUE@ check-local check-verbose \
2409 @ENABLE_ZSP_TRUE@ memcheck memcheck-verbose \
2410 @ENABLE_ZSP_TRUE@ debug debug-verbose \
2411 @ENABLE_ZSP_TRUE@ callcheck callcheck-verbose \
2412 @ENABLE_ZSP_TRUE@ animate animate-verbose \
2413 @ENABLE_ZSP_TRUE@ : src/zsp
2414
23172415 check-py: src/libczmq.la
23182416 $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py
23192417
0 CZMQ version 4.1.1 stable, released on 2018/03/22
1 =================================================
2
3 * New DRAFT APIs have been added to the zsys class to get and set
4 the zsys_interrupted global variable:
5 - zsys_is_interrupted
6 - zsys_set_interrupted
7 The following DRAFT APIs wrap a new libzmq context API (minimum
8 libzmq version with DRAFTs enabled required: 4.2.4):
9 - zsys_set_zero_copy_recv
10 - zsys_zero_copy_recv
11 See zsys manpage for more info.
12
13 * New DRAFT APIs have been added to the zproc class to set and get
14 the command line arguments string:
15 - zproc_args
16 - zproc_set_argsx
17 The zproc_set_args and zproc_set_env DRAFT APIs have had their
18 signature changed.
19 See the zproc manpage for more details.
20
21 * Existing DRAFT APIs have been deleted from to the zproc class as they
22 are redundant and already offered by zsys:
23 - zproc_log_debug
24 - zproc_log_info
25 - zproc_log_notice
26 - zproc_log_warning
27 - zproc_log_error
28 - zproc_set_log_system
29 - zproc_set_log_sender
30 - zproc_set_log_ident
31 - zproc_biface
32 - zproc_set_biface
33 - zproc_set_max_sockets
34 - zproc_set_io_threads
35 - zproc_run_as
36 - zproc_daemonize
37 - zproc_hostname
38 - zproc_has_curve
39 - zproc_interrupted
40 - zproc_czmq_version
41
42 * Exising DRAFT APIs to create DRAFT sockets will now return ENOTSUP
43 instead of EINVAL when libzmq does not support the socket type:
44 - zsock_new_server
45 - zsock_new_client
46 - zsock_new_radio
47 - zsock_new_dish
48 - zsock_new_scatter
49 - zsock_new_gather
50 - zsock_join
51 - zsock_leave
52
53 * Fixed #1828 - fix build on GNU/Hurd
54
55 * Fixed #1829 - fix build on FreeBSD 10.4 and 11.1
56
57 * Fixed #1840 - implement basic zproc support for Windows
58
59 * Fixed #1847 - fix test segfault when no USER env variable exists
60
61 * Fixed #1848 - fix zsock_resolve when using many thousands of sockets
62
63 * Fixed #1853 - use SIGTERM on Windows as SIGKILL does not exist
64
65 * Fixed #1858 - fix build on MINGGW
66
67 * Fixed #1875 - fix build with GCC 8
68
69 * Fixed #1876 - fix crash in zsys_shutdown with libzmq 4.2.4 built with
70 Tweetnacl
71
072 CZMQ version 4.1.0 stable, released on 2017/12/31
173 =================================================
274
0 ################################################################################
1 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
2 # Read the zproject/README.md for information about making permanent changes. #
3 ################################################################################
4 # Python cffi compatible file slurp
5
6 czmq_cdefs = list ()
7 # Custom setup for czmq
8 czmq_cdefs.append ('''
9 typedef int time_t;
10 typedef int off_t;
11
12 typedef unsigned char byte; // Single unsigned byte = 8 bits
13 typedef unsigned short dbyte; // Double byte = 16 bits
14 typedef unsigned int qbyte; // Quad byte = 32 bits
15 typedef int SOCKET;
16 typedef struct sockaddr_in inaddr_t;
17
18 // -- destroy an item
19 typedef void (czmq_destructor) (void **item);
20 // -- duplicate an item
21 typedef void *(czmq_duplicator) (const void *item);
22 // - compare two items, for sorting
23 typedef int (czmq_comparator) (const void *item1, const void *item2);
24 ''')
25
26 czmq_cdefs.append ('''
27 typedef struct _zsock_t zsock_t;
28 typedef struct _zactor_t zactor_t;
29 typedef struct _zmsg_t zmsg_t;
30 typedef struct _zargs_t zargs_t;
31 typedef struct _zarmour_t zarmour_t;
32 typedef struct _zchunk_t zchunk_t;
33 typedef struct _char_t char_t;
34 typedef struct _zcert_t zcert_t;
35 typedef struct _zlist_t zlist_t;
36 typedef struct _zcertstore_t zcertstore_t;
37 typedef struct _zlistx_t zlistx_t;
38 typedef struct _zframe_t zframe_t;
39 typedef struct _msecs_t msecs_t;
40 typedef struct _zclock_t zclock_t;
41 typedef struct _zconfig_t zconfig_t;
42 typedef struct _zdigest_t zdigest_t;
43 typedef struct _zdir_t zdir_t;
44 typedef struct _zhash_t zhash_t;
45 typedef struct _zfile_t zfile_t;
46 typedef struct _zdir_patch_t zdir_patch_t;
47 typedef struct _zhashx_t zhashx_t;
48 typedef struct _ziflist_t ziflist_t;
49 typedef struct _zloop_t zloop_t;
50 typedef struct _zmq_pollitem_t zmq_pollitem_t;
51 typedef struct _zpoller_t zpoller_t;
52 typedef struct _zproc_t zproc_t;
53 typedef struct _va_list_t va_list_t;
54 typedef struct _socket_t socket_t;
55 typedef struct _zstr_t zstr_t;
56 typedef struct _zsys_t zsys_t;
57 typedef struct _ztimerset_t ztimerset_t;
58 typedef struct _ztrie_t ztrie_t;
59 typedef struct _zuuid_t zuuid_t;
60 // Actors get a pipe and arguments from caller
61 typedef void (zactor_fn) (
62 zsock_t *pipe, void *args);
63
64 // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame.
65 //
66 // An example - to send $KTHXBAI string
67 //
68 // if (zstr_send (self, "$KTHXBAI") == 0)
69 // zsock_wait (self);
70 typedef void (zactor_destructor_fn) (
71 zactor_t *self);
72
73 // Loaders retrieve certificates from an arbitrary source.
74 typedef void (zcertstore_loader) (
75 zcertstore_t *self);
76
77 // Destructor for loader state.
78 typedef void (zcertstore_destructor) (
79 void **self_p);
80
81 //
82 typedef int (zconfig_fct) (
83 zconfig_t *self, void *arg, int level);
84
85 // Callback function for zhash_freefn method
86 typedef void (zhash_free_fn) (
87 void *data);
88
89 // Destroy an item
90 typedef void (zhashx_destructor_fn) (
91 void **item);
92
93 // Duplicate an item
94 typedef void * (zhashx_duplicator_fn) (
95 const void *item);
96
97 // Compare two items, for sorting
98 typedef int (zhashx_comparator_fn) (
99 const void *item1, const void *item2);
100
101 // Destroy an item.
102 typedef void (zhashx_free_fn) (
103 void *data);
104
105 // Hash function for keys.
106 typedef size_t (zhashx_hash_fn) (
107 const void *key);
108
109 // Serializes an item to a longstr.
110 // The caller takes ownership of the newly created object.
111 typedef char * (zhashx_serializer_fn) (
112 const void *item);
113
114 // Deserializes a longstr into an item.
115 // The caller takes ownership of the newly created object.
116 typedef void * (zhashx_deserializer_fn) (
117 const char *item_str);
118
119 // Comparison function e.g. for sorting and removing.
120 typedef int (zlist_compare_fn) (
121 void *item1, void *item2);
122
123 // Callback function for zlist_freefn method
124 typedef void (zlist_free_fn) (
125 void *data);
126
127 // Destroy an item
128 typedef void (zlistx_destructor_fn) (
129 void **item);
130
131 // Duplicate an item
132 typedef void * (zlistx_duplicator_fn) (
133 const void *item);
134
135 // Compare two items, for sorting
136 typedef int (zlistx_comparator_fn) (
137 const void *item1, const void *item2);
138
139 // Callback function for reactor socket activity
140 typedef int (zloop_reader_fn) (
141 zloop_t *loop, zsock_t *reader, void *arg);
142
143 // Callback function for reactor events (low-level)
144 typedef int (zloop_fn) (
145 zloop_t *loop, zmq_pollitem_t *item, void *arg);
146
147 // Callback for reactor timer events
148 typedef int (zloop_timer_fn) (
149 zloop_t *loop, int timer_id, void *arg);
150
151 // Callback for interrupt signal handler
152 typedef void (zsys_handler_fn) (
153 int signal_value);
154
155 // Callback function for timer event.
156 typedef void (ztimerset_fn) (
157 int timer_id, void *arg);
158
159 // Callback function for ztrie_node to destroy node data.
160 typedef void (ztrie_destroy_data_fn) (
161 void **data);
162
163 // CLASS: zactor
164 // Create a new actor passing arbitrary arguments reference.
165 zactor_t *
166 zactor_new (zactor_fn task, void *args);
167
168 // Destroy an actor.
169 void
170 zactor_destroy (zactor_t **self_p);
171
172 // Send a zmsg message to the actor, take ownership of the message
173 // and destroy when it has been sent.
174 int
175 zactor_send (zactor_t *self, zmsg_t **msg_p);
176
177 // Receive a zmsg message from the actor. Returns NULL if the actor
178 // was interrupted before the message could be received, or if there
179 // was a timeout on the actor.
180 zmsg_t *
181 zactor_recv (zactor_t *self);
182
183 // Probe the supplied object, and report if it looks like a zactor_t.
184 bool
185 zactor_is (void *self);
186
187 // Probe the supplied reference. If it looks like a zactor_t instance,
188 // return the underlying libzmq actor handle; else if it looks like
189 // a libzmq actor handle, return the supplied value.
190 void *
191 zactor_resolve (void *self);
192
193 // Return the actor's zsock handle. Use this when you absolutely need
194 // to work with the zsock instance rather than the actor.
195 zsock_t *
196 zactor_sock (zactor_t *self);
197
198 // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM.
199 void
200 zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor);
201
202 // Self test of this class.
203 void
204 zactor_test (bool verbose);
205
206 // CLASS: zargs
207 // Create a new zargs from command line arguments.
208 zargs_t *
209 zargs_new (int argc, char **argv);
210
211 // Destroy zargs instance.
212 void
213 zargs_destroy (zargs_t **self_p);
214
215 // Return program name (argv[0])
216 const char *
217 zargs_progname (zargs_t *self);
218
219 // Return number of positional arguments
220 size_t
221 zargs_arguments (zargs_t *self);
222
223 // Return first positional argument or NULL
224 const char *
225 zargs_first (zargs_t *self);
226
227 // Return next positional argument or NULL
228 const char *
229 zargs_next (zargs_t *self);
230
231 // Return first named parameter value, or NULL if there are no named
232 // parameters, or value for which zargs_param_empty (arg) returns true.
233 const char *
234 zargs_param_first (zargs_t *self);
235
236 // Return next named parameter value, or NULL if there are no named
237 // parameters, or value for which zargs_param_empty (arg) returns true.
238 const char *
239 zargs_param_next (zargs_t *self);
240
241 // Return current parameter name, or NULL if there are no named
242 // parameters.
243 const char *
244 zargs_param_name (zargs_t *self);
245
246 // Return value of named parameter, NULL if no given parameter has
247 // been specified, or special value for wich zargs_param_empty ()
248 // returns true.
249 const char *
250 zargs_param_lookup (zargs_t *self, const char *keys);
251
252 // Return value of named parameter(s), NULL if no given parameter has
253 // been specified, or special value for wich zargs_param_empty ()
254 // returns true.
255 const char *
256 zargs_param_lookupx (zargs_t *self, const char *keys, ...);
257
258 // Returns true if there are --help -h arguments
259 bool
260 zargs_has_help (zargs_t *self);
261
262 // Returns true if parameter did not have a value
263 bool
264 zargs_param_empty (const char *arg);
265
266 // Print an instance of zargs.
267 void
268 zargs_print (zargs_t *self);
269
270 // Self test of this class.
271 void
272 zargs_test (bool verbose);
273
274 // CLASS: zarmour
275 // Create a new zarmour
276 zarmour_t *
277 zarmour_new (void);
278
279 // Destroy the zarmour
280 void
281 zarmour_destroy (zarmour_t **self_p);
282
283 // Encode a stream of bytes into an armoured string. Returns the armoured
284 // string, or NULL if there was insufficient memory available to allocate
285 // a new string.
286 char *
287 zarmour_encode (zarmour_t *self, const byte *data, size_t size);
288
289 // Decode an armoured string into a chunk. The decoded output is
290 // null-terminated, so it may be treated as a string, if that's what
291 // it was prior to encoding.
292 zchunk_t *
293 zarmour_decode (zarmour_t *self, const char *data);
294
295 // Get the mode property.
296 int
297 zarmour_mode (zarmour_t *self);
298
299 // Get printable string for mode.
300 const char *
301 zarmour_mode_str (zarmour_t *self);
302
303 // Set the mode property.
304 void
305 zarmour_set_mode (zarmour_t *self, int mode);
306
307 // Return true if padding is turned on.
308 bool
309 zarmour_pad (zarmour_t *self);
310
311 // Turn padding on or off. Default is on.
312 void
313 zarmour_set_pad (zarmour_t *self, bool pad);
314
315 // Get the padding character.
316 char
317 zarmour_pad_char (zarmour_t *self);
318
319 // Set the padding character.
320 void
321 zarmour_set_pad_char (zarmour_t *self, char pad_char);
322
323 // Return if splitting output into lines is turned on. Default is off.
324 bool
325 zarmour_line_breaks (zarmour_t *self);
326
327 // Turn splitting output into lines on or off.
328 void
329 zarmour_set_line_breaks (zarmour_t *self, bool line_breaks);
330
331 // Get the line length used for splitting lines.
332 size_t
333 zarmour_line_length (zarmour_t *self);
334
335 // Set the line length used for splitting lines.
336 void
337 zarmour_set_line_length (zarmour_t *self, size_t line_length);
338
339 // Print properties of object
340 void
341 zarmour_print (zarmour_t *self);
342
343 // Self test of this class.
344 void
345 zarmour_test (bool verbose);
346
347 // CLASS: zcert
348 // Create and initialize a new certificate in memory
349 zcert_t *
350 zcert_new (void);
351
352 // Accepts public/secret key pair from caller
353 zcert_t *
354 zcert_new_from (const byte *public_key, const byte *secret_key);
355
356 // Accepts public/secret key text pair from caller
357 zcert_t *
358 zcert_new_from_txt (const char *public_txt, const char *secret_txt);
359
360 // Load certificate from file
361 zcert_t *
362 zcert_load (const char *filename);
363
364 // Destroy a certificate in memory
365 void
366 zcert_destroy (zcert_t **self_p);
367
368 // Return public part of key pair as 32-byte binary string
369 const byte *
370 zcert_public_key (zcert_t *self);
371
372 // Return secret part of key pair as 32-byte binary string
373 const byte *
374 zcert_secret_key (zcert_t *self);
375
376 // Return public part of key pair as Z85 armored string
377 const char *
378 zcert_public_txt (zcert_t *self);
379
380 // Return secret part of key pair as Z85 armored string
381 const char *
382 zcert_secret_txt (zcert_t *self);
383
384 // Set certificate metadata from formatted string.
385 void
386 zcert_set_meta (zcert_t *self, const char *name, const char *format, ...);
387
388 // Unset certificate metadata.
389 void
390 zcert_unset_meta (zcert_t *self, const char *name);
391
392 // Get metadata value from certificate; if the metadata value doesn't
393 // exist, returns NULL.
394 const char *
395 zcert_meta (zcert_t *self, const char *name);
396
397 // Get list of metadata fields from certificate. Caller is responsible for
398 // destroying list. Caller should not modify the values of list items.
399 zlist_t *
400 zcert_meta_keys (zcert_t *self);
401
402 // Save full certificate (public + secret) to file for persistent storage
403 // This creates one public file and one secret file (filename + "_secret").
404 int
405 zcert_save (zcert_t *self, const char *filename);
406
407 // Save public certificate only to file for persistent storage
408 int
409 zcert_save_public (zcert_t *self, const char *filename);
410
411 // Save secret certificate only to file for persistent storage
412 int
413 zcert_save_secret (zcert_t *self, const char *filename);
414
415 // Apply certificate to socket, i.e. use for CURVE security on socket.
416 // If certificate was loaded from public file, the secret key will be
417 // undefined, and this certificate will not work successfully.
418 void
419 zcert_apply (zcert_t *self, void *socket);
420
421 // Return copy of certificate; if certificate is NULL or we exhausted
422 // heap memory, returns NULL.
423 zcert_t *
424 zcert_dup (zcert_t *self);
425
426 // Return true if two certificates have the same keys
427 bool
428 zcert_eq (zcert_t *self, zcert_t *compare);
429
430 // Print certificate contents to stdout
431 void
432 zcert_print (zcert_t *self);
433
434 // Self test of this class
435 void
436 zcert_test (bool verbose);
437
438 // CLASS: zcertstore
439 // Create a new certificate store from a disk directory, loading and
440 // indexing all certificates in that location. The directory itself may be
441 // absent, and created later, or modified at any time. The certificate store
442 // is automatically refreshed on any zcertstore_lookup() call. If the
443 // location is specified as NULL, creates a pure-memory store, which you
444 // can work with by inserting certificates at runtime.
445 zcertstore_t *
446 zcertstore_new (const char *location);
447
448 // Destroy a certificate store object in memory. Does not affect anything
449 // stored on disk.
450 void
451 zcertstore_destroy (zcertstore_t **self_p);
452
453 // Override the default disk loader with a custom loader fn.
454 void
455 zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state);
456
457 // Look up certificate by public key, returns zcert_t object if found,
458 // else returns NULL. The public key is provided in Z85 text format.
459 zcert_t *
460 zcertstore_lookup (zcertstore_t *self, const char *public_key);
461
462 // Insert certificate into certificate store in memory. Note that this
463 // does not save the certificate to disk. To do that, use zcert_save()
464 // directly on the certificate. Takes ownership of zcert_t object.
465 void
466 zcertstore_insert (zcertstore_t *self, zcert_t **cert_p);
467
468 // Empty certificate hashtable. This wrapper exists to be friendly to bindings,
469 // which don't usually have access to struct internals.
470 void
471 zcertstore_empty (zcertstore_t *self);
472
473 // Print list of certificates in store to logging facility
474 void
475 zcertstore_print (zcertstore_t *self);
476
477 // Return a list of all the certificates in the store.
478 // The caller takes ownership of the zlistx_t object and is responsible
479 // for destroying it. The caller does not take ownership of the zcert_t
480 // objects.
481 zlistx_t *
482 zcertstore_certs (zcertstore_t *self);
483
484 // Self test of this class
485 void
486 zcertstore_test (bool verbose);
487
488 // CLASS: zchunk
489 // Create a new chunk of the specified size. If you specify the data, it
490 // is copied into the chunk. If you do not specify the data, the chunk is
491 // allocated and left empty, and you can then add data using zchunk_append.
492 zchunk_t *
493 zchunk_new (const void *data, size_t size);
494
495 // Destroy a chunk
496 void
497 zchunk_destroy (zchunk_t **self_p);
498
499 // Resizes chunk max_size as requested; chunk_cur size is set to zero
500 void
501 zchunk_resize (zchunk_t *self, size_t size);
502
503 // Return chunk cur size
504 size_t
505 zchunk_size (zchunk_t *self);
506
507 // Return chunk max size
508 size_t
509 zchunk_max_size (zchunk_t *self);
510
511 // Return chunk data
512 byte *
513 zchunk_data (zchunk_t *self);
514
515 // Set chunk data from user-supplied data; truncate if too large. Data may
516 // be null. Returns actual size of chunk
517 size_t
518 zchunk_set (zchunk_t *self, const void *data, size_t size);
519
520 // Fill chunk data from user-supplied octet
521 size_t
522 zchunk_fill (zchunk_t *self, byte filler, size_t size);
523
524 // Append user-supplied data to chunk, return resulting chunk size. If the
525 // data would exceeded the available space, it is truncated. If you want to
526 // grow the chunk to accommodate new data, use the zchunk_extend method.
527 size_t
528 zchunk_append (zchunk_t *self, const void *data, size_t size);
529
530 // Append user-supplied data to chunk, return resulting chunk size. If the
531 // data would exceeded the available space, the chunk grows in size.
532 size_t
533 zchunk_extend (zchunk_t *self, const void *data, size_t size);
534
535 // Copy as much data from 'source' into the chunk as possible; returns the
536 // new size of chunk. If all data from 'source' is used, returns exhausted
537 // on the source chunk. Source can be consumed as many times as needed until
538 // it is exhausted. If source was already exhausted, does not change chunk.
539 size_t
540 zchunk_consume (zchunk_t *self, zchunk_t *source);
541
542 // Returns true if the chunk was exhausted by consume methods, or if the
543 // chunk has a size of zero.
544 bool
545 zchunk_exhausted (zchunk_t *self);
546
547 // Read chunk from an open file descriptor
548 zchunk_t *
549 zchunk_read (FILE *handle, size_t bytes);
550
551 // Write chunk to an open file descriptor
552 int
553 zchunk_write (zchunk_t *self, FILE *handle);
554
555 // Try to slurp an entire file into a chunk. Will read up to maxsize of
556 // the file. If maxsize is 0, will attempt to read the entire file and
557 // fail with an assertion if that cannot fit into memory. Returns a new
558 // chunk containing the file data, or NULL if the file could not be read.
559 zchunk_t *
560 zchunk_slurp (const char *filename, size_t maxsize);
561
562 // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t
563 // object, or null if there was not enough heap memory. If chunk is null,
564 // returns null.
565 zchunk_t *
566 zchunk_dup (zchunk_t *self);
567
568 // Return chunk data encoded as printable hex string. Caller must free
569 // string when finished with it.
570 char *
571 zchunk_strhex (zchunk_t *self);
572
573 // Return chunk data copied into freshly allocated string
574 // Caller must free string when finished with it.
575 char *
576 zchunk_strdup (zchunk_t *self);
577
578 // Return TRUE if chunk body is equal to string, excluding terminator
579 bool
580 zchunk_streq (zchunk_t *self, const char *string);
581
582 // Transform zchunk into a zframe that can be sent in a message.
583 zframe_t *
584 zchunk_pack (zchunk_t *self);
585
586 // Transform a zframe into a zchunk.
587 zchunk_t *
588 zchunk_unpack (zframe_t *frame);
589
590 // Calculate SHA1 digest for chunk, using zdigest class.
591 const char *
592 zchunk_digest (zchunk_t *self);
593
594 // Dump chunk to FILE stream, for debugging and tracing.
595 void
596 zchunk_fprint (zchunk_t *self, FILE *file);
597
598 // Dump message to stderr, for debugging and tracing.
599 // See zchunk_fprint for details
600 void
601 zchunk_print (zchunk_t *self);
602
603 // Probe the supplied object, and report if it looks like a zchunk_t.
604 bool
605 zchunk_is (void *self);
606
607 // Self test of this class.
608 void
609 zchunk_test (bool verbose);
610
611 // CLASS: zclock
612 // Sleep for a number of milliseconds
613 void
614 zclock_sleep (int msecs);
615
616 // Return current system clock as milliseconds. Note that this clock can
617 // jump backwards (if the system clock is changed) so is unsafe to use for
618 // timers and time offsets. Use zclock_mono for that instead.
619 int64_t
620 zclock_time (void);
621
622 // Return current monotonic clock in milliseconds. Use this when you compute
623 // time offsets. The monotonic clock is not affected by system changes and
624 // so will never be reset backwards, unlike a system clock.
625 int64_t
626 zclock_mono (void);
627
628 // Return current monotonic clock in microseconds. Use this when you compute
629 // time offsets. The monotonic clock is not affected by system changes and
630 // so will never be reset backwards, unlike a system clock.
631 int64_t
632 zclock_usecs (void);
633
634 // Return formatted date/time as fresh string. Free using zstr_free().
635 char *
636 zclock_timestr (void);
637
638 // Self test of this class.
639 void
640 zclock_test (bool verbose);
641
642 // CLASS: zconfig
643 // Create new config item
644 zconfig_t *
645 zconfig_new (const char *name, zconfig_t *parent);
646
647 // Destroy a config item and all its children
648 void
649 zconfig_destroy (zconfig_t **self_p);
650
651 // Load a config tree from a specified ZPL text file; returns a zconfig_t
652 // reference for the root, if the file exists and is readable. Returns NULL
653 // if the file does not exist.
654 zconfig_t *
655 zconfig_load (const char *filename);
656
657 // Equivalent to zconfig_load, taking a format string instead of a fixed
658 // filename.
659 zconfig_t *
660 zconfig_loadf (const char *format, ...);
661
662 // Return name of config item
663 char *
664 zconfig_name (zconfig_t *self);
665
666 // Return value of config item
667 char *
668 zconfig_value (zconfig_t *self);
669
670 // Insert or update configuration key with value
671 void
672 zconfig_put (zconfig_t *self, const char *path, const char *value);
673
674 // Equivalent to zconfig_put, accepting a format specifier and variable
675 // argument list, instead of a single string value.
676 void
677 zconfig_putf (zconfig_t *self, const char *path, const char *format, ...);
678
679 // Get value for config item into a string value; leading slash is optional
680 // and ignored.
681 char *
682 zconfig_get (zconfig_t *self, const char *path, const char *default_value);
683
684 // Set config item name, name may be NULL
685 void
686 zconfig_set_name (zconfig_t *self, const char *name);
687
688 // Set new value for config item. The new value may be a string, a printf
689 // format, or NULL. Note that if string may possibly contain '%', or if it
690 // comes from an insecure source, you must use '%s' as the format, followed
691 // by the string.
692 void
693 zconfig_set_value (zconfig_t *self, const char *format, ...);
694
695 // Find our first child, if any
696 zconfig_t *
697 zconfig_child (zconfig_t *self);
698
699 // Find our first sibling, if any
700 zconfig_t *
701 zconfig_next (zconfig_t *self);
702
703 // Find a config item along a path; leading slash is optional and ignored.
704 zconfig_t *
705 zconfig_locate (zconfig_t *self, const char *path);
706
707 // Locate the last config item at a specified depth
708 zconfig_t *
709 zconfig_at_depth (zconfig_t *self, int level);
710
711 // Execute a callback for each config item in the tree; returns zero if
712 // successful, else -1.
713 int
714 zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg);
715
716 // Add comment to config item before saving to disk. You can add as many
717 // comment lines as you like. If you use a null format, all comments are
718 // deleted.
719 void
720 zconfig_set_comment (zconfig_t *self, const char *format, ...);
721
722 // Return comments of config item, as zlist.
723 zlist_t *
724 zconfig_comments (zconfig_t *self);
725
726 // Save a config tree to a specified ZPL text file, where a filename
727 // "-" means dump to standard output.
728 int
729 zconfig_save (zconfig_t *self, const char *filename);
730
731 // Equivalent to zconfig_save, taking a format string instead of a fixed
732 // filename.
733 int
734 zconfig_savef (zconfig_t *self, const char *format, ...);
735
736 // Report filename used during zconfig_load, or NULL if none
737 const char *
738 zconfig_filename (zconfig_t *self);
739
740 // Reload config tree from same file that it was previously loaded from.
741 // Returns 0 if OK, -1 if there was an error (and then does not change
742 // existing data).
743 int
744 zconfig_reload (zconfig_t **self_p);
745
746 // Load a config tree from a memory chunk
747 zconfig_t *
748 zconfig_chunk_load (zchunk_t *chunk);
749
750 // Save a config tree to a new memory chunk
751 zchunk_t *
752 zconfig_chunk_save (zconfig_t *self);
753
754 // Load a config tree from a null-terminated string
755 zconfig_t *
756 zconfig_str_load (const char *string);
757
758 // Save a config tree to a new null terminated string
759 char *
760 zconfig_str_save (zconfig_t *self);
761
762 // Return true if a configuration tree was loaded from a file and that
763 // file has changed in since the tree was loaded.
764 bool
765 zconfig_has_changed (zconfig_t *self);
766
767 // Destroy subtree (all children)
768 void
769 zconfig_remove_subtree (zconfig_t *self);
770
771 // Destroy node and subtree (all children)
772 void
773 zconfig_remove (zconfig_t **self_p);
774
775 // Print the config file to open stream
776 void
777 zconfig_fprint (zconfig_t *self, FILE *file);
778
779 // Print properties of object
780 void
781 zconfig_print (zconfig_t *self);
782
783 // Self test of this class
784 void
785 zconfig_test (bool verbose);
786
787 // CLASS: zdigest
788 // Constructor - creates new digest object, which you use to build up a
789 // digest by repeatedly calling zdigest_update() on chunks of data.
790 zdigest_t *
791 zdigest_new (void);
792
793 // Destroy a digest object
794 void
795 zdigest_destroy (zdigest_t **self_p);
796
797 // Add buffer into digest calculation
798 void
799 zdigest_update (zdigest_t *self, const byte *buffer, size_t length);
800
801 // Return final digest hash data. If built without crypto support,
802 // returns NULL.
803 const byte *
804 zdigest_data (zdigest_t *self);
805
806 // Return final digest hash size
807 size_t
808 zdigest_size (zdigest_t *self);
809
810 // Return digest as printable hex string; caller should not modify nor
811 // free this string. After calling this, you may not use zdigest_update()
812 // on the same digest. If built without crypto support, returns NULL.
813 char *
814 zdigest_string (zdigest_t *self);
815
816 // Self test of this class.
817 void
818 zdigest_test (bool verbose);
819
820 // CLASS: zdir
821 // Create a new directory item that loads in the full tree of the specified
822 // path, optionally located under some parent path. If parent is "-", then
823 // loads only the top-level directory, and does not use parent as a path.
824 zdir_t *
825 zdir_new (const char *path, const char *parent);
826
827 // Destroy a directory tree and all children it contains.
828 void
829 zdir_destroy (zdir_t **self_p);
830
831 // Return directory path
832 const char *
833 zdir_path (zdir_t *self);
834
835 // Return last modification time for directory.
836 time_t
837 zdir_modified (zdir_t *self);
838
839 // Return total hierarchy size, in bytes of data contained in all files
840 // in the directory tree.
841 off_t
842 zdir_cursize (zdir_t *self);
843
844 // Return directory count
845 size_t
846 zdir_count (zdir_t *self);
847
848 // Returns a sorted list of zfile objects; Each entry in the list is a pointer
849 // to a zfile_t item already allocated in the zdir tree. Do not destroy the
850 // original zdir tree until you are done with this list.
851 zlist_t *
852 zdir_list (zdir_t *self);
853
854 // Remove directory, optionally including all files that it contains, at
855 // all levels. If force is false, will only remove the directory if empty.
856 // If force is true, will remove all files and all subdirectories.
857 void
858 zdir_remove (zdir_t *self, bool force);
859
860 // Calculate differences between two versions of a directory tree.
861 // Returns a list of zdir_patch_t patches. Either older or newer may
862 // be null, indicating the directory is empty/absent. If alias is set,
863 // generates virtual filename (minus path, plus alias).
864 zlist_t *
865 zdir_diff (zdir_t *older, zdir_t *newer, const char *alias);
866
867 // Return full contents of directory as a zdir_patch list.
868 zlist_t *
869 zdir_resync (zdir_t *self, const char *alias);
870
871 // Load directory cache; returns a hash table containing the SHA-1 digests
872 // of every file in the tree. The cache is saved between runs in .cache.
873 zhash_t *
874 zdir_cache (zdir_t *self);
875
876 // Print contents of directory to open stream
877 void
878 zdir_fprint (zdir_t *self, FILE *file, int indent);
879
880 // Print contents of directory to stdout
881 void
882 zdir_print (zdir_t *self, int indent);
883
884 // Create a new zdir_watch actor instance:
885 //
886 // zactor_t *watch = zactor_new (zdir_watch, NULL);
887 //
888 // Destroy zdir_watch instance:
889 //
890 // zactor_destroy (&watch);
891 //
892 // Enable verbose logging of commands and activity:
893 //
894 // zstr_send (watch, "VERBOSE");
895 //
896 // Subscribe to changes to a directory path:
897 //
898 // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path");
899 //
900 // Unsubscribe from changes to a directory path:
901 //
902 // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path");
903 //
904 // Receive directory changes:
905 // zsock_recv (watch, "sp", &path, &patches);
906 //
907 // // Delete the received data.
908 // free (path);
909 // zlist_destroy (&patches);
910 void
911 zdir_watch (zsock_t *pipe, void *unused);
912
913 // Self test of this class.
914 void
915 zdir_test (bool verbose);
916
917 // CLASS: zdir_patch
918 // Create new patch
919 zdir_patch_t *
920 zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias);
921
922 // Destroy a patch
923 void
924 zdir_patch_destroy (zdir_patch_t **self_p);
925
926 // Create copy of a patch. If the patch is null, or memory was exhausted,
927 // returns null.
928 zdir_patch_t *
929 zdir_patch_dup (zdir_patch_t *self);
930
931 // Return patch file directory path
932 const char *
933 zdir_patch_path (zdir_patch_t *self);
934
935 // Return patch file item
936 zfile_t *
937 zdir_patch_file (zdir_patch_t *self);
938
939 // Return operation
940 int
941 zdir_patch_op (zdir_patch_t *self);
942
943 // Return patch virtual file path
944 const char *
945 zdir_patch_vpath (zdir_patch_t *self);
946
947 // Calculate hash digest for file (create only)
948 void
949 zdir_patch_digest_set (zdir_patch_t *self);
950
951 // Return hash digest for patch file
952 const char *
953 zdir_patch_digest (zdir_patch_t *self);
954
955 // Self test of this class.
956 void
957 zdir_patch_test (bool verbose);
958
959 // CLASS: zfile
960 // If file exists, populates properties. CZMQ supports portable symbolic
961 // links, which are files with the extension ".ln". A symbolic link is a
962 // text file containing one line, the filename of a target file. Reading
963 // data from the symbolic link actually reads from the target file. Path
964 // may be NULL, in which case it is not used.
965 zfile_t *
966 zfile_new (const char *path, const char *name);
967
968 // Create new temporary file for writing via tmpfile. File is automaticaly
969 // deleted on destroy
970 zfile_t *
971 zfile_tmp (void);
972
973 // Destroy a file item
974 void
975 zfile_destroy (zfile_t **self_p);
976
977 // Duplicate a file item, returns a newly constructed item. If the file
978 // is null, or memory was exhausted, returns null.
979 zfile_t *
980 zfile_dup (zfile_t *self);
981
982 // Return file name, remove path if provided
983 const char *
984 zfile_filename (zfile_t *self, const char *path);
985
986 // Refresh file properties from disk; this is not done automatically
987 // on access methods, otherwise it is not possible to compare directory
988 // snapshots.
989 void
990 zfile_restat (zfile_t *self);
991
992 // Return when the file was last modified. If you want this to reflect the
993 // current situation, call zfile_restat before checking this property.
994 time_t
995 zfile_modified (zfile_t *self);
996
997 // Return the last-known size of the file. If you want this to reflect the
998 // current situation, call zfile_restat before checking this property.
999 off_t
1000 zfile_cursize (zfile_t *self);
1001
1002 // Return true if the file is a directory. If you want this to reflect
1003 // any external changes, call zfile_restat before checking this property.
1004 bool
1005 zfile_is_directory (zfile_t *self);
1006
1007 // Return true if the file is a regular file. If you want this to reflect
1008 // any external changes, call zfile_restat before checking this property.
1009 bool
1010 zfile_is_regular (zfile_t *self);
1011
1012 // Return true if the file is readable by this process. If you want this to
1013 // reflect any external changes, call zfile_restat before checking this
1014 // property.
1015 bool
1016 zfile_is_readable (zfile_t *self);
1017
1018 // Return true if the file is writeable by this process. If you want this
1019 // to reflect any external changes, call zfile_restat before checking this
1020 // property.
1021 bool
1022 zfile_is_writeable (zfile_t *self);
1023
1024 // Check if file has stopped changing and can be safely processed.
1025 // Updates the file statistics from disk at every call.
1026 bool
1027 zfile_is_stable (zfile_t *self);
1028
1029 // Return true if the file was changed on disk since the zfile_t object
1030 // was created, or the last zfile_restat() call made on it.
1031 bool
1032 zfile_has_changed (zfile_t *self);
1033
1034 // Remove the file from disk
1035 void
1036 zfile_remove (zfile_t *self);
1037
1038 // Open file for reading
1039 // Returns 0 if OK, -1 if not found or not accessible
1040 int
1041 zfile_input (zfile_t *self);
1042
1043 // Open file for writing, creating directory if needed
1044 // File is created if necessary; chunks can be written to file at any
1045 // location. Returns 0 if OK, -1 if error.
1046 int
1047 zfile_output (zfile_t *self);
1048
1049 // Read chunk from file at specified position. If this was the last chunk,
1050 // sets the eof property. Returns a null chunk in case of error.
1051 zchunk_t *
1052 zfile_read (zfile_t *self, size_t bytes, off_t offset);
1053
1054 // Returns true if zfile_read() just read the last chunk in the file.
1055 bool
1056 zfile_eof (zfile_t *self);
1057
1058 // Write chunk to file at specified position
1059 // Return 0 if OK, else -1
1060 int
1061 zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset);
1062
1063 // Read next line of text from file. Returns a pointer to the text line,
1064 // or NULL if there was nothing more to read from the file.
1065 const char *
1066 zfile_readln (zfile_t *self);
1067
1068 // Close file, if open
1069 void
1070 zfile_close (zfile_t *self);
1071
1072 // Return file handle, if opened
1073 FILE *
1074 zfile_handle (zfile_t *self);
1075
1076 // Calculate SHA1 digest for file, using zdigest class.
1077 const char *
1078 zfile_digest (zfile_t *self);
1079
1080 // Self test of this class.
1081 void
1082 zfile_test (bool verbose);
1083
1084 // CLASS: zframe
1085 // Create a new frame. If size is not null, allocates the frame data
1086 // to the specified size. If additionally, data is not null, copies
1087 // size octets from the specified data into the frame body.
1088 zframe_t *
1089 zframe_new (const void *data, size_t size);
1090
1091 // Destroy a frame
1092 void
1093 zframe_destroy (zframe_t **self_p);
1094
1095 // Create an empty (zero-sized) frame
1096 zframe_t *
1097 zframe_new_empty (void);
1098
1099 // Create a frame with a specified string content.
1100 zframe_t *
1101 zframe_from (const char *string);
1102
1103 // Receive frame from socket, returns zframe_t object or NULL if the recv
1104 // was interrupted. Does a blocking recv, if you want to not block then use
1105 // zpoller or zloop.
1106 zframe_t *
1107 zframe_recv (void *source);
1108
1109 // Send a frame to a socket, destroy frame after sending.
1110 // Return -1 on error, 0 on success.
1111 int
1112 zframe_send (zframe_t **self_p, void *dest, int flags);
1113
1114 // Return number of bytes in frame data
1115 size_t
1116 zframe_size (zframe_t *self);
1117
1118 // Return address of frame data
1119 byte *
1120 zframe_data (zframe_t *self);
1121
1122 // Return meta data property for frame
1123 // The caller shall not modify or free the returned value, which shall be
1124 // owned by the message.
1125 const char *
1126 zframe_meta (zframe_t *self, const char *property);
1127
1128 // Create a new frame that duplicates an existing frame. If frame is null,
1129 // or memory was exhausted, returns null.
1130 zframe_t *
1131 zframe_dup (zframe_t *self);
1132
1133 // Return frame data encoded as printable hex string, useful for 0MQ UUIDs.
1134 // Caller must free string when finished with it.
1135 char *
1136 zframe_strhex (zframe_t *self);
1137
1138 // Return frame data copied into freshly allocated string
1139 // Caller must free string when finished with it.
1140 char *
1141 zframe_strdup (zframe_t *self);
1142
1143 // Return TRUE if frame body is equal to string, excluding terminator
1144 bool
1145 zframe_streq (zframe_t *self, const char *string);
1146
1147 // Return frame MORE indicator (1 or 0), set when reading frame from socket
1148 // or by the zframe_set_more() method
1149 int
1150 zframe_more (zframe_t *self);
1151
1152 // Set frame MORE indicator (1 or 0). Note this is NOT used when sending
1153 // frame to socket, you have to specify flag explicitly.
1154 void
1155 zframe_set_more (zframe_t *self, int more);
1156
1157 // Return frame routing ID, if the frame came from a ZMQ_SERVER socket.
1158 // Else returns zero.
1159 uint32_t
1160 zframe_routing_id (zframe_t *self);
1161
1162 // Set routing ID on frame. This is used if/when the frame is sent to a
1163 // ZMQ_SERVER socket.
1164 void
1165 zframe_set_routing_id (zframe_t *self, uint32_t routing_id);
1166
1167 // Return frame group of radio-dish pattern.
1168 const char *
1169 zframe_group (zframe_t *self);
1170
1171 // Set group on frame. This is used if/when the frame is sent to a
1172 // ZMQ_RADIO socket.
1173 // Return -1 on error, 0 on success.
1174 int
1175 zframe_set_group (zframe_t *self, const char *group);
1176
1177 // Return TRUE if two frames have identical size and data
1178 // If either frame is NULL, equality is always false.
1179 bool
1180 zframe_eq (zframe_t *self, zframe_t *other);
1181
1182 // Set new contents for frame
1183 void
1184 zframe_reset (zframe_t *self, const void *data, size_t size);
1185
1186 // Send message to zsys log sink (may be stdout, or system facility as
1187 // configured by zsys_set_logstream). Prefix shows before frame, if not null.
1188 void
1189 zframe_print (zframe_t *self, const char *prefix);
1190
1191 // Probe the supplied object, and report if it looks like a zframe_t.
1192 bool
1193 zframe_is (void *self);
1194
1195 // Self test of this class.
1196 void
1197 zframe_test (bool verbose);
1198
1199 // CLASS: zhash
1200 // Create a new, empty hash container
1201 zhash_t *
1202 zhash_new (void);
1203
1204 // Destroy a hash container and all items in it
1205 void
1206 zhash_destroy (zhash_t **self_p);
1207
1208 // Unpack binary frame into a new hash table. Packed data must follow format
1209 // defined by zhash_pack. Hash table is set to autofree. An empty frame
1210 // unpacks to an empty hash table.
1211 zhash_t *
1212 zhash_unpack (zframe_t *frame);
1213
1214 // Insert item into hash table with specified key and item.
1215 // If key is already present returns -1 and leaves existing item unchanged
1216 // Returns 0 on success.
1217 int
1218 zhash_insert (zhash_t *self, const char *key, void *item);
1219
1220 // Update item into hash table with specified key and item.
1221 // If key is already present, destroys old item and inserts new one.
1222 // Use free_fn method to ensure deallocator is properly called on item.
1223 void
1224 zhash_update (zhash_t *self, const char *key, void *item);
1225
1226 // Remove an item specified by key from the hash table. If there was no such
1227 // item, this function does nothing.
1228 void
1229 zhash_delete (zhash_t *self, const char *key);
1230
1231 // Return the item at the specified key, or null
1232 void *
1233 zhash_lookup (zhash_t *self, const char *key);
1234
1235 // Reindexes an item from an old key to a new key. If there was no such
1236 // item, does nothing. Returns 0 if successful, else -1.
1237 int
1238 zhash_rename (zhash_t *self, const char *old_key, const char *new_key);
1239
1240 // Set a free function for the specified hash table item. When the item is
1241 // destroyed, the free function, if any, is called on that item.
1242 // Use this when hash items are dynamically allocated, to ensure that
1243 // you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
1244 // Returns the item, or NULL if there is no such item.
1245 void *
1246 zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn);
1247
1248 // Return the number of keys/items in the hash table
1249 size_t
1250 zhash_size (zhash_t *self);
1251
1252 // Make copy of hash table; if supplied table is null, returns null.
1253 // Does not copy items themselves. Rebuilds new table so may be slow on
1254 // very large tables. NOTE: only works with item values that are strings
1255 // since there's no other way to know how to duplicate the item value.
1256 zhash_t *
1257 zhash_dup (zhash_t *self);
1258
1259 // Return keys for items in table
1260 zlist_t *
1261 zhash_keys (zhash_t *self);
1262
1263 // Simple iterator; returns first item in hash table, in no given order,
1264 // or NULL if the table is empty. This method is simpler to use than the
1265 // foreach() method, which is deprecated. To access the key for this item
1266 // use zhash_cursor(). NOTE: do NOT modify the table while iterating.
1267 void *
1268 zhash_first (zhash_t *self);
1269
1270 // Simple iterator; returns next item in hash table, in no given order,
1271 // or NULL if the last item was already returned. Use this together with
1272 // zhash_first() to process all items in a hash table. If you need the
1273 // items in sorted order, use zhash_keys() and then zlist_sort(). To
1274 // access the key for this item use zhash_cursor(). NOTE: do NOT modify
1275 // the table while iterating.
1276 void *
1277 zhash_next (zhash_t *self);
1278
1279 // After a successful first/next method, returns the key for the item that
1280 // was returned. This is a constant string that you may not modify or
1281 // deallocate, and which lasts as long as the item in the hash. After an
1282 // unsuccessful first/next, returns NULL.
1283 const char *
1284 zhash_cursor (zhash_t *self);
1285
1286 // Add a comment to hash table before saving to disk. You can add as many
1287 // comment lines as you like. These comment lines are discarded when loading
1288 // the file. If you use a null format, all comments are deleted.
1289 void
1290 zhash_comment (zhash_t *self, const char *format, ...);
1291
1292 // Serialize hash table to a binary frame that can be sent in a message.
1293 // The packed format is compatible with the 'dictionary' type defined in
1294 // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto:
1295 //
1296 // ; A list of name/value pairs
1297 // dictionary = dict-count *( dict-name dict-value )
1298 // dict-count = number-4
1299 // dict-value = longstr
1300 // dict-name = string
1301 //
1302 // ; Strings are always length + text contents
1303 // longstr = number-4 *VCHAR
1304 // string = number-1 *VCHAR
1305 //
1306 // ; Numbers are unsigned integers in network byte order
1307 // number-1 = 1OCTET
1308 // number-4 = 4OCTET
1309 //
1310 // Comments are not included in the packed data. Item values MUST be
1311 // strings.
1312 zframe_t *
1313 zhash_pack (zhash_t *self);
1314
1315 // Save hash table to a text file in name=value format. Hash values must be
1316 // printable strings; keys may not contain '=' character. Returns 0 if OK,
1317 // else -1 if a file error occurred.
1318 int
1319 zhash_save (zhash_t *self, const char *filename);
1320
1321 // Load hash table from a text file in name=value format; hash table must
1322 // already exist. Hash values must printable strings; keys may not contain
1323 // '=' character. Returns 0 if OK, else -1 if a file was not readable.
1324 int
1325 zhash_load (zhash_t *self, const char *filename);
1326
1327 // When a hash table was loaded from a file by zhash_load, this method will
1328 // reload the file if it has been modified since, and is "stable", i.e. not
1329 // still changing. Returns 0 if OK, -1 if there was an error reloading the
1330 // file.
1331 int
1332 zhash_refresh (zhash_t *self);
1333
1334 // Set hash for automatic value destruction. Note that this assumes that
1335 // values are NULL-terminated strings. Do not use with different types.
1336 void
1337 zhash_autofree (zhash_t *self);
1338
1339 // Self test of this class.
1340 void
1341 zhash_test (bool verbose);
1342
1343 // CLASS: zhashx
1344 // Create a new, empty hash container
1345 zhashx_t *
1346 zhashx_new (void);
1347
1348 // Destroy a hash container and all items in it
1349 void
1350 zhashx_destroy (zhashx_t **self_p);
1351
1352 // Unpack binary frame into a new hash table. Packed data must follow format
1353 // defined by zhashx_pack. Hash table is set to autofree. An empty frame
1354 // unpacks to an empty hash table.
1355 zhashx_t *
1356 zhashx_unpack (zframe_t *frame);
1357
1358 // Same as unpack but uses a user-defined deserializer function to convert
1359 // a longstr back into item format.
1360 zhashx_t *
1361 zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer);
1362
1363 // Insert item into hash table with specified key and item.
1364 // If key is already present returns -1 and leaves existing item unchanged
1365 // Returns 0 on success.
1366 int
1367 zhashx_insert (zhashx_t *self, const void *key, void *item);
1368
1369 // Update or insert item into hash table with specified key and item. If the
1370 // key is already present, destroys old item and inserts new one. If you set
1371 // a container item destructor, this is called on the old value. If the key
1372 // was not already present, inserts a new item. Sets the hash cursor to the
1373 // new item.
1374 void
1375 zhashx_update (zhashx_t *self, const void *key, void *item);
1376
1377 // Remove an item specified by key from the hash table. If there was no such
1378 // item, this function does nothing.
1379 void
1380 zhashx_delete (zhashx_t *self, const void *key);
1381
1382 // Delete all items from the hash table. If the key destructor is
1383 // set, calls it on every key. If the item destructor is set, calls
1384 // it on every item.
1385 void
1386 zhashx_purge (zhashx_t *self);
1387
1388 // Return the item at the specified key, or null
1389 void *
1390 zhashx_lookup (zhashx_t *self, const void *key);
1391
1392 // Reindexes an item from an old key to a new key. If there was no such
1393 // item, does nothing. Returns 0 if successful, else -1.
1394 int
1395 zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key);
1396
1397 // Set a free function for the specified hash table item. When the item is
1398 // destroyed, the free function, if any, is called on that item.
1399 // Use this when hash items are dynamically allocated, to ensure that
1400 // you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
1401 // Returns the item, or NULL if there is no such item.
1402 void *
1403 zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn);
1404
1405 // Return the number of keys/items in the hash table
1406 size_t
1407 zhashx_size (zhashx_t *self);
1408
1409 // Return a zlistx_t containing the keys for the items in the
1410 // table. Uses the key_duplicator to duplicate all keys and sets the
1411 // key_destructor as destructor for the list.
1412 zlistx_t *
1413 zhashx_keys (zhashx_t *self);
1414
1415 // Return a zlistx_t containing the values for the items in the
1416 // table. Uses the duplicator to duplicate all items and sets the
1417 // destructor as destructor for the list.
1418 zlistx_t *
1419 zhashx_values (zhashx_t *self);
1420
1421 // Simple iterator; returns first item in hash table, in no given order,
1422 // or NULL if the table is empty. This method is simpler to use than the
1423 // foreach() method, which is deprecated. To access the key for this item
1424 // use zhashx_cursor(). NOTE: do NOT modify the table while iterating.
1425 void *
1426 zhashx_first (zhashx_t *self);
1427
1428 // Simple iterator; returns next item in hash table, in no given order,
1429 // or NULL if the last item was already returned. Use this together with
1430 // zhashx_first() to process all items in a hash table. If you need the
1431 // items in sorted order, use zhashx_keys() and then zlistx_sort(). To
1432 // access the key for this item use zhashx_cursor(). NOTE: do NOT modify
1433 // the table while iterating.
1434 void *
1435 zhashx_next (zhashx_t *self);
1436
1437 // After a successful first/next method, returns the key for the item that
1438 // was returned. This is a constant string that you may not modify or
1439 // deallocate, and which lasts as long as the item in the hash. After an
1440 // unsuccessful first/next, returns NULL.
1441 const void *
1442 zhashx_cursor (zhashx_t *self);
1443
1444 // Add a comment to hash table before saving to disk. You can add as many
1445 // comment lines as you like. These comment lines are discarded when loading
1446 // the file. If you use a null format, all comments are deleted.
1447 void
1448 zhashx_comment (zhashx_t *self, const char *format, ...);
1449
1450 // Save hash table to a text file in name=value format. Hash values must be
1451 // printable strings; keys may not contain '=' character. Returns 0 if OK,
1452 // else -1 if a file error occurred.
1453 int
1454 zhashx_save (zhashx_t *self, const char *filename);
1455
1456 // Load hash table from a text file in name=value format; hash table must
1457 // already exist. Hash values must printable strings; keys may not contain
1458 // '=' character. Returns 0 if OK, else -1 if a file was not readable.
1459 int
1460 zhashx_load (zhashx_t *self, const char *filename);
1461
1462 // When a hash table was loaded from a file by zhashx_load, this method will
1463 // reload the file if it has been modified since, and is "stable", i.e. not
1464 // still changing. Returns 0 if OK, -1 if there was an error reloading the
1465 // file.
1466 int
1467 zhashx_refresh (zhashx_t *self);
1468
1469 // Serialize hash table to a binary frame that can be sent in a message.
1470 // The packed format is compatible with the 'dictionary' type defined in
1471 // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto:
1472 //
1473 // ; A list of name/value pairs
1474 // dictionary = dict-count *( dict-name dict-value )
1475 // dict-count = number-4
1476 // dict-value = longstr
1477 // dict-name = string
1478 //
1479 // ; Strings are always length + text contents
1480 // longstr = number-4 *VCHAR
1481 // string = number-1 *VCHAR
1482 //
1483 // ; Numbers are unsigned integers in network byte order
1484 // number-1 = 1OCTET
1485 // number-4 = 4OCTET
1486 //
1487 // Comments are not included in the packed data. Item values MUST be
1488 // strings.
1489 zframe_t *
1490 zhashx_pack (zhashx_t *self);
1491
1492 // Same as pack but uses a user-defined serializer function to convert items
1493 // into longstr.
1494 zframe_t *
1495 zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer);
1496
1497 // Make a copy of the list; items are duplicated if you set a duplicator
1498 // for the list, otherwise not. Copying a null reference returns a null
1499 // reference. Note that this method's behavior changed slightly for CZMQ
1500 // v3.x, as it does not set nor respect autofree. It does however let you
1501 // duplicate any hash table safely. The old behavior is in zhashx_dup_v2.
1502 zhashx_t *
1503 zhashx_dup (zhashx_t *self);
1504
1505 // Set a user-defined deallocator for hash items; by default items are not
1506 // freed when the hash is destroyed.
1507 void
1508 zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor);
1509
1510 // Set a user-defined duplicator for hash items; by default items are not
1511 // copied when the hash is duplicated.
1512 void
1513 zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator);
1514
1515 // Set a user-defined deallocator for keys; by default keys are freed
1516 // when the hash is destroyed using free().
1517 void
1518 zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor);
1519
1520 // Set a user-defined duplicator for keys; by default keys are duplicated
1521 // using strdup.
1522 void
1523 zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator);
1524
1525 // Set a user-defined comparator for keys; by default keys are
1526 // compared using strcmp.
1527 // The callback function should return zero (0) on matching
1528 // items.
1529 void
1530 zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator);
1531
1532 // Set a user-defined hash function for keys; by default keys are
1533 // hashed by a modified Bernstein hashing function.
1534 void
1535 zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher);
1536
1537 // Make copy of hash table; if supplied table is null, returns null.
1538 // Does not copy items themselves. Rebuilds new table so may be slow on
1539 // very large tables. NOTE: only works with item values that are strings
1540 // since there's no other way to know how to duplicate the item value.
1541 zhashx_t *
1542 zhashx_dup_v2 (zhashx_t *self);
1543
1544 // Self test of this class.
1545 void
1546 zhashx_test (bool verbose);
1547
1548 // CLASS: ziflist
1549 // Get a list of network interfaces currently defined on the system
1550 ziflist_t *
1551 ziflist_new (void);
1552
1553 // Destroy a ziflist instance
1554 void
1555 ziflist_destroy (ziflist_t **self_p);
1556
1557 // Reload network interfaces from system
1558 void
1559 ziflist_reload (ziflist_t *self);
1560
1561 // Return the number of network interfaces on system
1562 size_t
1563 ziflist_size (ziflist_t *self);
1564
1565 // Get first network interface, return NULL if there are none
1566 const char *
1567 ziflist_first (ziflist_t *self);
1568
1569 // Get next network interface, return NULL if we hit the last one
1570 const char *
1571 ziflist_next (ziflist_t *self);
1572
1573 // Return the current interface IP address as a printable string
1574 const char *
1575 ziflist_address (ziflist_t *self);
1576
1577 // Return the current interface broadcast address as a printable string
1578 const char *
1579 ziflist_broadcast (ziflist_t *self);
1580
1581 // Return the current interface network mask as a printable string
1582 const char *
1583 ziflist_netmask (ziflist_t *self);
1584
1585 // Return the list of interfaces.
1586 void
1587 ziflist_print (ziflist_t *self);
1588
1589 // Get a list of network interfaces currently defined on the system
1590 // Includes IPv6 interfaces
1591 ziflist_t *
1592 ziflist_new_ipv6 (void);
1593
1594 // Reload network interfaces from system, including IPv6
1595 void
1596 ziflist_reload_ipv6 (ziflist_t *self);
1597
1598 // Return true if the current interface uses IPv6
1599 bool
1600 ziflist_is_ipv6 (ziflist_t *self);
1601
1602 // Self test of this class.
1603 void
1604 ziflist_test (bool verbose);
1605
1606 // CLASS: zlist
1607 // Create a new list container
1608 zlist_t *
1609 zlist_new (void);
1610
1611 // Destroy a list container
1612 void
1613 zlist_destroy (zlist_t **self_p);
1614
1615 // Return the item at the head of list. If the list is empty, returns NULL.
1616 // Leaves cursor pointing at the head item, or NULL if the list is empty.
1617 void *
1618 zlist_first (zlist_t *self);
1619
1620 // Return the next item. If the list is empty, returns NULL. To move to
1621 // the start of the list call zlist_first (). Advances the cursor.
1622 void *
1623 zlist_next (zlist_t *self);
1624
1625 // Return the item at the tail of list. If the list is empty, returns NULL.
1626 // Leaves cursor pointing at the tail item, or NULL if the list is empty.
1627 void *
1628 zlist_last (zlist_t *self);
1629
1630 // Return first item in the list, or null, leaves the cursor
1631 void *
1632 zlist_head (zlist_t *self);
1633
1634 // Return last item in the list, or null, leaves the cursor
1635 void *
1636 zlist_tail (zlist_t *self);
1637
1638 // Return the current item of list. If the list is empty, returns NULL.
1639 // Leaves cursor pointing at the current item, or NULL if the list is empty.
1640 void *
1641 zlist_item (zlist_t *self);
1642
1643 // Append an item to the end of the list, return 0 if OK or -1 if this
1644 // failed for some reason (out of memory). Note that if a duplicator has
1645 // been set, this method will also duplicate the item.
1646 int
1647 zlist_append (zlist_t *self, void *item);
1648
1649 // Push an item to the start of the list, return 0 if OK or -1 if this
1650 // failed for some reason (out of memory). Note that if a duplicator has
1651 // been set, this method will also duplicate the item.
1652 int
1653 zlist_push (zlist_t *self, void *item);
1654
1655 // Pop the item off the start of the list, if any
1656 void *
1657 zlist_pop (zlist_t *self);
1658
1659 // Checks if an item already is present. Uses compare method to determine if
1660 // items are equal. If the compare method is NULL the check will only compare
1661 // pointers. Returns true if item is present else false.
1662 bool
1663 zlist_exists (zlist_t *self, void *item);
1664
1665 // Remove the specified item from the list if present
1666 void
1667 zlist_remove (zlist_t *self, void *item);
1668
1669 // Make a copy of list. If the list has autofree set, the copied list will
1670 // duplicate all items, which must be strings. Otherwise, the list will hold
1671 // pointers back to the items in the original list. If list is null, returns
1672 // NULL.
1673 zlist_t *
1674 zlist_dup (zlist_t *self);
1675
1676 // Purge all items from list
1677 void
1678 zlist_purge (zlist_t *self);
1679
1680 // Return number of items in the list
1681 size_t
1682 zlist_size (zlist_t *self);
1683
1684 // Sort the list. If the compare function is null, sorts the list by
1685 // ascending key value using a straight ASCII comparison. If you specify
1686 // a compare function, this decides how items are sorted. The sort is not
1687 // stable, so may reorder items with the same keys. The algorithm used is
1688 // combsort, a compromise between performance and simplicity.
1689 void
1690 zlist_sort (zlist_t *self, zlist_compare_fn compare);
1691
1692 // Set list for automatic item destruction; item values MUST be strings.
1693 // By default a list item refers to a value held elsewhere. When you set
1694 // this, each time you append or push a list item, zlist will take a copy
1695 // of the string value. Then, when you destroy the list, it will free all
1696 // item values automatically. If you use any other technique to allocate
1697 // list values, you must free them explicitly before destroying the list.
1698 // The usual technique is to pop list items and destroy them, until the
1699 // list is empty.
1700 void
1701 zlist_autofree (zlist_t *self);
1702
1703 // Sets a compare function for this list. The function compares two items.
1704 // It returns an integer less than, equal to, or greater than zero if the
1705 // first item is found, respectively, to be less than, to match, or be
1706 // greater than the second item.
1707 // This function is used for sorting, removal and exists checking.
1708 void
1709 zlist_comparefn (zlist_t *self, zlist_compare_fn fn);
1710
1711 // Set a free function for the specified list item. When the item is
1712 // destroyed, the free function, if any, is called on that item.
1713 // Use this when list items are dynamically allocated, to ensure that
1714 // you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
1715 // Returns the item, or NULL if there is no such item.
1716 void *
1717 zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail);
1718
1719 // Self test of this class.
1720 void
1721 zlist_test (bool verbose);
1722
1723 // CLASS: zlistx
1724 // Create a new, empty list.
1725 zlistx_t *
1726 zlistx_new (void);
1727
1728 // Destroy a list. If an item destructor was specified, all items in the
1729 // list are automatically destroyed as well.
1730 void
1731 zlistx_destroy (zlistx_t **self_p);
1732
1733 // Add an item to the head of the list. Calls the item duplicator, if any,
1734 // on the item. Resets cursor to list head. Returns an item handle on
1735 // success, NULL if memory was exhausted.
1736 void *
1737 zlistx_add_start (zlistx_t *self, void *item);
1738
1739 // Add an item to the tail of the list. Calls the item duplicator, if any,
1740 // on the item. Resets cursor to list head. Returns an item handle on
1741 // success, NULL if memory was exhausted.
1742 void *
1743 zlistx_add_end (zlistx_t *self, void *item);
1744
1745 // Return the number of items in the list
1746 size_t
1747 zlistx_size (zlistx_t *self);
1748
1749 // Return first item in the list, or null, leaves the cursor
1750 void *
1751 zlistx_head (zlistx_t *self);
1752
1753 // Return last item in the list, or null, leaves the cursor
1754 void *
1755 zlistx_tail (zlistx_t *self);
1756
1757 // Return the item at the head of list. If the list is empty, returns NULL.
1758 // Leaves cursor pointing at the head item, or NULL if the list is empty.
1759 void *
1760 zlistx_first (zlistx_t *self);
1761
1762 // Return the next item. At the end of the list (or in an empty list),
1763 // returns NULL. Use repeated zlistx_next () calls to work through the list
1764 // from zlistx_first (). First time, acts as zlistx_first().
1765 void *
1766 zlistx_next (zlistx_t *self);
1767
1768 // Return the previous item. At the start of the list (or in an empty list),
1769 // returns NULL. Use repeated zlistx_prev () calls to work through the list
1770 // backwards from zlistx_last (). First time, acts as zlistx_last().
1771 void *
1772 zlistx_prev (zlistx_t *self);
1773
1774 // Return the item at the tail of list. If the list is empty, returns NULL.
1775 // Leaves cursor pointing at the tail item, or NULL if the list is empty.
1776 void *
1777 zlistx_last (zlistx_t *self);
1778
1779 // Returns the value of the item at the cursor, or NULL if the cursor is
1780 // not pointing to an item.
1781 void *
1782 zlistx_item (zlistx_t *self);
1783
1784 // Returns the handle of the item at the cursor, or NULL if the cursor is
1785 // not pointing to an item.
1786 void *
1787 zlistx_cursor (zlistx_t *self);
1788
1789 // Returns the item associated with the given list handle, or NULL if passed
1790 // in handle is NULL. Asserts that the passed in handle points to a list element.
1791 void *
1792 zlistx_handle_item (void *handle);
1793
1794 // Find an item in the list, searching from the start. Uses the item
1795 // comparator, if any, else compares item values directly. Returns the
1796 // item handle found, or NULL. Sets the cursor to the found item, if any.
1797 void *
1798 zlistx_find (zlistx_t *self, void *item);
1799
1800 // Detach an item from the list, using its handle. The item is not modified,
1801 // and the caller is responsible for destroying it if necessary. If handle is
1802 // null, detaches the first item on the list. Returns item that was detached,
1803 // or null if none was. If cursor was at item, moves cursor to previous item,
1804 // so you can detach items while iterating forwards through a list.
1805 void *
1806 zlistx_detach (zlistx_t *self, void *handle);
1807
1808 // Detach item at the cursor, if any, from the list. The item is not modified,
1809 // and the caller is responsible for destroying it as necessary. Returns item
1810 // that was detached, or null if none was. Moves cursor to previous item, so
1811 // you can detach items while iterating forwards through a list.
1812 void *
1813 zlistx_detach_cur (zlistx_t *self);
1814
1815 // Delete an item, using its handle. Calls the item destructor is any is
1816 // set. If handle is null, deletes the first item on the list. Returns 0
1817 // if an item was deleted, -1 if not. If cursor was at item, moves cursor
1818 // to previous item, so you can delete items while iterating forwards
1819 // through a list.
1820 int
1821 zlistx_delete (zlistx_t *self, void *handle);
1822
1823 // Move an item to the start of the list, via its handle.
1824 void
1825 zlistx_move_start (zlistx_t *self, void *handle);
1826
1827 // Move an item to the end of the list, via its handle.
1828 void
1829 zlistx_move_end (zlistx_t *self, void *handle);
1830
1831 // Remove all items from the list, and destroy them if the item destructor
1832 // is set.
1833 void
1834 zlistx_purge (zlistx_t *self);
1835
1836 // Sort the list. If an item comparator was set, calls that to compare
1837 // items, otherwise compares on item value. The sort is not stable, so may
1838 // reorder equal items.
1839 void
1840 zlistx_sort (zlistx_t *self);
1841
1842 // Create a new node and insert it into a sorted list. Calls the item
1843 // duplicator, if any, on the item. If low_value is true, starts searching
1844 // from the start of the list, otherwise searches from the end. Use the item
1845 // comparator, if any, to find where to place the new node. Returns a handle
1846 // to the new node, or NULL if memory was exhausted. Resets the cursor to the
1847 // list head.
1848 void *
1849 zlistx_insert (zlistx_t *self, void *item, bool low_value);
1850
1851 // Move an item, specified by handle, into position in a sorted list. Uses
1852 // the item comparator, if any, to determine the new location. If low_value
1853 // is true, starts searching from the start of the list, otherwise searches
1854 // from the end.
1855 void
1856 zlistx_reorder (zlistx_t *self, void *handle, bool low_value);
1857
1858 // Make a copy of the list; items are duplicated if you set a duplicator
1859 // for the list, otherwise not. Copying a null reference returns a null
1860 // reference.
1861 zlistx_t *
1862 zlistx_dup (zlistx_t *self);
1863
1864 // Set a user-defined deallocator for list items; by default items are not
1865 // freed when the list is destroyed.
1866 void
1867 zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor);
1868
1869 // Set a user-defined duplicator for list items; by default items are not
1870 // copied when the list is duplicated.
1871 void
1872 zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator);
1873
1874 // Set a user-defined comparator for zlistx_find and zlistx_sort; the method
1875 // must return -1, 0, or 1 depending on whether item1 is less than, equal to,
1876 // or greater than, item2.
1877 void
1878 zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator);
1879
1880 // Self test of this class.
1881 void
1882 zlistx_test (bool verbose);
1883
1884 // CLASS: zloop
1885 // Create a new zloop reactor
1886 zloop_t *
1887 zloop_new (void);
1888
1889 // Destroy a reactor
1890 void
1891 zloop_destroy (zloop_t **self_p);
1892
1893 // Register socket reader with the reactor. When the reader has messages,
1894 // the reactor will call the handler, passing the arg. Returns 0 if OK, -1
1895 // if there was an error. If you register the same socket more than once,
1896 // each instance will invoke its corresponding handler.
1897 int
1898 zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg);
1899
1900 // Cancel a socket reader from the reactor. If multiple readers exist for
1901 // same socket, cancels ALL of them.
1902 void
1903 zloop_reader_end (zloop_t *self, zsock_t *sock);
1904
1905 // Configure a registered reader to ignore errors. If you do not set this,
1906 // then readers that have errors are removed from the reactor silently.
1907 void
1908 zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock);
1909
1910 // Register low-level libzmq pollitem with the reactor. When the pollitem
1911 // is ready, will call the handler, passing the arg. Returns 0 if OK, -1
1912 // if there was an error. If you register the pollitem more than once, each
1913 // instance will invoke its corresponding handler. A pollitem with
1914 // socket=NULL and fd=0 means 'poll on FD zero'.
1915 int
1916 zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg);
1917
1918 // Cancel a pollitem from the reactor, specified by socket or FD. If both
1919 // are specified, uses only socket. If multiple poll items exist for same
1920 // socket/FD, cancels ALL of them.
1921 void
1922 zloop_poller_end (zloop_t *self, zmq_pollitem_t *item);
1923
1924 // Configure a registered poller to ignore errors. If you do not set this,
1925 // then poller that have errors are removed from the reactor silently.
1926 void
1927 zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item);
1928
1929 // Register a timer that expires after some delay and repeats some number of
1930 // times. At each expiry, will call the handler, passing the arg. To run a
1931 // timer forever, use 0 times. Returns a timer_id that is used to cancel the
1932 // timer in the future. Returns -1 if there was an error.
1933 int
1934 zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg);
1935
1936 // Cancel a specific timer identified by a specific timer_id (as returned by
1937 // zloop_timer).
1938 int
1939 zloop_timer_end (zloop_t *self, int timer_id);
1940
1941 // Register a ticket timer. Ticket timers are very fast in the case where
1942 // you use a lot of timers (thousands), and frequently remove and add them.
1943 // The main use case is expiry timers for servers that handle many clients,
1944 // and which reset the expiry timer for each message received from a client.
1945 // Whereas normal timers perform poorly as the number of clients grows, the
1946 // cost of ticket timers is constant, no matter the number of clients. You
1947 // must set the ticket delay using zloop_set_ticket_delay before creating a
1948 // ticket. Returns a handle to the timer that you should use in
1949 // zloop_ticket_reset and zloop_ticket_delete.
1950 void *
1951 zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg);
1952
1953 // Reset a ticket timer, which moves it to the end of the ticket list and
1954 // resets its execution time. This is a very fast operation.
1955 void
1956 zloop_ticket_reset (zloop_t *self, void *handle);
1957
1958 // Delete a ticket timer. We do not actually delete the ticket here, as
1959 // other code may still refer to the ticket. We mark as deleted, and remove
1960 // later and safely.
1961 void
1962 zloop_ticket_delete (zloop_t *self, void *handle);
1963
1964 // Set the ticket delay, which applies to all tickets. If you lower the
1965 // delay and there are already tickets created, the results are undefined.
1966 void
1967 zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay);
1968
1969 // Set hard limit on number of timers allowed. Setting more than a small
1970 // number of timers (10-100) can have a dramatic impact on the performance
1971 // of the reactor. For high-volume cases, use ticket timers. If the hard
1972 // limit is reached, the reactor stops creating new timers and logs an
1973 // error.
1974 void
1975 zloop_set_max_timers (zloop_t *self, size_t max_timers);
1976
1977 // Set verbose tracing of reactor on/off. The default verbose setting is
1978 // off (false).
1979 void
1980 zloop_set_verbose (zloop_t *self, bool verbose);
1981
1982 // By default the reactor stops if the process receives a SIGINT or SIGTERM
1983 // signal. This makes it impossible to shut-down message based architectures
1984 // like zactors. This method lets you switch off break handling. The default
1985 // nonstop setting is off (false).
1986 void
1987 zloop_set_nonstop (zloop_t *self, bool nonstop);
1988
1989 // Start the reactor. Takes control of the thread and returns when the 0MQ
1990 // context is terminated or the process is interrupted, or any event handler
1991 // returns -1. Event handlers may register new sockets and timers, and
1992 // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler.
1993 int
1994 zloop_start (zloop_t *self);
1995
1996 // Self test of this class.
1997 void
1998 zloop_test (bool verbose);
1999
2000 // CLASS: zmsg
2001 // Create a new empty message object
2002 zmsg_t *
2003 zmsg_new (void);
2004
2005 // Destroy a message object and all frames it contains
2006 void
2007 zmsg_destroy (zmsg_t **self_p);
2008
2009 // Receive message from socket, returns zmsg_t object or NULL if the recv
2010 // was interrupted. Does a blocking recv. If you want to not block then use
2011 // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input
2012 // before receiving.
2013 zmsg_t *
2014 zmsg_recv (void *source);
2015
2016 // Load/append an open file into new message, return the message.
2017 // Returns NULL if the message could not be loaded.
2018 zmsg_t *
2019 zmsg_load (FILE *file);
2020
2021 // Decodes a serialized message frame created by zmsg_encode () and returns
2022 // a new zmsg_t object. Returns NULL if the frame was badly formatted or
2023 // there was insufficient memory to work.
2024 zmsg_t *
2025 zmsg_decode (zframe_t *frame);
2026
2027 // Generate a signal message encoding the given status. A signal is a short
2028 // message carrying a 1-byte success/failure code (by convention, 0 means
2029 // OK). Signals are encoded to be distinguishable from "normal" messages.
2030 zmsg_t *
2031 zmsg_new_signal (byte status);
2032
2033 // Send message to destination socket, and destroy the message after sending
2034 // it successfully. If the message has no frames, sends nothing but destroys
2035 // the message anyhow. Nullifies the caller's reference to the message (as
2036 // it is a destructor).
2037 int
2038 zmsg_send (zmsg_t **self_p, void *dest);
2039
2040 // Send message to destination socket as part of a multipart sequence, and
2041 // destroy the message after sending it successfully. Note that after a
2042 // zmsg_sendm, you must call zmsg_send or another method that sends a final
2043 // message part. If the message has no frames, sends nothing but destroys
2044 // the message anyhow. Nullifies the caller's reference to the message (as
2045 // it is a destructor).
2046 int
2047 zmsg_sendm (zmsg_t **self_p, void *dest);
2048
2049 // Return size of message, i.e. number of frames (0 or more).
2050 size_t
2051 zmsg_size (zmsg_t *self);
2052
2053 // Return total size of all frames in message.
2054 size_t
2055 zmsg_content_size (zmsg_t *self);
2056
2057 // Return message routing ID, if the message came from a ZMQ_SERVER socket.
2058 // Else returns zero.
2059 uint32_t
2060 zmsg_routing_id (zmsg_t *self);
2061
2062 // Set routing ID on message. This is used if/when the message is sent to a
2063 // ZMQ_SERVER socket.
2064 void
2065 zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id);
2066
2067 // Push frame to the front of the message, i.e. before all other frames.
2068 // Message takes ownership of frame, will destroy it when message is sent.
2069 // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not
2070 // nullify the caller's frame reference.
2071 int
2072 zmsg_prepend (zmsg_t *self, zframe_t **frame_p);
2073
2074 // Add frame to the end of the message, i.e. after all other frames.
2075 // Message takes ownership of frame, will destroy it when message is sent.
2076 // Returns 0 on success. Deprecates zmsg_add, which did not nullify the
2077 // caller's frame reference.
2078 int
2079 zmsg_append (zmsg_t *self, zframe_t **frame_p);
2080
2081 // Remove first frame from message, if any. Returns frame, or NULL.
2082 zframe_t *
2083 zmsg_pop (zmsg_t *self);
2084
2085 // Push block of memory to front of message, as a new frame.
2086 // Returns 0 on success, -1 on error.
2087 int
2088 zmsg_pushmem (zmsg_t *self, const void *data, size_t size);
2089
2090 // Add block of memory to the end of the message, as a new frame.
2091 // Returns 0 on success, -1 on error.
2092 int
2093 zmsg_addmem (zmsg_t *self, const void *data, size_t size);
2094
2095 // Push string as new frame to front of message.
2096 // Returns 0 on success, -1 on error.
2097 int
2098 zmsg_pushstr (zmsg_t *self, const char *string);
2099
2100 // Push string as new frame to end of message.
2101 // Returns 0 on success, -1 on error.
2102 int
2103 zmsg_addstr (zmsg_t *self, const char *string);
2104
2105 // Push formatted string as new frame to front of message.
2106 // Returns 0 on success, -1 on error.
2107 int
2108 zmsg_pushstrf (zmsg_t *self, const char *format, ...);
2109
2110 // Push formatted string as new frame to end of message.
2111 // Returns 0 on success, -1 on error.
2112 int
2113 zmsg_addstrf (zmsg_t *self, const char *format, ...);
2114
2115 // Pop frame off front of message, return as fresh string. If there were
2116 // no more frames in the message, returns NULL.
2117 char *
2118 zmsg_popstr (zmsg_t *self);
2119
2120 // Push encoded message as a new frame. Message takes ownership of
2121 // submessage, so the original is destroyed in this call. Returns 0 on
2122 // success, -1 on error.
2123 int
2124 zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p);
2125
2126 // Remove first submessage from message, if any. Returns zmsg_t, or NULL if
2127 // decoding was not successful.
2128 zmsg_t *
2129 zmsg_popmsg (zmsg_t *self);
2130
2131 // Remove specified frame from list, if present. Does not destroy frame.
2132 void
2133 zmsg_remove (zmsg_t *self, zframe_t *frame);
2134
2135 // Set cursor to first frame in message. Returns frame, or NULL, if the
2136 // message is empty. Use this to navigate the frames as a list.
2137 zframe_t *
2138 zmsg_first (zmsg_t *self);
2139
2140 // Return the next frame. If there are no more frames, returns NULL. To move
2141 // to the first frame call zmsg_first(). Advances the cursor.
2142 zframe_t *
2143 zmsg_next (zmsg_t *self);
2144
2145 // Return the last frame. If there are no frames, returns NULL.
2146 zframe_t *
2147 zmsg_last (zmsg_t *self);
2148
2149 // Save message to an open file, return 0 if OK, else -1. The message is
2150 // saved as a series of frames, each with length and data. Note that the
2151 // file is NOT guaranteed to be portable between operating systems, not
2152 // versions of CZMQ. The file format is at present undocumented and liable
2153 // to arbitrary change.
2154 int
2155 zmsg_save (zmsg_t *self, FILE *file);
2156
2157 // Serialize multipart message to a single message frame. Use this method
2158 // to send structured messages across transports that do not support
2159 // multipart data. Allocates and returns a new frame containing the
2160 // serialized message. To decode a serialized message frame, use
2161 // zmsg_decode ().
2162 zframe_t *
2163 zmsg_encode (zmsg_t *self);
2164
2165 // Create copy of message, as new message object. Returns a fresh zmsg_t
2166 // object. If message is null, or memory was exhausted, returns null.
2167 zmsg_t *
2168 zmsg_dup (zmsg_t *self);
2169
2170 // Send message to zsys log sink (may be stdout, or system facility as
2171 // configured by zsys_set_logstream).
2172 void
2173 zmsg_print (zmsg_t *self);
2174
2175 // Return true if the two messages have the same number of frames and each
2176 // frame in the first message is identical to the corresponding frame in the
2177 // other message. As with zframe_eq, return false if either message is NULL.
2178 bool
2179 zmsg_eq (zmsg_t *self, zmsg_t *other);
2180
2181 // Return signal value, 0 or greater, if message is a signal, -1 if not.
2182 int
2183 zmsg_signal (zmsg_t *self);
2184
2185 // Probe the supplied object, and report if it looks like a zmsg_t.
2186 bool
2187 zmsg_is (void *self);
2188
2189 // Self test of this class.
2190 void
2191 zmsg_test (bool verbose);
2192
2193 // CLASS: zpoller
2194 // Create new poller, specifying zero or more readers. The list of
2195 // readers ends in a NULL. Each reader can be a zsock_t instance, a
2196 // zactor_t instance, a libzmq socket (void *), or a file handle.
2197 zpoller_t *
2198 zpoller_new (void *reader, ...);
2199
2200 // Destroy a poller
2201 void
2202 zpoller_destroy (zpoller_t **self_p);
2203
2204 // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may
2205 // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance.
2206 int
2207 zpoller_add (zpoller_t *self, void *reader);
2208
2209 // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader
2210 // must have been passed during construction, or in an zpoller_add () call.
2211 int
2212 zpoller_remove (zpoller_t *self, void *reader);
2213
2214 // By default the poller stops if the process receives a SIGINT or SIGTERM
2215 // signal. This makes it impossible to shut-down message based architectures
2216 // like zactors. This method lets you switch off break handling. The default
2217 // nonstop setting is off (false).
2218 void
2219 zpoller_set_nonstop (zpoller_t *self, bool nonstop);
2220
2221 // Poll the registered readers for I/O, return first reader that has input.
2222 // The reader will be a libzmq void * socket, or a zsock_t or zactor_t
2223 // instance as specified in zpoller_new/zpoller_add. The timeout should be
2224 // zero or greater, or -1 to wait indefinitely. Socket priority is defined
2225 // by their order in the poll list. If you need a balanced poll, use the low
2226 // level zmq_poll method directly. If the poll call was interrupted (SIGINT),
2227 // or the ZMQ context was destroyed, or the timeout expired, returns NULL.
2228 // You can test the actual exit condition by calling zpoller_expired () and
2229 // zpoller_terminated (). The timeout is in msec.
2230 void *
2231 zpoller_wait (zpoller_t *self, int timeout);
2232
2233 // Return true if the last zpoller_wait () call ended because the timeout
2234 // expired, without any error.
2235 bool
2236 zpoller_expired (zpoller_t *self);
2237
2238 // Return true if the last zpoller_wait () call ended because the process
2239 // was interrupted, or the parent context was destroyed.
2240 bool
2241 zpoller_terminated (zpoller_t *self);
2242
2243 // Self test of this class.
2244 void
2245 zpoller_test (bool verbose);
2246
2247 // CLASS: zproc
2248 // Create a new zproc.
2249 // NOTE: On Windows and with libzmq3 and libzmq2 this function
2250 // returns NULL. Code needs to be ported there.
2251 zproc_t *
2252 zproc_new (void);
2253
2254 // Destroy zproc, wait until process ends.
2255 void
2256 zproc_destroy (zproc_t **self_p);
2257
2258 // Return command line arguments (the first item is the executable) or
2259 // NULL if not set.
2260 zlist_t *
2261 zproc_args (zproc_t *self);
2262
2263 // Setup the command line arguments, the first item must be an (absolute) filename
2264 // to run.
2265 void
2266 zproc_set_args (zproc_t *self, zlist_t **arguments);
2267
2268 // Setup the command line arguments, the first item must be an (absolute) filename
2269 // to run. Variadic function, must be NULL terminated.
2270 void
2271 zproc_set_argsx (zproc_t *self, const char *arguments, ...);
2272
2273 // Setup the environment variables for the process.
2274 void
2275 zproc_set_env (zproc_t *self, zhash_t **arguments);
2276
2277 // Connects process stdin with a readable ('>', connect) zeromq socket. If
2278 // socket argument is NULL, zproc creates own managed pair of inproc
2279 // sockets. The writable one is then accessbile via zproc_stdin method.
2280 void
2281 zproc_set_stdin (zproc_t *self, void *socket);
2282
2283 // Connects process stdout with a writable ('@', bind) zeromq socket. If
2284 // socket argument is NULL, zproc creates own managed pair of inproc
2285 // sockets. The readable one is then accessbile via zproc_stdout method.
2286 void
2287 zproc_set_stdout (zproc_t *self, void *socket);
2288
2289 // Connects process stderr with a writable ('@', bind) zeromq socket. If
2290 // socket argument is NULL, zproc creates own managed pair of inproc
2291 // sockets. The readable one is then accessbile via zproc_stderr method.
2292 void
2293 zproc_set_stderr (zproc_t *self, void *socket);
2294
2295 // Return subprocess stdin writable socket. NULL for
2296 // not initialized or external sockets.
2297 void *
2298 zproc_stdin (zproc_t *self);
2299
2300 // Return subprocess stdout readable socket. NULL for
2301 // not initialized or external sockets.
2302 void *
2303 zproc_stdout (zproc_t *self);
2304
2305 // Return subprocess stderr readable socket. NULL for
2306 // not initialized or external sockets.
2307 void *
2308 zproc_stderr (zproc_t *self);
2309
2310 // Starts the process, return just before execve/CreateProcess.
2311 int
2312 zproc_run (zproc_t *self);
2313
2314 // process exit code
2315 int
2316 zproc_returncode (zproc_t *self);
2317
2318 // PID of the process
2319 int
2320 zproc_pid (zproc_t *self);
2321
2322 // return true if process is running, false if not yet started or finished
2323 bool
2324 zproc_running (zproc_t *self);
2325
2326 // wait or poll process status, return return code
2327 int
2328 zproc_wait (zproc_t *self, bool hang);
2329
2330 // return internal actor, usefull for the polling if process died
2331 void *
2332 zproc_actor (zproc_t *self);
2333
2334 // send a signal to the subprocess
2335 void
2336 zproc_kill (zproc_t *self, int signal);
2337
2338 // set verbose mode
2339 void
2340 zproc_set_verbose (zproc_t *self, bool verbose);
2341
2342 // Self test of this class.
2343 void
2344 zproc_test (bool verbose);
2345
2346 // CLASS: zsock
2347 // Create a new socket. Returns the new socket, or NULL if the new socket
2348 // could not be created. Note that the symbol zsock_new (and other
2349 // constructors/destructors for zsock) are redirected to the *_checked
2350 // variant, enabling intelligent socket leak detection. This can have
2351 // performance implications if you use a LOT of sockets. To turn off this
2352 // redirection behaviour, define ZSOCK_NOCHECK.
2353 zsock_t *
2354 zsock_new (int type);
2355
2356 // Destroy the socket. You must use this for any socket created via the
2357 // zsock_new method.
2358 void
2359 zsock_destroy (zsock_t **self_p);
2360
2361 // Create a PUB socket. Default action is bind.
2362 zsock_t *
2363 zsock_new_pub (const char *endpoint);
2364
2365 // Create a SUB socket, and optionally subscribe to some prefix string. Default
2366 // action is connect.
2367 zsock_t *
2368 zsock_new_sub (const char *endpoint, const char *subscribe);
2369
2370 // Create a REQ socket. Default action is connect.
2371 zsock_t *
2372 zsock_new_req (const char *endpoint);
2373
2374 // Create a REP socket. Default action is bind.
2375 zsock_t *
2376 zsock_new_rep (const char *endpoint);
2377
2378 // Create a DEALER socket. Default action is connect.
2379 zsock_t *
2380 zsock_new_dealer (const char *endpoint);
2381
2382 // Create a ROUTER socket. Default action is bind.
2383 zsock_t *
2384 zsock_new_router (const char *endpoint);
2385
2386 // Create a PUSH socket. Default action is connect.
2387 zsock_t *
2388 zsock_new_push (const char *endpoint);
2389
2390 // Create a PULL socket. Default action is bind.
2391 zsock_t *
2392 zsock_new_pull (const char *endpoint);
2393
2394 // Create an XPUB socket. Default action is bind.
2395 zsock_t *
2396 zsock_new_xpub (const char *endpoint);
2397
2398 // Create an XSUB socket. Default action is connect.
2399 zsock_t *
2400 zsock_new_xsub (const char *endpoint);
2401
2402 // Create a PAIR socket. Default action is connect.
2403 zsock_t *
2404 zsock_new_pair (const char *endpoint);
2405
2406 // Create a STREAM socket. Default action is connect.
2407 zsock_t *
2408 zsock_new_stream (const char *endpoint);
2409
2410 // Create a SERVER socket. Default action is bind.
2411 zsock_t *
2412 zsock_new_server (const char *endpoint);
2413
2414 // Create a CLIENT socket. Default action is connect.
2415 zsock_t *
2416 zsock_new_client (const char *endpoint);
2417
2418 // Create a RADIO socket. Default action is bind.
2419 zsock_t *
2420 zsock_new_radio (const char *endpoint);
2421
2422 // Create a DISH socket. Default action is connect.
2423 zsock_t *
2424 zsock_new_dish (const char *endpoint);
2425
2426 // Create a GATHER socket. Default action is bind.
2427 zsock_t *
2428 zsock_new_gather (const char *endpoint);
2429
2430 // Create a SCATTER socket. Default action is connect.
2431 zsock_t *
2432 zsock_new_scatter (const char *endpoint);
2433
2434 // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports
2435 // ephemeral ports, if you specify the port number as "*". By default
2436 // zsock uses the IANA designated range from C000 (49152) to FFFF (65535).
2437 // To override this range, follow the "*" with "[first-last]". Either or
2438 // both first and last may be empty. To bind to a random port within the
2439 // range, use "!" in place of "*".
2440 //
2441 // Examples:
2442 // tcp://127.0.0.1:* bind to first free port from C000 up
2443 // tcp://127.0.0.1:! bind to random port from C000 to FFFF
2444 // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up
2445 // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000
2446 // tcp://127.0.0.1:![55000-55999]
2447 // bind to random port from 55000 to 55999
2448 //
2449 // On success, returns the actual port number used, for tcp:// endpoints,
2450 // and 0 for other transports. On failure, returns -1. Note that when using
2451 // ephemeral ports, a port may be reused by different services without
2452 // clients being aware. Protocols that run on ephemeral ports should take
2453 // this into account.
2454 int
2455 zsock_bind (zsock_t *self, const char *format, ...);
2456
2457 // Returns last bound endpoint, if any.
2458 const char *
2459 zsock_endpoint (zsock_t *self);
2460
2461 // Unbind a socket from a formatted endpoint.
2462 // Returns 0 if OK, -1 if the endpoint was invalid or the function
2463 // isn't supported.
2464 int
2465 zsock_unbind (zsock_t *self, const char *format, ...);
2466
2467 // Connect a socket to a formatted endpoint
2468 // Returns 0 if OK, -1 if the endpoint was invalid.
2469 int
2470 zsock_connect (zsock_t *self, const char *format, ...);
2471
2472 // Disconnect a socket from a formatted endpoint
2473 // Returns 0 if OK, -1 if the endpoint was invalid or the function
2474 // isn't supported.
2475 int
2476 zsock_disconnect (zsock_t *self, const char *format, ...);
2477
2478 // Attach a socket to zero or more endpoints. If endpoints is not null,
2479 // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by
2480 // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all
2481 // endpoints were valid, or -1 if there was a syntax error. If the endpoint
2482 // does not start with '@' or '>', the serverish argument defines whether
2483 // it is used to bind (serverish = true) or connect (serverish = false).
2484 int
2485 zsock_attach (zsock_t *self, const char *endpoints, bool serverish);
2486
2487 // Returns socket type as printable constant string.
2488 const char *
2489 zsock_type_str (zsock_t *self);
2490
2491 // Send a 'picture' message to the socket (or actor). The picture is a
2492 // string that defines the type of each frame. This makes it easy to send
2493 // a complex multiframe message in one call. The picture can contain any
2494 // of these characters, each corresponding to one or two arguments:
2495 //
2496 // i = int (signed)
2497 // 1 = uint8_t
2498 // 2 = uint16_t
2499 // 4 = uint32_t
2500 // 8 = uint64_t
2501 // s = char *
2502 // b = byte *, size_t (2 arguments)
2503 // c = zchunk_t *
2504 // f = zframe_t *
2505 // h = zhashx_t *
2506 // U = zuuid_t *
2507 // p = void * (sends the pointer value, only meaningful over inproc)
2508 // m = zmsg_t * (sends all frames in the zmsg)
2509 // z = sends zero-sized frame (0 arguments)
2510 // u = uint (deprecated)
2511 //
2512 // Note that s, b, c, and f are encoded the same way and the choice is
2513 // offered as a convenience to the sender, which may or may not already
2514 // have data in a zchunk or zframe. Does not change or take ownership of
2515 // any arguments. Returns 0 if successful, -1 if sending failed for any
2516 // reason.
2517 int
2518 zsock_send (void *self, const char *picture, ...);
2519
2520 // Send a 'picture' message to the socket (or actor). This is a va_list
2521 // version of zsock_send (), so please consult its documentation for the
2522 // details.
2523 int
2524 zsock_vsend (void *self, const char *picture, va_list argptr);
2525
2526 // Receive a 'picture' message to the socket (or actor). See zsock_send for
2527 // the format and meaning of the picture. Returns the picture elements into
2528 // a series of pointers as provided by the caller:
2529 //
2530 // i = int * (stores signed integer)
2531 // 4 = uint32_t * (stores 32-bit unsigned integer)
2532 // 8 = uint64_t * (stores 64-bit unsigned integer)
2533 // s = char ** (allocates new string)
2534 // b = byte **, size_t * (2 arguments) (allocates memory)
2535 // c = zchunk_t ** (creates zchunk)
2536 // f = zframe_t ** (creates zframe)
2537 // U = zuuid_t * (creates a zuuid with the data)
2538 // h = zhashx_t ** (creates zhashx)
2539 // p = void ** (stores pointer)
2540 // m = zmsg_t ** (creates a zmsg with the remaing frames)
2541 // z = null, asserts empty frame (0 arguments)
2542 // u = uint * (stores unsigned integer, deprecated)
2543 //
2544 // Note that zsock_recv creates the returned objects, and the caller must
2545 // destroy them when finished with them. The supplied pointers do not need
2546 // to be initialized. Returns 0 if successful, or -1 if it failed to recv
2547 // a message, in which case the pointers are not modified. When message
2548 // frames are truncated (a short message), sets return values to zero/null.
2549 // If an argument pointer is NULL, does not store any value (skips it).
2550 // An 'n' picture matches an empty frame; if the message does not match,
2551 // the method will return -1.
2552 int
2553 zsock_recv (void *self, const char *picture, ...);
2554
2555 // Receive a 'picture' message from the socket (or actor). This is a
2556 // va_list version of zsock_recv (), so please consult its documentation
2557 // for the details.
2558 int
2559 zsock_vrecv (void *self, const char *picture, va_list argptr);
2560
2561 // Send a binary encoded 'picture' message to the socket (or actor). This
2562 // method is similar to zsock_send, except the arguments are encoded in a
2563 // binary format that is compatible with zproto, and is designed to reduce
2564 // memory allocations. The pattern argument is a string that defines the
2565 // type of each argument. Supports these argument types:
2566 //
2567 // pattern C type zproto type:
2568 // 1 uint8_t type = "number" size = "1"
2569 // 2 uint16_t type = "number" size = "2"
2570 // 4 uint32_t type = "number" size = "3"
2571 // 8 uint64_t type = "number" size = "4"
2572 // s char *, 0-255 chars type = "string"
2573 // S char *, 0-2^32-1 chars type = "longstr"
2574 // c zchunk_t * type = "chunk"
2575 // f zframe_t * type = "frame"
2576 // u zuuid_t * type = "uuid"
2577 // m zmsg_t * type = "msg"
2578 // p void *, sends pointer value, only over inproc
2579 //
2580 // Does not change or take ownership of any arguments. Returns 0 if
2581 // successful, -1 if sending failed for any reason.
2582 int
2583 zsock_bsend (void *self, const char *picture, ...);
2584
2585 // Receive a binary encoded 'picture' message from the socket (or actor).
2586 // This method is similar to zsock_recv, except the arguments are encoded
2587 // in a binary format that is compatible with zproto, and is designed to
2588 // reduce memory allocations. The pattern argument is a string that defines
2589 // the type of each argument. See zsock_bsend for the supported argument
2590 // types. All arguments must be pointers; this call sets them to point to
2591 // values held on a per-socket basis.
2592 // For types 1, 2, 4 and 8 the caller must allocate the memory itself before
2593 // calling zsock_brecv.
2594 // For types S, the caller must free the value once finished with it, as
2595 // zsock_brecv will allocate the buffer.
2596 // For type s, the caller must not free the value as it is stored in a
2597 // local cache for performance purposes.
2598 // For types c, f, u and m the caller must call the appropriate destructor
2599 // depending on the object as zsock_brecv will create new objects.
2600 // For type p the caller must coordinate with the sender, as it is just a
2601 // pointer value being passed.
2602 int
2603 zsock_brecv (void *self, const char *picture, ...);
2604
2605 // Return socket routing ID if any. This returns 0 if the socket is not
2606 // of type ZMQ_SERVER or if no request was already received on it.
2607 uint32_t
2608 zsock_routing_id (zsock_t *self);
2609
2610 // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER.
2611 // This will be used when sending messages on the socket via the zsock API.
2612 void
2613 zsock_set_routing_id (zsock_t *self, uint32_t routing_id);
2614
2615 // Set socket to use unbounded pipes (HWM=0); use this in cases when you are
2616 // totally certain the message volume can fit in memory. This method works
2617 // across all versions of ZeroMQ. Takes a polymorphic socket reference.
2618 void
2619 zsock_set_unbounded (void *self);
2620
2621 // Send a signal over a socket. A signal is a short message carrying a
2622 // success/failure code (by convention, 0 means OK). Signals are encoded
2623 // to be distinguishable from "normal" messages. Accepts a zsock_t or a
2624 // zactor_t argument, and returns 0 if successful, -1 if the signal could
2625 // not be sent. Takes a polymorphic socket reference.
2626 int
2627 zsock_signal (void *self, byte status);
2628
2629 // Wait on a signal. Use this to coordinate between threads, over pipe
2630 // pairs. Blocks until the signal is received. Returns -1 on error, 0 or
2631 // greater on success. Accepts a zsock_t or a zactor_t as argument.
2632 // Takes a polymorphic socket reference.
2633 int
2634 zsock_wait (void *self);
2635
2636 // If there is a partial message still waiting on the socket, remove and
2637 // discard it. This is useful when reading partial messages, to get specific
2638 // message types.
2639 void
2640 zsock_flush (void *self);
2641
2642 // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH.
2643 // Returns 0 if OK, -1 if failed.
2644 int
2645 zsock_join (void *self, const char *group);
2646
2647 // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH.
2648 // Returns 0 if OK, -1 if failed.
2649 int
2650 zsock_leave (void *self, const char *group);
2651
2652 // Probe the supplied object, and report if it looks like a zsock_t.
2653 // Takes a polymorphic socket reference.
2654 bool
2655 zsock_is (void *self);
2656
2657 // Probe the supplied reference. If it looks like a zsock_t instance, return
2658 // the underlying libzmq socket handle; else if it looks like a file
2659 // descriptor, return NULL; else if it looks like a libzmq socket handle,
2660 // return the supplied value. Takes a polymorphic socket reference.
2661 void *
2662 zsock_resolve (void *self);
2663
2664 // Get socket option `heartbeat_ivl`.
2665 // Available from libzmq 4.2.0.
2666 int
2667 zsock_heartbeat_ivl (void *self);
2668
2669 // Set socket option `heartbeat_ivl`.
2670 // Available from libzmq 4.2.0.
2671 void
2672 zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl);
2673
2674 // Get socket option `heartbeat_ttl`.
2675 // Available from libzmq 4.2.0.
2676 int
2677 zsock_heartbeat_ttl (void *self);
2678
2679 // Set socket option `heartbeat_ttl`.
2680 // Available from libzmq 4.2.0.
2681 void
2682 zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl);
2683
2684 // Get socket option `heartbeat_timeout`.
2685 // Available from libzmq 4.2.0.
2686 int
2687 zsock_heartbeat_timeout (void *self);
2688
2689 // Set socket option `heartbeat_timeout`.
2690 // Available from libzmq 4.2.0.
2691 void
2692 zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout);
2693
2694 // Get socket option `use_fd`.
2695 // Available from libzmq 4.2.0.
2696 int
2697 zsock_use_fd (void *self);
2698
2699 // Set socket option `use_fd`.
2700 // Available from libzmq 4.2.0.
2701 void
2702 zsock_set_use_fd (void *self, int use_fd);
2703
2704 // Set socket option `xpub_manual`.
2705 // Available from libzmq 4.2.0.
2706 void
2707 zsock_set_xpub_manual (void *self, int xpub_manual);
2708
2709 // Set socket option `xpub_welcome_msg`.
2710 // Available from libzmq 4.2.0.
2711 void
2712 zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg);
2713
2714 // Set socket option `stream_notify`.
2715 // Available from libzmq 4.2.0.
2716 void
2717 zsock_set_stream_notify (void *self, int stream_notify);
2718
2719 // Get socket option `invert_matching`.
2720 // Available from libzmq 4.2.0.
2721 int
2722 zsock_invert_matching (void *self);
2723
2724 // Set socket option `invert_matching`.
2725 // Available from libzmq 4.2.0.
2726 void
2727 zsock_set_invert_matching (void *self, int invert_matching);
2728
2729 // Set socket option `xpub_verboser`.
2730 // Available from libzmq 4.2.0.
2731 void
2732 zsock_set_xpub_verboser (void *self, int xpub_verboser);
2733
2734 // Get socket option `connect_timeout`.
2735 // Available from libzmq 4.2.0.
2736 int
2737 zsock_connect_timeout (void *self);
2738
2739 // Set socket option `connect_timeout`.
2740 // Available from libzmq 4.2.0.
2741 void
2742 zsock_set_connect_timeout (void *self, int connect_timeout);
2743
2744 // Get socket option `tcp_maxrt`.
2745 // Available from libzmq 4.2.0.
2746 int
2747 zsock_tcp_maxrt (void *self);
2748
2749 // Set socket option `tcp_maxrt`.
2750 // Available from libzmq 4.2.0.
2751 void
2752 zsock_set_tcp_maxrt (void *self, int tcp_maxrt);
2753
2754 // Get socket option `thread_safe`.
2755 // Available from libzmq 4.2.0.
2756 int
2757 zsock_thread_safe (void *self);
2758
2759 // Get socket option `multicast_maxtpdu`.
2760 // Available from libzmq 4.2.0.
2761 int
2762 zsock_multicast_maxtpdu (void *self);
2763
2764 // Set socket option `multicast_maxtpdu`.
2765 // Available from libzmq 4.2.0.
2766 void
2767 zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu);
2768
2769 // Get socket option `vmci_buffer_size`.
2770 // Available from libzmq 4.2.0.
2771 int
2772 zsock_vmci_buffer_size (void *self);
2773
2774 // Set socket option `vmci_buffer_size`.
2775 // Available from libzmq 4.2.0.
2776 void
2777 zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size);
2778
2779 // Get socket option `vmci_buffer_min_size`.
2780 // Available from libzmq 4.2.0.
2781 int
2782 zsock_vmci_buffer_min_size (void *self);
2783
2784 // Set socket option `vmci_buffer_min_size`.
2785 // Available from libzmq 4.2.0.
2786 void
2787 zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size);
2788
2789 // Get socket option `vmci_buffer_max_size`.
2790 // Available from libzmq 4.2.0.
2791 int
2792 zsock_vmci_buffer_max_size (void *self);
2793
2794 // Set socket option `vmci_buffer_max_size`.
2795 // Available from libzmq 4.2.0.
2796 void
2797 zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size);
2798
2799 // Get socket option `vmci_connect_timeout`.
2800 // Available from libzmq 4.2.0.
2801 int
2802 zsock_vmci_connect_timeout (void *self);
2803
2804 // Set socket option `vmci_connect_timeout`.
2805 // Available from libzmq 4.2.0.
2806 void
2807 zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout);
2808
2809 // Get socket option `tos`.
2810 // Available from libzmq 4.1.0.
2811 int
2812 zsock_tos (void *self);
2813
2814 // Set socket option `tos`.
2815 // Available from libzmq 4.1.0.
2816 void
2817 zsock_set_tos (void *self, int tos);
2818
2819 // Set socket option `router_handover`.
2820 // Available from libzmq 4.1.0.
2821 void
2822 zsock_set_router_handover (void *self, int router_handover);
2823
2824 // Set socket option `connect_rid`.
2825 // Available from libzmq 4.1.0.
2826 void
2827 zsock_set_connect_rid (void *self, const char *connect_rid);
2828
2829 // Set socket option `connect_rid` from 32-octet binary
2830 // Available from libzmq 4.1.0.
2831 void
2832 zsock_set_connect_rid_bin (void *self, const byte *connect_rid);
2833
2834 // Get socket option `handshake_ivl`.
2835 // Available from libzmq 4.1.0.
2836 int
2837 zsock_handshake_ivl (void *self);
2838
2839 // Set socket option `handshake_ivl`.
2840 // Available from libzmq 4.1.0.
2841 void
2842 zsock_set_handshake_ivl (void *self, int handshake_ivl);
2843
2844 // Get socket option `socks_proxy`.
2845 // Available from libzmq 4.1.0.
2846 char *
2847 zsock_socks_proxy (void *self);
2848
2849 // Set socket option `socks_proxy`.
2850 // Available from libzmq 4.1.0.
2851 void
2852 zsock_set_socks_proxy (void *self, const char *socks_proxy);
2853
2854 // Set socket option `xpub_nodrop`.
2855 // Available from libzmq 4.1.0.
2856 void
2857 zsock_set_xpub_nodrop (void *self, int xpub_nodrop);
2858
2859 // Set socket option `router_mandatory`.
2860 // Available from libzmq 4.0.0.
2861 void
2862 zsock_set_router_mandatory (void *self, int router_mandatory);
2863
2864 // Set socket option `probe_router`.
2865 // Available from libzmq 4.0.0.
2866 void
2867 zsock_set_probe_router (void *self, int probe_router);
2868
2869 // Set socket option `req_relaxed`.
2870 // Available from libzmq 4.0.0.
2871 void
2872 zsock_set_req_relaxed (void *self, int req_relaxed);
2873
2874 // Set socket option `req_correlate`.
2875 // Available from libzmq 4.0.0.
2876 void
2877 zsock_set_req_correlate (void *self, int req_correlate);
2878
2879 // Set socket option `conflate`.
2880 // Available from libzmq 4.0.0.
2881 void
2882 zsock_set_conflate (void *self, int conflate);
2883
2884 // Get socket option `zap_domain`.
2885 // Available from libzmq 4.0.0.
2886 char *
2887 zsock_zap_domain (void *self);
2888
2889 // Set socket option `zap_domain`.
2890 // Available from libzmq 4.0.0.
2891 void
2892 zsock_set_zap_domain (void *self, const char *zap_domain);
2893
2894 // Get socket option `mechanism`.
2895 // Available from libzmq 4.0.0.
2896 int
2897 zsock_mechanism (void *self);
2898
2899 // Get socket option `plain_server`.
2900 // Available from libzmq 4.0.0.
2901 int
2902 zsock_plain_server (void *self);
2903
2904 // Set socket option `plain_server`.
2905 // Available from libzmq 4.0.0.
2906 void
2907 zsock_set_plain_server (void *self, int plain_server);
2908
2909 // Get socket option `plain_username`.
2910 // Available from libzmq 4.0.0.
2911 char *
2912 zsock_plain_username (void *self);
2913
2914 // Set socket option `plain_username`.
2915 // Available from libzmq 4.0.0.
2916 void
2917 zsock_set_plain_username (void *self, const char *plain_username);
2918
2919 // Get socket option `plain_password`.
2920 // Available from libzmq 4.0.0.
2921 char *
2922 zsock_plain_password (void *self);
2923
2924 // Set socket option `plain_password`.
2925 // Available from libzmq 4.0.0.
2926 void
2927 zsock_set_plain_password (void *self, const char *plain_password);
2928
2929 // Get socket option `curve_server`.
2930 // Available from libzmq 4.0.0.
2931 int
2932 zsock_curve_server (void *self);
2933
2934 // Set socket option `curve_server`.
2935 // Available from libzmq 4.0.0.
2936 void
2937 zsock_set_curve_server (void *self, int curve_server);
2938
2939 // Get socket option `curve_publickey`.
2940 // Available from libzmq 4.0.0.
2941 char *
2942 zsock_curve_publickey (void *self);
2943
2944 // Set socket option `curve_publickey`.
2945 // Available from libzmq 4.0.0.
2946 void
2947 zsock_set_curve_publickey (void *self, const char *curve_publickey);
2948
2949 // Set socket option `curve_publickey` from 32-octet binary
2950 // Available from libzmq 4.0.0.
2951 void
2952 zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey);
2953
2954 // Get socket option `curve_secretkey`.
2955 // Available from libzmq 4.0.0.
2956 char *
2957 zsock_curve_secretkey (void *self);
2958
2959 // Set socket option `curve_secretkey`.
2960 // Available from libzmq 4.0.0.
2961 void
2962 zsock_set_curve_secretkey (void *self, const char *curve_secretkey);
2963
2964 // Set socket option `curve_secretkey` from 32-octet binary
2965 // Available from libzmq 4.0.0.
2966 void
2967 zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey);
2968
2969 // Get socket option `curve_serverkey`.
2970 // Available from libzmq 4.0.0.
2971 char *
2972 zsock_curve_serverkey (void *self);
2973
2974 // Set socket option `curve_serverkey`.
2975 // Available from libzmq 4.0.0.
2976 void
2977 zsock_set_curve_serverkey (void *self, const char *curve_serverkey);
2978
2979 // Set socket option `curve_serverkey` from 32-octet binary
2980 // Available from libzmq 4.0.0.
2981 void
2982 zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey);
2983
2984 // Get socket option `gssapi_server`.
2985 // Available from libzmq 4.0.0.
2986 int
2987 zsock_gssapi_server (void *self);
2988
2989 // Set socket option `gssapi_server`.
2990 // Available from libzmq 4.0.0.
2991 void
2992 zsock_set_gssapi_server (void *self, int gssapi_server);
2993
2994 // Get socket option `gssapi_plaintext`.
2995 // Available from libzmq 4.0.0.
2996 int
2997 zsock_gssapi_plaintext (void *self);
2998
2999 // Set socket option `gssapi_plaintext`.
3000 // Available from libzmq 4.0.0.
3001 void
3002 zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
3003
3004 // Get socket option `gssapi_principal`.
3005 // Available from libzmq 4.0.0.
3006 char *
3007 zsock_gssapi_principal (void *self);
3008
3009 // Set socket option `gssapi_principal`.
3010 // Available from libzmq 4.0.0.
3011 void
3012 zsock_set_gssapi_principal (void *self, const char *gssapi_principal);
3013
3014 // Get socket option `gssapi_service_principal`.
3015 // Available from libzmq 4.0.0.
3016 char *
3017 zsock_gssapi_service_principal (void *self);
3018
3019 // Set socket option `gssapi_service_principal`.
3020 // Available from libzmq 4.0.0.
3021 void
3022 zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal);
3023
3024 // Get socket option `ipv6`.
3025 // Available from libzmq 4.0.0.
3026 int
3027 zsock_ipv6 (void *self);
3028
3029 // Set socket option `ipv6`.
3030 // Available from libzmq 4.0.0.
3031 void
3032 zsock_set_ipv6 (void *self, int ipv6);
3033
3034 // Get socket option `immediate`.
3035 // Available from libzmq 4.0.0.
3036 int
3037 zsock_immediate (void *self);
3038
3039 // Set socket option `immediate`.
3040 // Available from libzmq 4.0.0.
3041 void
3042 zsock_set_immediate (void *self, int immediate);
3043
3044 // Get socket option `sndhwm`.
3045 // Available from libzmq 3.0.0.
3046 int
3047 zsock_sndhwm (void *self);
3048
3049 // Set socket option `sndhwm`.
3050 // Available from libzmq 3.0.0.
3051 void
3052 zsock_set_sndhwm (void *self, int sndhwm);
3053
3054 // Get socket option `rcvhwm`.
3055 // Available from libzmq 3.0.0.
3056 int
3057 zsock_rcvhwm (void *self);
3058
3059 // Set socket option `rcvhwm`.
3060 // Available from libzmq 3.0.0.
3061 void
3062 zsock_set_rcvhwm (void *self, int rcvhwm);
3063
3064 // Get socket option `maxmsgsize`.
3065 // Available from libzmq 3.0.0.
3066 int
3067 zsock_maxmsgsize (void *self);
3068
3069 // Set socket option `maxmsgsize`.
3070 // Available from libzmq 3.0.0.
3071 void
3072 zsock_set_maxmsgsize (void *self, int maxmsgsize);
3073
3074 // Get socket option `multicast_hops`.
3075 // Available from libzmq 3.0.0.
3076 int
3077 zsock_multicast_hops (void *self);
3078
3079 // Set socket option `multicast_hops`.
3080 // Available from libzmq 3.0.0.
3081 void
3082 zsock_set_multicast_hops (void *self, int multicast_hops);
3083
3084 // Set socket option `xpub_verbose`.
3085 // Available from libzmq 3.0.0.
3086 void
3087 zsock_set_xpub_verbose (void *self, int xpub_verbose);
3088
3089 // Get socket option `tcp_keepalive`.
3090 // Available from libzmq 3.0.0.
3091 int
3092 zsock_tcp_keepalive (void *self);
3093
3094 // Set socket option `tcp_keepalive`.
3095 // Available from libzmq 3.0.0.
3096 void
3097 zsock_set_tcp_keepalive (void *self, int tcp_keepalive);
3098
3099 // Get socket option `tcp_keepalive_idle`.
3100 // Available from libzmq 3.0.0.
3101 int
3102 zsock_tcp_keepalive_idle (void *self);
3103
3104 // Set socket option `tcp_keepalive_idle`.
3105 // Available from libzmq 3.0.0.
3106 void
3107 zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle);
3108
3109 // Get socket option `tcp_keepalive_cnt`.
3110 // Available from libzmq 3.0.0.
3111 int
3112 zsock_tcp_keepalive_cnt (void *self);
3113
3114 // Set socket option `tcp_keepalive_cnt`.
3115 // Available from libzmq 3.0.0.
3116 void
3117 zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt);
3118
3119 // Get socket option `tcp_keepalive_intvl`.
3120 // Available from libzmq 3.0.0.
3121 int
3122 zsock_tcp_keepalive_intvl (void *self);
3123
3124 // Set socket option `tcp_keepalive_intvl`.
3125 // Available from libzmq 3.0.0.
3126 void
3127 zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl);
3128
3129 // Get socket option `tcp_accept_filter`.
3130 // Available from libzmq 3.0.0.
3131 char *
3132 zsock_tcp_accept_filter (void *self);
3133
3134 // Set socket option `tcp_accept_filter`.
3135 // Available from libzmq 3.0.0.
3136 void
3137 zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter);
3138
3139 // Get socket option `last_endpoint`.
3140 // Available from libzmq 3.0.0.
3141 char *
3142 zsock_last_endpoint (void *self);
3143
3144 // Set socket option `router_raw`.
3145 // Available from libzmq 3.0.0.
3146 void
3147 zsock_set_router_raw (void *self, int router_raw);
3148
3149 // Get socket option `ipv4only`.
3150 // Available from libzmq 3.0.0.
3151 int
3152 zsock_ipv4only (void *self);
3153
3154 // Set socket option `ipv4only`.
3155 // Available from libzmq 3.0.0.
3156 void
3157 zsock_set_ipv4only (void *self, int ipv4only);
3158
3159 // Set socket option `delay_attach_on_connect`.
3160 // Available from libzmq 3.0.0.
3161 void
3162 zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
3163
3164 // Get socket option `hwm`.
3165 // Available from libzmq 2.0.0 to 3.0.0.
3166 int
3167 zsock_hwm (void *self);
3168
3169 // Set socket option `hwm`.
3170 // Available from libzmq 2.0.0 to 3.0.0.
3171 void
3172 zsock_set_hwm (void *self, int hwm);
3173
3174 // Get socket option `swap`.
3175 // Available from libzmq 2.0.0 to 3.0.0.
3176 int
3177 zsock_swap (void *self);
3178
3179 // Set socket option `swap`.
3180 // Available from libzmq 2.0.0 to 3.0.0.
3181 void
3182 zsock_set_swap (void *self, int swap);
3183
3184 // Get socket option `affinity`.
3185 // Available from libzmq 2.0.0.
3186 int
3187 zsock_affinity (void *self);
3188
3189 // Set socket option `affinity`.
3190 // Available from libzmq 2.0.0.
3191 void
3192 zsock_set_affinity (void *self, int affinity);
3193
3194 // Get socket option `identity`.
3195 // Available from libzmq 2.0.0.
3196 char *
3197 zsock_identity (void *self);
3198
3199 // Set socket option `identity`.
3200 // Available from libzmq 2.0.0.
3201 void
3202 zsock_set_identity (void *self, const char *identity);
3203
3204 // Get socket option `rate`.
3205 // Available from libzmq 2.0.0.
3206 int
3207 zsock_rate (void *self);
3208
3209 // Set socket option `rate`.
3210 // Available from libzmq 2.0.0.
3211 void
3212 zsock_set_rate (void *self, int rate);
3213
3214 // Get socket option `recovery_ivl`.
3215 // Available from libzmq 2.0.0.
3216 int
3217 zsock_recovery_ivl (void *self);
3218
3219 // Set socket option `recovery_ivl`.
3220 // Available from libzmq 2.0.0.
3221 void
3222 zsock_set_recovery_ivl (void *self, int recovery_ivl);
3223
3224 // Get socket option `recovery_ivl_msec`.
3225 // Available from libzmq 2.0.0 to 3.0.0.
3226 int
3227 zsock_recovery_ivl_msec (void *self);
3228
3229 // Set socket option `recovery_ivl_msec`.
3230 // Available from libzmq 2.0.0 to 3.0.0.
3231 void
3232 zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec);
3233
3234 // Get socket option `mcast_loop`.
3235 // Available from libzmq 2.0.0 to 3.0.0.
3236 int
3237 zsock_mcast_loop (void *self);
3238
3239 // Set socket option `mcast_loop`.
3240 // Available from libzmq 2.0.0 to 3.0.0.
3241 void
3242 zsock_set_mcast_loop (void *self, int mcast_loop);
3243
3244 // Get socket option `rcvtimeo`.
3245 // Available from libzmq 2.2.0.
3246 int
3247 zsock_rcvtimeo (void *self);
3248
3249 // Set socket option `rcvtimeo`.
3250 // Available from libzmq 2.2.0.
3251 void
3252 zsock_set_rcvtimeo (void *self, int rcvtimeo);
3253
3254 // Get socket option `sndtimeo`.
3255 // Available from libzmq 2.2.0.
3256 int
3257 zsock_sndtimeo (void *self);
3258
3259 // Set socket option `sndtimeo`.
3260 // Available from libzmq 2.2.0.
3261 void
3262 zsock_set_sndtimeo (void *self, int sndtimeo);
3263
3264 // Get socket option `sndbuf`.
3265 // Available from libzmq 2.0.0.
3266 int
3267 zsock_sndbuf (void *self);
3268
3269 // Set socket option `sndbuf`.
3270 // Available from libzmq 2.0.0.
3271 void
3272 zsock_set_sndbuf (void *self, int sndbuf);
3273
3274 // Get socket option `rcvbuf`.
3275 // Available from libzmq 2.0.0.
3276 int
3277 zsock_rcvbuf (void *self);
3278
3279 // Set socket option `rcvbuf`.
3280 // Available from libzmq 2.0.0.
3281 void
3282 zsock_set_rcvbuf (void *self, int rcvbuf);
3283
3284 // Get socket option `linger`.
3285 // Available from libzmq 2.0.0.
3286 int
3287 zsock_linger (void *self);
3288
3289 // Set socket option `linger`.
3290 // Available from libzmq 2.0.0.
3291 void
3292 zsock_set_linger (void *self, int linger);
3293
3294 // Get socket option `reconnect_ivl`.
3295 // Available from libzmq 2.0.0.
3296 int
3297 zsock_reconnect_ivl (void *self);
3298
3299 // Set socket option `reconnect_ivl`.
3300 // Available from libzmq 2.0.0.
3301 void
3302 zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
3303
3304 // Get socket option `reconnect_ivl_max`.
3305 // Available from libzmq 2.0.0.
3306 int
3307 zsock_reconnect_ivl_max (void *self);
3308
3309 // Set socket option `reconnect_ivl_max`.
3310 // Available from libzmq 2.0.0.
3311 void
3312 zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
3313
3314 // Get socket option `backlog`.
3315 // Available from libzmq 2.0.0.
3316 int
3317 zsock_backlog (void *self);
3318
3319 // Set socket option `backlog`.
3320 // Available from libzmq 2.0.0.
3321 void
3322 zsock_set_backlog (void *self, int backlog);
3323
3324 // Set socket option `subscribe`.
3325 // Available from libzmq 2.0.0.
3326 void
3327 zsock_set_subscribe (void *self, const char *subscribe);
3328
3329 // Set socket option `unsubscribe`.
3330 // Available from libzmq 2.0.0.
3331 void
3332 zsock_set_unsubscribe (void *self, const char *unsubscribe);
3333
3334 // Get socket option `type`.
3335 // Available from libzmq 2.0.0.
3336 int
3337 zsock_type (void *self);
3338
3339 // Get socket option `rcvmore`.
3340 // Available from libzmq 2.0.0.
3341 int
3342 zsock_rcvmore (void *self);
3343
3344 // Get socket option `fd`.
3345 // Available from libzmq 2.0.0.
3346 SOCKET
3347 zsock_fd (void *self);
3348
3349 // Get socket option `events`.
3350 // Available from libzmq 2.0.0.
3351 int
3352 zsock_events (void *self);
3353
3354 // Self test of this class.
3355 void
3356 zsock_test (bool verbose);
3357
3358 // CLASS: zstr
3359 // Receive C string from socket. Caller must free returned string using
3360 // zstr_free(). Returns NULL if the context is being terminated or the
3361 // process was interrupted.
3362 char *
3363 zstr_recv (void *source);
3364
3365 // Receive a series of strings (until NULL) from multipart data.
3366 // Each string is allocated and filled with string data; if there
3367 // are not enough frames, unallocated strings are set to NULL.
3368 // Returns -1 if the message could not be read, else returns the
3369 // number of strings filled, zero or more. Free each returned string
3370 // using zstr_free(). If not enough strings are provided, remaining
3371 // multipart frames in the message are dropped.
3372 int
3373 zstr_recvx (void *source, char **string_p, ...);
3374
3375 // De-compress and receive C string from socket, received as a message
3376 // with two frames: size of the uncompressed string, and the string itself.
3377 // Caller must free returned string using zstr_free(). Returns NULL if the
3378 // context is being terminated or the process was interrupted.
3379 char *
3380 zstr_recv_compress (void *source);
3381
3382 // Send a C string to a socket, as a frame. The string is sent without
3383 // trailing null byte; to read this you can use zstr_recv, or a similar
3384 // method that adds a null terminator on the received string. String
3385 // may be NULL, which is sent as "".
3386 int
3387 zstr_send (void *dest, const char *string);
3388
3389 // Send a C string to a socket, as zstr_send(), with a MORE flag, so that
3390 // you can send further strings in the same multi-part message.
3391 int
3392 zstr_sendm (void *dest, const char *string);
3393
3394 // Send a formatted string to a socket. Note that you should NOT use
3395 // user-supplied strings in the format (they may contain '%' which
3396 // will create security holes).
3397 int
3398 zstr_sendf (void *dest, const char *format, ...);
3399
3400 // Send a formatted string to a socket, as for zstr_sendf(), with a
3401 // MORE flag, so that you can send further strings in the same multi-part
3402 // message.
3403 int
3404 zstr_sendfm (void *dest, const char *format, ...);
3405
3406 // Send a series of strings (until NULL) as multipart data
3407 // Returns 0 if the strings could be sent OK, or -1 on error.
3408 int
3409 zstr_sendx (void *dest, const char *string, ...);
3410
3411 // Compress and send a C string to a socket, as a message with two frames:
3412 // size of the uncompressed string, and the string itself. The string is
3413 // sent without trailing null byte; to read this you can use
3414 // zstr_recv_compress, or a similar method that de-compresses and adds a
3415 // null terminator on the received string.
3416 int
3417 zstr_send_compress (void *dest, const char *string);
3418
3419 // Compress and send a C string to a socket, as zstr_send_compress(),
3420 // with a MORE flag, so that you can send further strings in the same
3421 // multi-part message.
3422 int
3423 zstr_sendm_compress (void *dest, const char *string);
3424
3425 // Accepts a void pointer and returns a fresh character string. If source
3426 // is null, returns an empty string.
3427 char *
3428 zstr_str (void *source);
3429
3430 // Free a provided string, and nullify the parent pointer. Safe to call on
3431 // a null pointer.
3432 void
3433 zstr_free (char **string_p);
3434
3435 // Self test of this class.
3436 void
3437 zstr_test (bool verbose);
3438
3439 // CLASS: zsys
3440 // Initialize CZMQ zsys layer; this happens automatically when you create
3441 // a socket or an actor; however this call lets you force initialization
3442 // earlier, so e.g. logging is properly set-up before you start working.
3443 // Not threadsafe, so call only from main thread. Safe to call multiple
3444 // times. Returns global CZMQ context.
3445 void *
3446 zsys_init (void);
3447
3448 // Optionally shut down the CZMQ zsys layer; this normally happens automatically
3449 // when the process exits; however this call lets you force a shutdown
3450 // earlier, avoiding any potential problems with atexit() ordering, especially
3451 // with Windows dlls.
3452 void
3453 zsys_shutdown (void);
3454
3455 // Get a new ZMQ socket, automagically creating a ZMQ context if this is
3456 // the first time. Caller is responsible for destroying the ZMQ socket
3457 // before process exits, to avoid a ZMQ deadlock. Note: you should not use
3458 // this method in CZMQ apps, use zsock_new() instead.
3459 // *** This is for CZMQ internal use only and may change arbitrarily ***
3460 void *
3461 zsys_socket (int type, const char *filename, size_t line_nbr);
3462
3463 // Destroy/close a ZMQ socket. You should call this for every socket you
3464 // create using zsys_socket().
3465 // *** This is for CZMQ internal use only and may change arbitrarily ***
3466 int
3467 zsys_close (void *handle, const char *filename, size_t line_nbr);
3468
3469 // Return ZMQ socket name for socket type
3470 // *** This is for CZMQ internal use only and may change arbitrarily ***
3471 char *
3472 zsys_sockname (int socktype);
3473
3474 // Create a pipe, which consists of two PAIR sockets connected over inproc.
3475 // The pipe is configured to use the zsys_pipehwm setting. Returns the
3476 // frontend socket successful, NULL if failed.
3477 zsock_t *
3478 zsys_create_pipe (zsock_t **backend_p);
3479
3480 // Set interrupt handler; this saves the default handlers so that a
3481 // zsys_handler_reset () can restore them. If you call this multiple times
3482 // then the last handler will take affect. If handler_fn is NULL, disables
3483 // default SIGINT/SIGTERM handling in CZMQ.
3484 void
3485 zsys_handler_set (zsys_handler_fn *handler_fn);
3486
3487 // Reset interrupt handler, call this at exit if needed
3488 void
3489 zsys_handler_reset (void);
3490
3491 // Set default interrupt handler, so Ctrl-C or SIGTERM will set
3492 // zsys_interrupted. Idempotent; safe to call multiple times.
3493 // Can be supressed by ZSYS_SIGHANDLER=false
3494 // *** This is for CZMQ internal use only and may change arbitrarily ***
3495 void
3496 zsys_catch_interrupts (void);
3497
3498 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
3499 // Does not work if ZSYS_SIGHANDLER is false and code does not call
3500 // set interrupted on signal.
3501 bool
3502 zsys_is_interrupted (void);
3503
3504 // Set interrupted flag. This is done by default signal handler, however
3505 // this can be handy for language bindings or cases without default
3506 // signal handler.
3507 void
3508 zsys_set_interrupted (void);
3509
3510 // Return 1 if file exists, else zero
3511 bool
3512 zsys_file_exists (const char *filename);
3513
3514 // Return file modification time. Returns 0 if the file does not exist.
3515 time_t
3516 zsys_file_modified (const char *filename);
3517
3518 // Return file mode; provides at least support for the POSIX S_ISREG(m)
3519 // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes.
3520 // Returns a mode_t cast to int, or -1 in case of error.
3521 int
3522 zsys_file_mode (const char *filename);
3523
3524 // Delete file. Does not complain if the file is absent
3525 int
3526 zsys_file_delete (const char *filename);
3527
3528 // Check if file is 'stable'
3529 bool
3530 zsys_file_stable (const char *filename);
3531
3532 // Create a file path if it doesn't exist. The file path is treated as
3533 // printf format.
3534 int
3535 zsys_dir_create (const char *pathname, ...);
3536
3537 // Remove a file path if empty; the pathname is treated as printf format.
3538 int
3539 zsys_dir_delete (const char *pathname, ...);
3540
3541 // Move to a specified working directory. Returns 0 if OK, -1 if this failed.
3542 int
3543 zsys_dir_change (const char *pathname);
3544
3545 // Set private file creation mode; all files created from here will be
3546 // readable/writable by the owner only.
3547 void
3548 zsys_file_mode_private (void);
3549
3550 // Reset default file creation mode; all files created from here will use
3551 // process file mode defaults.
3552 void
3553 zsys_file_mode_default (void);
3554
3555 // Return the CZMQ version for run-time API detection; returns version
3556 // number into provided fields, providing reference isn't null in each case.
3557 void
3558 zsys_version (int *major, int *minor, int *patch);
3559
3560 // Format a string using printf formatting, returning a freshly allocated
3561 // buffer. If there was insufficient memory, returns NULL. Free the returned
3562 // string using zstr_free().
3563 char *
3564 zsys_sprintf (const char *format, ...);
3565
3566 // Format a string with a va_list argument, returning a freshly allocated
3567 // buffer. If there was insufficient memory, returns NULL. Free the returned
3568 // string using zstr_free().
3569 char *
3570 zsys_vprintf (const char *format, va_list argptr);
3571
3572 // Create UDP beacon socket; if the routable option is true, uses
3573 // multicast (not yet implemented), else uses broadcast. This method
3574 // and related ones might _eventually_ be moved to a zudp class.
3575 // *** This is for CZMQ internal use only and may change arbitrarily ***
3576 SOCKET
3577 zsys_udp_new (bool routable);
3578
3579 // Close a UDP socket
3580 // *** This is for CZMQ internal use only and may change arbitrarily ***
3581 int
3582 zsys_udp_close (SOCKET handle);
3583
3584 // Send zframe to UDP socket, return -1 if sending failed due to
3585 // interface having disappeared (happens easily with WiFi)
3586 // *** This is for CZMQ internal use only and may change arbitrarily ***
3587 int
3588 zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen);
3589
3590 // Receive zframe from UDP socket, and set address of peer that sent it
3591 // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or
3592 // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address.
3593 // *** This is for CZMQ internal use only and may change arbitrarily ***
3594 zframe_t *
3595 zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen);
3596
3597 // Handle an I/O error on some socket operation; will report and die on
3598 // fatal errors, and continue silently on "try again" errors.
3599 // *** This is for CZMQ internal use only and may change arbitrarily ***
3600 void
3601 zsys_socket_error (const char *reason);
3602
3603 // Return current host name, for use in public tcp:// endpoints. Caller gets
3604 // a freshly allocated string, should free it using zstr_free(). If the host
3605 // name is not resolvable, returns NULL.
3606 char *
3607 zsys_hostname (void);
3608
3609 // Move the current process into the background. The precise effect depends
3610 // on the operating system. On POSIX boxes, moves to a specified working
3611 // directory (if specified), closes all file handles, reopens stdin, stdout,
3612 // and stderr to the null device, and sets the process to ignore SIGHUP. On
3613 // Windows, does nothing. Returns 0 if OK, -1 if there was an error.
3614 int
3615 zsys_daemonize (const char *workdir);
3616
3617 // Drop the process ID into the lockfile, with exclusive lock, and switch
3618 // the process to the specified group and/or user. Any of the arguments
3619 // may be null, indicating a no-op. Returns 0 on success, -1 on failure.
3620 // Note if you combine this with zsys_daemonize, run after, not before
3621 // that method, or the lockfile will hold the wrong process ID.
3622 int
3623 zsys_run_as (const char *lockfile, const char *group, const char *user);
3624
3625 // Returns true if the underlying libzmq supports CURVE security.
3626 // Uses a heuristic probe according to the version of libzmq being used.
3627 bool
3628 zsys_has_curve (void);
3629
3630 // Configure the number of I/O threads that ZeroMQ will use. A good
3631 // rule of thumb is one thread per gigabit of traffic in or out. The
3632 // default is 1, sufficient for most applications. If the environment
3633 // variable ZSYS_IO_THREADS is defined, that provides the default.
3634 // Note that this method is valid only before any socket is created.
3635 void
3636 zsys_set_io_threads (size_t io_threads);
3637
3638 // Configure the scheduling policy of the ZMQ context thread pool.
3639 // Not available on Windows. See the sched_setscheduler man page or sched.h
3640 // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY
3641 // is defined, that provides the default.
3642 // Note that this method is valid only before any socket is created.
3643 void
3644 zsys_set_thread_sched_policy (int policy);
3645
3646 // Configure the scheduling priority of the ZMQ context thread pool.
3647 // Not available on Windows. See the sched_setscheduler man page or sched.h
3648 // for more information. If the environment variable ZSYS_THREAD_PRIORITY is
3649 // defined, that provides the default.
3650 // Note that this method is valid only before any socket is created.
3651 void
3652 zsys_set_thread_priority (int priority);
3653
3654 // Configure the number of sockets that ZeroMQ will allow. The default
3655 // is 1024. The actual limit depends on the system, and you can query it
3656 // by using zsys_socket_limit (). A value of zero means "maximum".
3657 // Note that this method is valid only before any socket is created.
3658 void
3659 zsys_set_max_sockets (size_t max_sockets);
3660
3661 // Return maximum number of ZeroMQ sockets that the system will support.
3662 size_t
3663 zsys_socket_limit (void);
3664
3665 // Configure the maximum allowed size of a message sent.
3666 // The default is INT_MAX.
3667 void
3668 zsys_set_max_msgsz (int max_msgsz);
3669
3670 // Return maximum message size.
3671 int
3672 zsys_max_msgsz (void);
3673
3674 // Configure whether to use zero copy strategy in libzmq. If the environment
3675 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
3676 // Otherwise the default is 1.
3677 void
3678 zsys_set_zero_copy_recv (int zero_copy);
3679
3680 // Return ZMQ_ZERO_COPY_RECV option.
3681 int
3682 zsys_zero_copy_recv (void);
3683
3684 // Configure the threshold value of filesystem object age per st_mtime
3685 // that should elapse until we consider that object "stable" at the
3686 // current zclock_time() moment.
3687 // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
3688 // which generally depends on host OS, with fallback value of 5000.
3689 void
3690 zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);
3691
3692 // Return current threshold value of file stable age in msec.
3693 // This can be used in code that chooses to wait for this timeout
3694 // before testing if a filesystem object is "stable" or not.
3695 int64_t
3696 zsys_file_stable_age_msec (void);
3697
3698 // Configure the default linger timeout in msecs for new zsock instances.
3699 // You can also set this separately on each zsock_t instance. The default
3700 // linger time is zero, i.e. any pending messages will be dropped. If the
3701 // environment variable ZSYS_LINGER is defined, that provides the default.
3702 // Note that process exit will typically be delayed by the linger time.
3703 void
3704 zsys_set_linger (size_t linger);
3705
3706 // Configure the default outgoing pipe limit (HWM) for new zsock instances.
3707 // You can also set this separately on each zsock_t instance. The default
3708 // HWM is 1,000, on all versions of ZeroMQ. If the environment variable
3709 // ZSYS_SNDHWM is defined, that provides the default. Note that a value of
3710 // zero means no limit, i.e. infinite memory consumption.
3711 void
3712 zsys_set_sndhwm (size_t sndhwm);
3713
3714 // Configure the default incoming pipe limit (HWM) for new zsock instances.
3715 // You can also set this separately on each zsock_t instance. The default
3716 // HWM is 1,000, on all versions of ZeroMQ. If the environment variable
3717 // ZSYS_RCVHWM is defined, that provides the default. Note that a value of
3718 // zero means no limit, i.e. infinite memory consumption.
3719 void
3720 zsys_set_rcvhwm (size_t rcvhwm);
3721
3722 // Configure the default HWM for zactor internal pipes; this is set on both
3723 // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is
3724 // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is
3725 // defined, that provides the default. Note that a value of zero means no
3726 // limit, i.e. infinite memory consumption.
3727 void
3728 zsys_set_pipehwm (size_t pipehwm);
3729
3730 // Return the HWM for zactor internal pipes.
3731 size_t
3732 zsys_pipehwm (void);
3733
3734 // Configure use of IPv6 for new zsock instances. By default sockets accept
3735 // and make only IPv4 connections. When you enable IPv6, sockets will accept
3736 // and connect to both IPv4 and IPv6 peers. You can override the setting on
3737 // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the
3738 // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the
3739 // default. Note: has no effect on ZMQ v2.
3740 void
3741 zsys_set_ipv6 (int ipv6);
3742
3743 // Return use of IPv6 for zsock instances.
3744 int
3745 zsys_ipv6 (void);
3746
3747 // Set network interface name to use for broadcasts, particularly zbeacon.
3748 // This lets the interface be configured for test environments where required.
3749 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
3750 // the default when there is no specified interface. If the environment
3751 // variable ZSYS_INTERFACE is set, use that as the default interface name.
3752 // Setting the interface to "*" means "use all available interfaces".
3753 void
3754 zsys_set_interface (const char *value);
3755
3756 // Return network interface to use for broadcasts, or "" if none was set.
3757 const char *
3758 zsys_interface (void);
3759
3760 // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon.
3761 // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses
3762 // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set,
3763 // use that as the default IPv6 address.
3764 void
3765 zsys_set_ipv6_address (const char *value);
3766
3767 // Return IPv6 address to use for zbeacon reception, or "" if none was set.
3768 const char *
3769 zsys_ipv6_address (void);
3770
3771 // Set IPv6 milticast address to use for sending zbeacon messages. This needs
3772 // to be set if IPv6 is enabled. If the environment variable
3773 // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast
3774 // address.
3775 void
3776 zsys_set_ipv6_mcast_address (const char *value);
3777
3778 // Return IPv6 multicast address to use for sending zbeacon, or "" if none was
3779 // set.
3780 const char *
3781 zsys_ipv6_mcast_address (void);
3782
3783 // Configure the automatic use of pre-allocated FDs when creating new sockets.
3784 // If 0 (default), nothing will happen. Else, when a new socket is bound, the
3785 // system API will be used to check if an existing pre-allocated FD with a
3786 // matching port (if TCP) or path (if IPC) exists, and if it does it will be
3787 // set via the ZMQ_USE_FD socket option so that the library will use it
3788 // instead of creating a new socket.
3789 void
3790 zsys_set_auto_use_fd (int auto_use_fd);
3791
3792 // Return use of automatic pre-allocated FDs for zsock instances.
3793 int
3794 zsys_auto_use_fd (void);
3795
3796 // Set log identity, which is a string that prefixes all log messages sent
3797 // by this process. The log identity defaults to the environment variable
3798 // ZSYS_LOGIDENT, if that is set.
3799 void
3800 zsys_set_logident (const char *value);
3801
3802 // Set stream to receive log traffic. By default, log traffic is sent to
3803 // stdout. If you set the stream to NULL, no stream will receive the log
3804 // traffic (it may still be sent to the system facility).
3805 void
3806 zsys_set_logstream (FILE *stream);
3807
3808 // Sends log output to a PUB socket bound to the specified endpoint. To
3809 // collect such log output, create a SUB socket, subscribe to the traffic
3810 // you care about, and connect to the endpoint. Log traffic is sent as a
3811 // single string frame, in the same format as when sent to stdout. The
3812 // log system supports a single sender; multiple calls to this method will
3813 // bind the same sender to multiple endpoints. To disable the sender, call
3814 // this method with a null argument.
3815 void
3816 zsys_set_logsender (const char *endpoint);
3817
3818 // Enable or disable logging to the system facility (syslog on POSIX boxes,
3819 // event log on Windows). By default this is disabled.
3820 void
3821 zsys_set_logsystem (bool logsystem);
3822
3823 // Log error condition - highest priority
3824 void
3825 zsys_error (const char *format, ...);
3826
3827 // Log warning condition - high priority
3828 void
3829 zsys_warning (const char *format, ...);
3830
3831 // Log normal, but significant, condition - normal priority
3832 void
3833 zsys_notice (const char *format, ...);
3834
3835 // Log informational message - low priority
3836 void
3837 zsys_info (const char *format, ...);
3838
3839 // Log debug-level message - lowest priority
3840 void
3841 zsys_debug (const char *format, ...);
3842
3843 // Self test of this class.
3844 void
3845 zsys_test (bool verbose);
3846
3847 // CLASS: ztimerset
3848 // Create new timer set.
3849 ztimerset_t *
3850 ztimerset_new (void);
3851
3852 // Destroy a timer set
3853 void
3854 ztimerset_destroy (ztimerset_t **self_p);
3855
3856 // Add a timer to the set. Returns timer id if OK, -1 on failure.
3857 int
3858 ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg);
3859
3860 // Cancel a timer. Returns 0 if OK, -1 on failure.
3861 int
3862 ztimerset_cancel (ztimerset_t *self, int timer_id);
3863
3864 // Set timer interval. Returns 0 if OK, -1 on failure.
3865 // This method is slow, canceling the timer and adding a new one yield better performance.
3866 int
3867 ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval);
3868
3869 // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure.
3870 // This method is slow, canceling the timer and adding a new one yield better performance.
3871 int
3872 ztimerset_reset (ztimerset_t *self, int timer_id);
3873
3874 // Return the time until the next interval.
3875 // Should be used as timeout parameter for the zpoller wait method.
3876 // The timeout is in msec.
3877 int
3878 ztimerset_timeout (ztimerset_t *self);
3879
3880 // Invoke callback function of all timers which their interval has elapsed.
3881 // Should be call after zpoller wait method.
3882 // Returns 0 if OK, -1 on failure.
3883 int
3884 ztimerset_execute (ztimerset_t *self);
3885
3886 // Self test of this class.
3887 void
3888 ztimerset_test (bool verbose);
3889
3890 // CLASS: ztrie
3891 // Creates a new ztrie.
3892 ztrie_t *
3893 ztrie_new (char delimiter);
3894
3895 // Destroy the ztrie.
3896 void
3897 ztrie_destroy (ztrie_t **self_p);
3898
3899 // Inserts a new route into the tree and attaches the data. Returns -1
3900 // if the route already exists, otherwise 0. This method takes ownership of
3901 // the provided data if a destroy_data_fn is provided.
3902 int
3903 ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn);
3904
3905 // Removes a route from the trie and destroys its data. Returns -1 if the
3906 // route does not exists, otherwise 0.
3907 // the start of the list call zlist_first (). Advances the cursor.
3908 int
3909 ztrie_remove_route (ztrie_t *self, const char *path);
3910
3911 // Returns true if the path matches a route in the tree, otherwise false.
3912 bool
3913 ztrie_matches (ztrie_t *self, const char *path);
3914
3915 // Returns the data of a matched route from last ztrie_matches. If the path
3916 // did not match, returns NULL. Do not delete the data as it's owned by
3917 // ztrie.
3918 void *
3919 ztrie_hit_data (ztrie_t *self);
3920
3921 // Returns the count of parameters that a matched route has.
3922 size_t
3923 ztrie_hit_parameter_count (ztrie_t *self);
3924
3925 // Returns the parameters of a matched route with named regexes from last
3926 // ztrie_matches. If the path did not match or the route did not contain any
3927 // named regexes, returns NULL.
3928 zhashx_t *
3929 ztrie_hit_parameters (ztrie_t *self);
3930
3931 // Returns the asterisk matched part of a route, if there has been no match
3932 // or no asterisk match, returns NULL.
3933 const char *
3934 ztrie_hit_asterisk_match (ztrie_t *self);
3935
3936 // Print the trie
3937 void
3938 ztrie_print (ztrie_t *self);
3939
3940 // Self test of this class.
3941 void
3942 ztrie_test (bool verbose);
3943
3944 // CLASS: zuuid
3945 // Create a new UUID object.
3946 zuuid_t *
3947 zuuid_new (void);
3948
3949 // Destroy a specified UUID object.
3950 void
3951 zuuid_destroy (zuuid_t **self_p);
3952
3953 // Create UUID object from supplied ZUUID_LEN-octet value.
3954 zuuid_t *
3955 zuuid_new_from (const byte *source);
3956
3957 // Set UUID to new supplied ZUUID_LEN-octet value.
3958 void
3959 zuuid_set (zuuid_t *self, const byte *source);
3960
3961 // Set UUID to new supplied string value skipping '-' and '{' '}'
3962 // optional delimiters. Return 0 if OK, else returns -1.
3963 int
3964 zuuid_set_str (zuuid_t *self, const char *source);
3965
3966 // Return UUID binary data.
3967 const byte *
3968 zuuid_data (zuuid_t *self);
3969
3970 // Return UUID binary size
3971 size_t
3972 zuuid_size (zuuid_t *self);
3973
3974 // Returns UUID as string
3975 const char *
3976 zuuid_str (zuuid_t *self);
3977
3978 // Return UUID in the canonical string format: 8-4-4-4-12, in lower
3979 // case. Caller does not modify or free returned value. See
3980 // http://en.wikipedia.org/wiki/Universally_unique_identifier
3981 const char *
3982 zuuid_str_canonical (zuuid_t *self);
3983
3984 // Store UUID blob in target array
3985 void
3986 zuuid_export (zuuid_t *self, byte *target);
3987
3988 // Check if UUID is same as supplied value
3989 bool
3990 zuuid_eq (zuuid_t *self, const byte *compare);
3991
3992 // Check if UUID is different from supplied value
3993 bool
3994 zuuid_neq (zuuid_t *self, const byte *compare);
3995
3996 // Make copy of UUID object; if uuid is null, or memory was exhausted,
3997 // returns null.
3998 zuuid_t *
3999 zuuid_dup (zuuid_t *self);
4000
4001 // Self test of this class.
4002 void
4003 zuuid_test (bool verbose);
4004
4005 ''')
2020
2121 An example - to send $KTHXBAI string
2222
23 if (zstr_send (self->pipe, "$KTHXBAI") == 0)
24 zsock_wait (self->pipe);
23 if (zstr_send (self, "$KTHXBAI") == 0)
24 zsock_wait (self);
2525 <argument name = "self" type = "zactor" />
2626 </callback_type>
2727
1919 Destroy zproc, wait until process ends.
2020 </destructor>
2121
22 <method name = "args" >
23 Return command line arguments (the first item is the executable) or
24 NULL if not set.
25 <return type = "zlist" fresh = "1" />
26 </method>
27
2228 <method name = "set args" >
2329 Setup the command line arguments, the first item must be an (absolute) filename
2430 to run.
25 <argument name = "args" type = "zlistx" />
31 <argument name = "arguments" type = "zlist" by_reference = "1" />
32 </method>
33
34 <method name = "set argsx" >
35 Setup the command line arguments, the first item must be an (absolute) filename
36 to run. Variadic function, must be NULL terminated.
37 <argument name = "arguments" type = "string" variadic = "1" />
2638 </method>
2739
2840 <method name = "set env" >
2941 Setup the environment variables for the process.
30 <argument name = "args" type = "zhashx" />
42 <argument name = "arguments" type = "zhash" by_reference = "1" />
3143 </method>
3244
3345 <method name = "set stdin" >
7082 </method>
7183
7284 <method name = "run" >
73 Starts the process.
85 Starts the process, return just before execve/CreateProcess.
7486 <return type = "integer" />
7587 </method>
7688
110122 <argument name = "verbose" type = "boolean" />
111123 </method>
112124
113 <!--
114 TODO: cannot express such method in zproto API model!!
115 // run the subprocess
116 CZMQ_EXPORT int
117 zsubproc_run (zsubproc_t *self, const char *filename, char *const argv[], char *const envp[]);
118 -->
119
120 <method name = "czmq version" singleton = "1">
121 Returns CZMQ version as a single 6-digit integer encoding the major
122 version (x 10000), the minor version (x 100) and the patch.
123 <return type = "integer" />
124 </method>
125
126 <method name = "interrupted" singleton = "1">
127 Returns true if the process received a SIGINT or SIGTERM signal.
128 It is good practice to use this method to exit any infinite loop
129 processing messages.
130 <return type = "boolean" />
131 </method>
132
133 <method name = "has curve" singleton = "1">
134 Returns true if the underlying libzmq supports CURVE security.
135 <return type = "boolean" />
136 </method>
137
138 <method name = "hostname" singleton = "1">
139 Return current host name, for use in public tcp:// endpoints.
140 If the host name is not resolvable, returns NULL.
141 <return type = "string" fresh = "1" />
142 </method>
143
144 <method name = "daemonize" singleton = "1">
145 Move the current process into the background. The precise effect
146 depends on the operating system. On POSIX boxes, moves to a specified
147 working directory (if specified), closes all file handles, reopens
148 stdin, stdout, and stderr to the null device, and sets the process to
149 ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
150 was an error.
151 <argument name = "workdir" type = "string" />
152 </method>
153
154 <method name = "run as" singleton = "1">
155 Drop the process ID into the lockfile, with exclusive lock, and
156 switch the process to the specified group and/or user. Any of the
157 arguments may be null, indicating a no-op. Returns 0 on success,
158 -1 on failure. Note if you combine this with zsys_daemonize, run
159 after, not before that method, or the lockfile will hold the wrong
160 process ID.
161 <argument name = "lockfile" type = "string" />
162 <argument name = "group" type = "string" />
163 <argument name = "user" type = "string" />
164 </method>
165
166 <method name = "set io threads" singleton = "1">
167 Configure the number of I/O threads that ZeroMQ will use. A good
168 rule of thumb is one thread per gigabit of traffic in or out. The
169 default is 1, sufficient for most applications. If the environment
170 variable ZSYS_IO_THREADS is defined, that provides the default.
171 Note that this method is valid only before any socket is created.
172 <argument name = "io_threads" type = "size" />
173 </method>
174
175 <method name = "set max sockets" singleton = "1">
176 Configure the number of sockets that ZeroMQ will allow. The default
177 is 1024. The actual limit depends on the system, and you can query it
178 by using zsys_socket_limit (). A value of zero means "maximum".
179 Note that this method is valid only before any socket is created.
180 <argument name = "max_sockets" type = "size" />
181 </method>
182
183 <method name = "set biface" singleton = "1">
184 Set network interface name to use for broadcasts, particularly zbeacon.
185 This lets the interface be configured for test environments where required.
186 For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
187 the default when there is no specified interface. If the environment
188 variable ZSYS_INTERFACE is set, use that as the default interface name.
189 Setting the interface to "*" means "use all available interfaces".
190 <argument name = "value" type = "string" />
191 </method>
192
193 <method name = "biface" singleton = "1">
194 Return network interface to use for broadcasts, or "" if none was set.
195 <return type = "string" />
196 </method>
197
198 <method name = "set log ident" singleton = "1">
199 Set log identity, which is a string that prefixes all log messages sent
200 by this process. The log identity defaults to the environment variable
201 ZSYS_LOGIDENT, if that is set.
202 <argument name = "value" type = "string" />
203 </method>
204
205 <method name = "set log sender" singleton = "1">
206 Sends log output to a PUB socket bound to the specified endpoint. To
207 collect such log output, create a SUB socket, subscribe to the traffic
208 you care about, and connect to the endpoint. Log traffic is sent as a
209 single string frame, in the same format as when sent to stdout. The
210 log system supports a single sender; multiple calls to this method will
211 bind the same sender to multiple endpoints. To disable the sender, call
212 this method with a null argument.
213 <argument name = "endpoint" type = "string" />
214 </method>
215
216 <method name = "set log system" singleton = "1">
217 Enable or disable logging to the system facility (syslog on POSIX boxes,
218 event log on Windows). By default this is disabled.
219 <argument name = "logsystem" type = "boolean" />
220 </method>
221
222 <method name = "log error" singleton = "1">
223 Log error condition - highest priority
224 <argument name = "format" type = "format" />
225 </method>
226
227 <method name = "log warning" singleton = "1">
228 Log warning condition - high priority
229 <argument name = "format" type = "format" />
230 </method>
231
232 <method name = "log notice" singleton = "1">
233 Log normal, but significant, condition - normal priority
234 <argument name = "format" type = "format" />
235 </method>
236
237 <method name = "log info" singleton = "1">
238 Log informational message - low priority
239 <argument name = "format" type = "format" />
240 </method>
241
242 <method name = "log debug" singleton = "1">
243 Log debug-level message - lowest priority
244 <argument name = "format" type = "format" />
245 </method>
246125 </class>
8383 zsys_interrupted. Idempotent; safe to call multiple times.
8484 Can be supressed by ZSYS_SIGHANDLER=false
8585 *** This is for CZMQ internal use only and may change arbitrarily ***
86 </method>
87
88 <method name = "is interrupted" singleton = "1" state = "draft">
89 Check if default interrupt handler of Ctrl-C or SIGTERM was called.
90 Does not work if ZSYS_SIGHANDLER is false and code does not call
91 set interrupted on signal.
92 <return type = "boolean" />
93 </method>
94
95 <method name = "set interrupted" singleton = "1" state = "draft">
96 Set interrupted flag. This is done by default signal handler, however
97 this can be handy for language bindings or cases without default
98 signal handler.
8699 </method>
87100
88101 <method name = "file exists" singleton = "1">
302315 <return type = "integer" />
303316 </method>
304317
318 <method name = "set zero copy recv" singleton = "1" state = "draft" >
319 Configure whether to use zero copy strategy in libzmq. If the environment
320 variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
321 Otherwise the default is 1.
322 <argument name = "zero copy" type = "integer" />
323 </method>
324
325 <method name = "zero copy recv" singleton = "1" state = "draft" >
326 Return ZMQ_ZERO_COPY_RECV option.
327 <return type = "integer" />
328 </method>
329
305330 <method name = "set file stable age msec" singleton = "1" state = "draft">
306331 Configure the threshold value of filesystem object age per st_mtime
307332 that should elapse until we consider that object "stable" at the
4848 This does the following:
4949
5050 * It compiles the CZMQ C sources for Android, into a native library libczmq.so in builds/android/
51 * It compiles the JNI Java classes into a jar file czmq-jni-4.1.0.jar in bindings/jni/build/libs
51 * It compiles the JNI Java classes into a jar file czmq-jni-4.1.1.jar in bindings/jni/build/libs
5252 * It compiles the JNI C sources for Android, into a native library libczmqjni.so.
5353 * It combines all these into czmq-android.jar, which you can use in your Android projects.
5454
5151
5252 echo "******** Building czmq.jar for Android"
5353 # Copy class files into org/zeromq/etc.
54 unzip -q ../../build/libs/czmq-jni-4.1.0.jar
54 unzip -q ../../build/libs/czmq-jni-4.1.1.jar
5555
5656 # Copy native libraries into lib/armeabi
5757 mkdir -p lib/armeabi
1111 }
1212
1313 group = "org.zeromq"
14 version = "4.1.0"
14 version = "4.1.1"
1515
1616 repositories {
1717 mavenLocal()
135135 vcsUrl = 'https://github.com/zeromq/czmq.git'
136136 githubRepo = System.getenv('BINTRAY_USER_ORG') + '/czmq'
137137 version {
138 name = '4.1.0'
139 vcsTag= '4.1.0'
138 name = '4.1.1'
139 vcsTag= '4.1.1'
140140 }
141141 }
142142 }
4848 //
4949
5050 VS_VERSION_INFO VERSIONINFO
51 FILEVERSION 4,1,0,0
52 PRODUCTVERSION 4,1,0,0
51 FILEVERSION 4,1,1,0
52 PRODUCTVERSION 4,1,1,0
5353 FILEFLAGSMASK 0x3fL
5454 #ifdef _DEBUG
5555 FILEFLAGS 0x1L
6666 BEGIN
6767 VALUE "CompanyName", "The AUTHORS"
6868 VALUE "FileDescription", "The high-level C binding for 0MQ"
69 VALUE "FileVersion", "4.1.0.0"
69 VALUE "FileVersion", "4.1.1.0"
7070 VALUE "InternalName", "CZMQ"
7171 VALUE "LegalCopyright", "Copyright (c) the Authors"
7272 VALUE "OriginalFilename", "libczmq.dll"
7373 VALUE "ProductName", "CZMQ"
74 VALUE "ProductVersion", "4.1.0.0"
74 VALUE "ProductVersion", "4.1.1.0"
7575 END
7676 END
7777 BLOCK "VarFileInfo"
2424 zproc_destroy ((zproc_t **) &self);
2525 }
2626
27 JNIEXPORT void JNICALL
28 Java_org_zeromq_czmq_Zproc__1_1setArgs (JNIEnv *env, jclass c, jlong self, jlong args)
27 JNIEXPORT jlong JNICALL
28 Java_org_zeromq_czmq_Zproc__1_1args (JNIEnv *env, jclass c, jlong self)
2929 {
30 zproc_set_args ((zproc_t *) (intptr_t) self, (zlistx_t *) (intptr_t) args);
30 jlong args_ = (jlong) (intptr_t) zproc_args ((zproc_t *) (intptr_t) self);
31 return args_;
3132 }
3233
3334 JNIEXPORT void JNICALL
34 Java_org_zeromq_czmq_Zproc__1_1setEnv (JNIEnv *env, jclass c, jlong self, jlong args)
35 Java_org_zeromq_czmq_Zproc__1_1setArgs (JNIEnv *env, jclass c, jlong self, jlong arguments)
3536 {
36 zproc_set_env ((zproc_t *) (intptr_t) self, (zhashx_t *) (intptr_t) args);
37 zproc_set_args ((zproc_t *) (intptr_t) self, (zlist_t **) (intptr_t) &arguments);
38 }
39
40 JNIEXPORT void JNICALL
41 Java_org_zeromq_czmq_Zproc__1_1setArgsx (JNIEnv *env, jclass c, jlong self, jstring arguments)
42 {
43 char *arguments_ = (char *) (*env)->GetStringUTFChars (env, arguments, NULL);
44 zproc_set_argsx ((zproc_t *) (intptr_t) self, arguments_);
45 (*env)->ReleaseStringUTFChars (env, arguments, arguments_);
46 }
47
48 JNIEXPORT void JNICALL
49 Java_org_zeromq_czmq_Zproc__1_1setEnv (JNIEnv *env, jclass c, jlong self, jlong arguments)
50 {
51 zproc_set_env ((zproc_t *) (intptr_t) self, (zhash_t **) (intptr_t) &arguments);
3752 }
3853
3954 JNIEXPORT void JNICALL
129144 zproc_set_verbose ((zproc_t *) (intptr_t) self, (bool) verbose);
130145 }
131146
132 JNIEXPORT jint JNICALL
133 Java_org_zeromq_czmq_Zproc__1_1czmqVersion (JNIEnv *env, jclass c)
134 {
135 jint czmq_version_ = (jint) zproc_czmq_version ();
136 return czmq_version_;
137 }
138
139 JNIEXPORT jboolean JNICALL
140 Java_org_zeromq_czmq_Zproc__1_1interrupted (JNIEnv *env, jclass c)
141 {
142 jboolean interrupted_ = (jboolean) zproc_interrupted ();
143 return interrupted_;
144 }
145
146 JNIEXPORT jboolean JNICALL
147 Java_org_zeromq_czmq_Zproc__1_1hasCurve (JNIEnv *env, jclass c)
148 {
149 jboolean has_curve_ = (jboolean) zproc_has_curve ();
150 return has_curve_;
151 }
152
153 JNIEXPORT jstring JNICALL
154 Java_org_zeromq_czmq_Zproc__1_1hostname (JNIEnv *env, jclass c)
155 {
156 char *hostname_ = (char *) zproc_hostname ();
157 jstring return_string_ = (*env)->NewStringUTF (env, hostname_);
158 zstr_free (&hostname_);
159 return return_string_;
160 }
161
162 JNIEXPORT void JNICALL
163 Java_org_zeromq_czmq_Zproc__1_1daemonize (JNIEnv *env, jclass c, jstring workdir)
164 {
165 char *workdir_ = (char *) (*env)->GetStringUTFChars (env, workdir, NULL);
166 zproc_daemonize (workdir_);
167 (*env)->ReleaseStringUTFChars (env, workdir, workdir_);
168 }
169
170 JNIEXPORT void JNICALL
171 Java_org_zeromq_czmq_Zproc__1_1runAs (JNIEnv *env, jclass c, jstring lockfile, jstring group, jstring user)
172 {
173 char *lockfile_ = (char *) (*env)->GetStringUTFChars (env, lockfile, NULL);
174 char *group_ = (char *) (*env)->GetStringUTFChars (env, group, NULL);
175 char *user_ = (char *) (*env)->GetStringUTFChars (env, user, NULL);
176 zproc_run_as (lockfile_, group_, user_);
177 (*env)->ReleaseStringUTFChars (env, lockfile, lockfile_);
178 (*env)->ReleaseStringUTFChars (env, group, group_);
179 (*env)->ReleaseStringUTFChars (env, user, user_);
180 }
181
182 JNIEXPORT void JNICALL
183 Java_org_zeromq_czmq_Zproc__1_1setIoThreads (JNIEnv *env, jclass c, jlong io_threads)
184 {
185 zproc_set_io_threads ((size_t) io_threads);
186 }
187
188 JNIEXPORT void JNICALL
189 Java_org_zeromq_czmq_Zproc__1_1setMaxSockets (JNIEnv *env, jclass c, jlong max_sockets)
190 {
191 zproc_set_max_sockets ((size_t) max_sockets);
192 }
193
194 JNIEXPORT void JNICALL
195 Java_org_zeromq_czmq_Zproc__1_1setBiface (JNIEnv *env, jclass c, jstring value)
196 {
197 char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL);
198 zproc_set_biface (value_);
199 (*env)->ReleaseStringUTFChars (env, value, value_);
200 }
201
202 JNIEXPORT jstring JNICALL
203 Java_org_zeromq_czmq_Zproc__1_1biface (JNIEnv *env, jclass c)
204 {
205 char *biface_ = (char *) zproc_biface ();
206 jstring return_string_ = (*env)->NewStringUTF (env, biface_);
207 return return_string_;
208 }
209
210 JNIEXPORT void JNICALL
211 Java_org_zeromq_czmq_Zproc__1_1setLogIdent (JNIEnv *env, jclass c, jstring value)
212 {
213 char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL);
214 zproc_set_log_ident (value_);
215 (*env)->ReleaseStringUTFChars (env, value, value_);
216 }
217
218 JNIEXPORT void JNICALL
219 Java_org_zeromq_czmq_Zproc__1_1setLogSender (JNIEnv *env, jclass c, jstring endpoint)
220 {
221 char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL);
222 zproc_set_log_sender (endpoint_);
223 (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_);
224 }
225
226 JNIEXPORT void JNICALL
227 Java_org_zeromq_czmq_Zproc__1_1setLogSystem (JNIEnv *env, jclass c, jboolean logsystem)
228 {
229 zproc_set_log_system ((bool) logsystem);
230 }
231
232 JNIEXPORT void JNICALL
233 Java_org_zeromq_czmq_Zproc__1_1logError (JNIEnv *env, jclass c, jstring format)
234 {
235 char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
236 zproc_log_error ("%s", format_);
237 (*env)->ReleaseStringUTFChars (env, format, format_);
238 }
239
240 JNIEXPORT void JNICALL
241 Java_org_zeromq_czmq_Zproc__1_1logWarning (JNIEnv *env, jclass c, jstring format)
242 {
243 char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
244 zproc_log_warning ("%s", format_);
245 (*env)->ReleaseStringUTFChars (env, format, format_);
246 }
247
248 JNIEXPORT void JNICALL
249 Java_org_zeromq_czmq_Zproc__1_1logNotice (JNIEnv *env, jclass c, jstring format)
250 {
251 char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
252 zproc_log_notice ("%s", format_);
253 (*env)->ReleaseStringUTFChars (env, format, format_);
254 }
255
256 JNIEXPORT void JNICALL
257 Java_org_zeromq_czmq_Zproc__1_1logInfo (JNIEnv *env, jclass c, jstring format)
258 {
259 char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
260 zproc_log_info ("%s", format_);
261 (*env)->ReleaseStringUTFChars (env, format, format_);
262 }
263
264 JNIEXPORT void JNICALL
265 Java_org_zeromq_czmq_Zproc__1_1logDebug (JNIEnv *env, jclass c, jstring format)
266 {
267 char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
268 zproc_log_debug ("%s", format_);
269 (*env)->ReleaseStringUTFChars (env, format, format_);
270 }
271
272147 JNIEXPORT void JNICALL
273148 Java_org_zeromq_czmq_Zproc__1_1test (JNIEnv *env, jclass c, jboolean verbose)
274149 {
6868 }
6969
7070 JNIEXPORT jboolean JNICALL
71 Java_org_zeromq_czmq_Zsys__1_1isInterrupted (JNIEnv *env, jclass c)
72 {
73 jboolean is_interrupted_ = (jboolean) zsys_is_interrupted ();
74 return is_interrupted_;
75 }
76
77 JNIEXPORT void JNICALL
78 Java_org_zeromq_czmq_Zsys__1_1setInterrupted (JNIEnv *env, jclass c)
79 {
80 zsys_set_interrupted ();
81 }
82
83 JNIEXPORT jboolean JNICALL
7184 Java_org_zeromq_czmq_Zsys__1_1fileExists (JNIEnv *env, jclass c, jstring filename)
7285 {
7386 char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL);
257270 }
258271
259272 JNIEXPORT void JNICALL
273 Java_org_zeromq_czmq_Zsys__1_1setZeroCopyRecv (JNIEnv *env, jclass c, jint zero_copy)
274 {
275 zsys_set_zero_copy_recv ((int) zero_copy);
276 }
277
278 JNIEXPORT jint JNICALL
279 Java_org_zeromq_czmq_Zsys__1_1zeroCopyRecv (JNIEnv *env, jclass c)
280 {
281 jint zero_copy_recv_ = (jint) zsys_zero_copy_recv ();
282 return zero_copy_recv_;
283 }
284
285 JNIEXPORT void JNICALL
260286 Java_org_zeromq_czmq_Zsys__1_1setFileStableAgeMsec (JNIEnv *env, jclass c, jlong file_stable_age_msec)
261287 {
262288 zsys_set_file_stable_age_msec ((int64_t) file_stable_age_msec);
3838 self = 0;
3939 }
4040 /*
41 Return command line arguments (the first item is the executable) or
42 NULL if not set.
43 */
44 native static long __args (long self);
45 public Zlist args () {
46 return new Zlist (__args (self));
47 }
48 /*
4149 Setup the command line arguments, the first item must be an (absolute) filename
4250 to run.
4351 */
44 native static void __setArgs (long self, long args);
45 public void setArgs (Zlistx args) {
46 __setArgs (self, args.self);
52 native static void __setArgs (long self, long arguments);
53 public void setArgs (Zlist arguments) {
54 __setArgs (self, arguments.self);
55 }
56 /*
57 Setup the command line arguments, the first item must be an (absolute) filename
58 to run. Variadic function, must be NULL terminated.
59 */
60 native static void __setArgsx (long self, String arguments);
61 public void setArgsx (String arguments []) {
62 __setArgsx (self, arguments [0]);
4763 }
4864 /*
4965 Setup the environment variables for the process.
5066 */
51 native static void __setEnv (long self, long args);
52 public void setEnv (Zhashx args) {
53 __setEnv (self, args.self);
67 native static void __setEnv (long self, long arguments);
68 public void setEnv (Zhash arguments) {
69 __setEnv (self, arguments.self);
5470 }
5571 /*
5672 Connects process stdin with a readable ('>', connect) zeromq socket. If
104120 return __stderr (self);
105121 }
106122 /*
107 Starts the process.
123 Starts the process, return just before execve/CreateProcess.
108124 */
109125 native static int __run (long self);
110126 public int run () {
160176 __setVerbose (self, verbose);
161177 }
162178 /*
163 Returns CZMQ version as a single 6-digit integer encoding the major
164 version (x 10000), the minor version (x 100) and the patch.
165 */
166 native static int __czmqVersion ();
167 public int czmqVersion () {
168 return __czmqVersion ();
169 }
170 /*
171 Returns true if the process received a SIGINT or SIGTERM signal.
172 It is good practice to use this method to exit any infinite loop
173 processing messages.
174 */
175 native static boolean __interrupted ();
176 public boolean interrupted () {
177 return __interrupted ();
178 }
179 /*
180 Returns true if the underlying libzmq supports CURVE security.
181 */
182 native static boolean __hasCurve ();
183 public boolean hasCurve () {
184 return __hasCurve ();
185 }
186 /*
187 Return current host name, for use in public tcp:// endpoints.
188 If the host name is not resolvable, returns NULL.
189 */
190 native static String __hostname ();
191 public String hostname () {
192 return __hostname ();
193 }
194 /*
195 Move the current process into the background. The precise effect
196 depends on the operating system. On POSIX boxes, moves to a specified
197 working directory (if specified), closes all file handles, reopens
198 stdin, stdout, and stderr to the null device, and sets the process to
199 ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
200 was an error.
201 */
202 native static void __daemonize (String workdir);
203 public void daemonize (String workdir) {
204 __daemonize (workdir);
205 }
206 /*
207 Drop the process ID into the lockfile, with exclusive lock, and
208 switch the process to the specified group and/or user. Any of the
209 arguments may be null, indicating a no-op. Returns 0 on success,
210 -1 on failure. Note if you combine this with zsys_daemonize, run
211 after, not before that method, or the lockfile will hold the wrong
212 process ID.
213 */
214 native static void __runAs (String lockfile, String group, String user);
215 public void runAs (String lockfile, String group, String user) {
216 __runAs (lockfile, group, user);
217 }
218 /*
219 Configure the number of I/O threads that ZeroMQ will use. A good
220 rule of thumb is one thread per gigabit of traffic in or out. The
221 default is 1, sufficient for most applications. If the environment
222 variable ZSYS_IO_THREADS is defined, that provides the default.
223 Note that this method is valid only before any socket is created.
224 */
225 native static void __setIoThreads (long ioThreads);
226 public void setIoThreads (long ioThreads) {
227 __setIoThreads (ioThreads);
228 }
229 /*
230 Configure the number of sockets that ZeroMQ will allow. The default
231 is 1024. The actual limit depends on the system, and you can query it
232 by using zsys_socket_limit (). A value of zero means "maximum".
233 Note that this method is valid only before any socket is created.
234 */
235 native static void __setMaxSockets (long maxSockets);
236 public void setMaxSockets (long maxSockets) {
237 __setMaxSockets (maxSockets);
238 }
239 /*
240 Set network interface name to use for broadcasts, particularly zbeacon.
241 This lets the interface be configured for test environments where required.
242 For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
243 the default when there is no specified interface. If the environment
244 variable ZSYS_INTERFACE is set, use that as the default interface name.
245 Setting the interface to "*" means "use all available interfaces".
246 */
247 native static void __setBiface (String value);
248 public void setBiface (String value) {
249 __setBiface (value);
250 }
251 /*
252 Return network interface to use for broadcasts, or "" if none was set.
253 */
254 native static String __biface ();
255 public String biface () {
256 return __biface ();
257 }
258 /*
259 Set log identity, which is a string that prefixes all log messages sent
260 by this process. The log identity defaults to the environment variable
261 ZSYS_LOGIDENT, if that is set.
262 */
263 native static void __setLogIdent (String value);
264 public void setLogIdent (String value) {
265 __setLogIdent (value);
266 }
267 /*
268 Sends log output to a PUB socket bound to the specified endpoint. To
269 collect such log output, create a SUB socket, subscribe to the traffic
270 you care about, and connect to the endpoint. Log traffic is sent as a
271 single string frame, in the same format as when sent to stdout. The
272 log system supports a single sender; multiple calls to this method will
273 bind the same sender to multiple endpoints. To disable the sender, call
274 this method with a null argument.
275 */
276 native static void __setLogSender (String endpoint);
277 public void setLogSender (String endpoint) {
278 __setLogSender (endpoint);
279 }
280 /*
281 Enable or disable logging to the system facility (syslog on POSIX boxes,
282 event log on Windows). By default this is disabled.
283 */
284 native static void __setLogSystem (boolean logsystem);
285 public void setLogSystem (boolean logsystem) {
286 __setLogSystem (logsystem);
287 }
288 /*
289 Log error condition - highest priority
290 */
291 native static void __logError (String format);
292 public void logError (String format) {
293 __logError (format);
294 }
295 /*
296 Log warning condition - high priority
297 */
298 native static void __logWarning (String format);
299 public void logWarning (String format) {
300 __logWarning (format);
301 }
302 /*
303 Log normal, but significant, condition - normal priority
304 */
305 native static void __logNotice (String format);
306 public void logNotice (String format) {
307 __logNotice (format);
308 }
309 /*
310 Log informational message - low priority
311 */
312 native static void __logInfo (String format);
313 public void logInfo (String format) {
314 __logInfo (format);
315 }
316 /*
317 Log debug-level message - lowest priority
318 */
319 native static void __logDebug (String format);
320 public void logDebug (String format) {
321 __logDebug (format);
322 }
323 /*
324179 Self test of this class.
325180 */
326181 native static void __test (boolean verbose);
9191 __catchInterrupts ();
9292 }
9393 /*
94 Check if default interrupt handler of Ctrl-C or SIGTERM was called.
95 Does not work if ZSYS_SIGHANDLER is false and code does not call
96 set interrupted on signal.
97 */
98 native static boolean __isInterrupted ();
99 public boolean isInterrupted () {
100 return __isInterrupted ();
101 }
102 /*
103 Set interrupted flag. This is done by default signal handler, however
104 this can be handy for language bindings or cases without default
105 signal handler.
106 */
107 native static void __setInterrupted ();
108 public void setInterrupted () {
109 __setInterrupted ();
110 }
111 /*
94112 Return 1 if file exists, else zero
95113 */
96114 native static boolean __fileExists (String filename);
294312 native static int __maxMsgsz ();
295313 public int maxMsgsz () {
296314 return __maxMsgsz ();
315 }
316 /*
317 Configure whether to use zero copy strategy in libzmq. If the environment
318 variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
319 Otherwise the default is 1.
320 */
321 native static void __setZeroCopyRecv (int zeroCopy);
322 public void setZeroCopyRecv (int zeroCopy) {
323 __setZeroCopyRecv (zeroCopy);
324 }
325 /*
326 Return ZMQ_ZERO_COPY_RECV option.
327 */
328 native static int __zeroCopyRecv ();
329 public int zeroCopyRecv () {
330 return __zeroCopyRecv ();
297331 }
298332 /*
299333 Configure the threshold value of filesystem object age per st_mtime
6060 //
6161 // An example - to send $KTHXBAI string
6262 //
63 // if (zstr_send (self->pipe, "$KTHXBAI") == 0)
64 // zsock_wait (self->pipe);
63 // if (zstr_send (self, "$KTHXBAI") == 0)
64 // zsock_wait (self);
6565 typedef void (zactor_destructor_fn) (
6666 zactor_t *self);
6767
22502250 void
22512251 zproc_destroy (zproc_t **self_p);
22522252
2253 // Return command line arguments (the first item is the executable) or
2254 // NULL if not set.
2255 zlist_t *
2256 zproc_args (zproc_t *self);
2257
22532258 // Setup the command line arguments, the first item must be an (absolute) filename
22542259 // to run.
22552260 void
2256 zproc_set_args (zproc_t *self, zlistx_t *args);
2261 zproc_set_args (zproc_t *self, zlist_t **arguments);
2262
2263 // Setup the command line arguments, the first item must be an (absolute) filename
2264 // to run. Variadic function, must be NULL terminated.
2265 void
2266 zproc_set_argsx (zproc_t *self, const char *arguments, ...);
22572267
22582268 // Setup the environment variables for the process.
22592269 void
2260 zproc_set_env (zproc_t *self, zhashx_t *args);
2270 zproc_set_env (zproc_t *self, zhash_t **arguments);
22612271
22622272 // Connects process stdin with a readable ('>', connect) zeromq socket. If
22632273 // socket argument is NULL, zproc creates own managed pair of inproc
22922302 void *
22932303 zproc_stderr (zproc_t *self);
22942304
2295 // Starts the process.
2305 // Starts the process, return just before execve/CreateProcess.
22962306 int
22972307 zproc_run (zproc_t *self);
22982308
23232333 // set verbose mode
23242334 void
23252335 zproc_set_verbose (zproc_t *self, bool verbose);
2326
2327 // Returns CZMQ version as a single 6-digit integer encoding the major
2328 // version (x 10000), the minor version (x 100) and the patch.
2329 int
2330 zproc_czmq_version (void);
2331
2332 // Returns true if the process received a SIGINT or SIGTERM signal.
2333 // It is good practice to use this method to exit any infinite loop
2334 // processing messages.
2335 bool
2336 zproc_interrupted (void);
2337
2338 // Returns true if the underlying libzmq supports CURVE security.
2339 bool
2340 zproc_has_curve (void);
2341
2342 // Return current host name, for use in public tcp:// endpoints.
2343 // If the host name is not resolvable, returns NULL.
2344 char *
2345 zproc_hostname (void);
2346
2347 // Move the current process into the background. The precise effect
2348 // depends on the operating system. On POSIX boxes, moves to a specified
2349 // working directory (if specified), closes all file handles, reopens
2350 // stdin, stdout, and stderr to the null device, and sets the process to
2351 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
2352 // was an error.
2353 void
2354 zproc_daemonize (const char *workdir);
2355
2356 // Drop the process ID into the lockfile, with exclusive lock, and
2357 // switch the process to the specified group and/or user. Any of the
2358 // arguments may be null, indicating a no-op. Returns 0 on success,
2359 // -1 on failure. Note if you combine this with zsys_daemonize, run
2360 // after, not before that method, or the lockfile will hold the wrong
2361 // process ID.
2362 void
2363 zproc_run_as (const char *lockfile, const char *group, const char *user);
2364
2365 // Configure the number of I/O threads that ZeroMQ will use. A good
2366 // rule of thumb is one thread per gigabit of traffic in or out. The
2367 // default is 1, sufficient for most applications. If the environment
2368 // variable ZSYS_IO_THREADS is defined, that provides the default.
2369 // Note that this method is valid only before any socket is created.
2370 void
2371 zproc_set_io_threads (size_t io_threads);
2372
2373 // Configure the number of sockets that ZeroMQ will allow. The default
2374 // is 1024. The actual limit depends on the system, and you can query it
2375 // by using zsys_socket_limit (). A value of zero means "maximum".
2376 // Note that this method is valid only before any socket is created.
2377 void
2378 zproc_set_max_sockets (size_t max_sockets);
2379
2380 // Set network interface name to use for broadcasts, particularly zbeacon.
2381 // This lets the interface be configured for test environments where required.
2382 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
2383 // the default when there is no specified interface. If the environment
2384 // variable ZSYS_INTERFACE is set, use that as the default interface name.
2385 // Setting the interface to "*" means "use all available interfaces".
2386 void
2387 zproc_set_biface (const char *value);
2388
2389 // Return network interface to use for broadcasts, or "" if none was set.
2390 const char *
2391 zproc_biface (void);
2392
2393 // Set log identity, which is a string that prefixes all log messages sent
2394 // by this process. The log identity defaults to the environment variable
2395 // ZSYS_LOGIDENT, if that is set.
2396 void
2397 zproc_set_log_ident (const char *value);
2398
2399 // Sends log output to a PUB socket bound to the specified endpoint. To
2400 // collect such log output, create a SUB socket, subscribe to the traffic
2401 // you care about, and connect to the endpoint. Log traffic is sent as a
2402 // single string frame, in the same format as when sent to stdout. The
2403 // log system supports a single sender; multiple calls to this method will
2404 // bind the same sender to multiple endpoints. To disable the sender, call
2405 // this method with a null argument.
2406 void
2407 zproc_set_log_sender (const char *endpoint);
2408
2409 // Enable or disable logging to the system facility (syslog on POSIX boxes,
2410 // event log on Windows). By default this is disabled.
2411 void
2412 zproc_set_log_system (bool logsystem);
2413
2414 // Log error condition - highest priority
2415 void
2416 zproc_log_error (const char *format, ...);
2417
2418 // Log warning condition - high priority
2419 void
2420 zproc_log_warning (const char *format, ...);
2421
2422 // Log normal, but significant, condition - normal priority
2423 void
2424 zproc_log_notice (const char *format, ...);
2425
2426 // Log informational message - low priority
2427 void
2428 zproc_log_info (const char *format, ...);
2429
2430 // Log debug-level message - lowest priority
2431 void
2432 zproc_log_debug (const char *format, ...);
24332336
24342337 // Self test of this class.
24352338 void
35873490 void
35883491 zsys_catch_interrupts (void);
35893492
3493 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
3494 // Does not work if ZSYS_SIGHANDLER is false and code does not call
3495 // set interrupted on signal.
3496 bool
3497 zsys_is_interrupted (void);
3498
3499 // Set interrupted flag. This is done by default signal handler, however
3500 // this can be handy for language bindings or cases without default
3501 // signal handler.
3502 void
3503 zsys_set_interrupted (void);
3504
35903505 // Return 1 if file exists, else zero
35913506 bool
35923507 zsys_file_exists (const char *filename);
37503665 // Return maximum message size.
37513666 int
37523667 zsys_max_msgsz (void);
3668
3669 // Configure whether to use zero copy strategy in libzmq. If the environment
3670 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
3671 // Otherwise the default is 1.
3672 void
3673 zsys_set_zero_copy_recv (int zero_copy);
3674
3675 // Return ZMQ_ZERO_COPY_RECV option.
3676 int
3677 zsys_zero_copy_recv (void);
37533678
37543679 // Configure the threshold value of filesystem object age per st_mtime
37553680 // that should elapse until we consider that object "stable" at the
21852185 Methods:
21862186
21872187 ```
2188 nothing my_zproc.setArgs (Zlistx)
2188 zlist my_zproc.args ()
2189 ```
2190
2191 Return command line arguments (the first item is the executable) or
2192 NULL if not set.
2193
2194 ```
2195 nothing my_zproc.setArgs (Zlist)
21892196 ```
21902197
21912198 Setup the command line arguments, the first item must be an (absolute) filename
21922199 to run.
21932200
21942201 ```
2195 nothing my_zproc.setEnv (Zhashx)
2202 nothing my_zproc.setArgsx (String)
2203 ```
2204
2205 Setup the command line arguments, the first item must be an (absolute) filename
2206 to run. Variadic function, must be NULL terminated.
2207
2208 ```
2209 nothing my_zproc.setEnv (Zhash)
21962210 ```
21972211
21982212 Setup the environment variables for the process.
22012215 integer my_zproc.run ()
22022216 ```
22032217
2204 Starts the process.
2218 Starts the process, return just before execve/CreateProcess.
22052219
22062220 ```
22072221 integer my_zproc.returncode ()
22382252 ```
22392253
22402254 set verbose mode
2241
2242 ```
2243 integer my_zproc.czmqVersion ()
2244 ```
2245
2246 Returns CZMQ version as a single 6-digit integer encoding the major
2247 version (x 10000), the minor version (x 100) and the patch.
2248
2249 ```
2250 boolean my_zproc.interrupted ()
2251 ```
2252
2253 Returns true if the process received a SIGINT or SIGTERM signal.
2254 It is good practice to use this method to exit any infinite loop
2255 processing messages.
2256
2257 ```
2258 boolean my_zproc.hasCurve ()
2259 ```
2260
2261 Returns true if the underlying libzmq supports CURVE security.
2262
2263 ```
2264 string my_zproc.hostname ()
2265 ```
2266
2267 Return current host name, for use in public tcp:// endpoints.
2268 If the host name is not resolvable, returns NULL.
2269
2270 ```
2271 nothing my_zproc.daemonize (String)
2272 ```
2273
2274 Move the current process into the background. The precise effect
2275 depends on the operating system. On POSIX boxes, moves to a specified
2276 working directory (if specified), closes all file handles, reopens
2277 stdin, stdout, and stderr to the null device, and sets the process to
2278 ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
2279 was an error.
2280
2281 ```
2282 nothing my_zproc.runAs (String, String, String)
2283 ```
2284
2285 Drop the process ID into the lockfile, with exclusive lock, and
2286 switch the process to the specified group and/or user. Any of the
2287 arguments may be null, indicating a no-op. Returns 0 on success,
2288 -1 on failure. Note if you combine this with zsys_daemonize, run
2289 after, not before that method, or the lockfile will hold the wrong
2290 process ID.
2291
2292 ```
2293 nothing my_zproc.setIoThreads ()
2294 ```
2295
2296 Configure the number of I/O threads that ZeroMQ will use. A good
2297 rule of thumb is one thread per gigabit of traffic in or out. The
2298 default is 1, sufficient for most applications. If the environment
2299 variable ZSYS_IO_THREADS is defined, that provides the default.
2300 Note that this method is valid only before any socket is created.
2301
2302 ```
2303 nothing my_zproc.setMaxSockets ()
2304 ```
2305
2306 Configure the number of sockets that ZeroMQ will allow. The default
2307 is 1024. The actual limit depends on the system, and you can query it
2308 by using zsys_socket_limit (). A value of zero means "maximum".
2309 Note that this method is valid only before any socket is created.
2310
2311 ```
2312 nothing my_zproc.setBiface (String)
2313 ```
2314
2315 Set network interface name to use for broadcasts, particularly zbeacon.
2316 This lets the interface be configured for test environments where required.
2317 For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
2318 the default when there is no specified interface. If the environment
2319 variable ZSYS_INTERFACE is set, use that as the default interface name.
2320 Setting the interface to "*" means "use all available interfaces".
2321
2322 ```
2323 string my_zproc.biface ()
2324 ```
2325
2326 Return network interface to use for broadcasts, or "" if none was set.
2327
2328 ```
2329 nothing my_zproc.setLogIdent (String)
2330 ```
2331
2332 Set log identity, which is a string that prefixes all log messages sent
2333 by this process. The log identity defaults to the environment variable
2334 ZSYS_LOGIDENT, if that is set.
2335
2336 ```
2337 nothing my_zproc.setLogSender (String)
2338 ```
2339
2340 Sends log output to a PUB socket bound to the specified endpoint. To
2341 collect such log output, create a SUB socket, subscribe to the traffic
2342 you care about, and connect to the endpoint. Log traffic is sent as a
2343 single string frame, in the same format as when sent to stdout. The
2344 log system supports a single sender; multiple calls to this method will
2345 bind the same sender to multiple endpoints. To disable the sender, call
2346 this method with a null argument.
2347
2348 ```
2349 nothing my_zproc.setLogSystem (Boolean)
2350 ```
2351
2352 Enable or disable logging to the system facility (syslog on POSIX boxes,
2353 event log on Windows). By default this is disabled.
2354
2355 ```
2356 nothing my_zproc.logError (String)
2357 ```
2358
2359 Log error condition - highest priority
2360
2361 ```
2362 nothing my_zproc.logWarning (String)
2363 ```
2364
2365 Log warning condition - high priority
2366
2367 ```
2368 nothing my_zproc.logNotice (String)
2369 ```
2370
2371 Log normal, but significant, condition - normal priority
2372
2373 ```
2374 nothing my_zproc.logInfo (String)
2375 ```
2376
2377 Log informational message - low priority
2378
2379 ```
2380 nothing my_zproc.logDebug (String)
2381 ```
2382
2383 Log debug-level message - lowest priority
23842255
23852256 ```
23862257 nothing my_zproc.test (Boolean)
37723643 *** This is for CZMQ internal use only and may change arbitrarily ***
37733644
37743645 ```
3646 boolean my_zsys.isInterrupted ()
3647 ```
3648
3649 Check if default interrupt handler of Ctrl-C or SIGTERM was called.
3650 Does not work if ZSYS_SIGHANDLER is false and code does not call
3651 set interrupted on signal.
3652
3653 ```
3654 nothing my_zsys.setInterrupted ()
3655 ```
3656
3657 Set interrupted flag. This is done by default signal handler, however
3658 this can be handy for language bindings or cases without default
3659 signal handler.
3660
3661 ```
37753662 boolean my_zsys.fileExists (String)
37763663 ```
37773664
39513838 ```
39523839
39533840 Return maximum message size.
3841
3842 ```
3843 nothing my_zsys.setZeroCopyRecv (Number)
3844 ```
3845
3846 Configure whether to use zero copy strategy in libzmq. If the environment
3847 variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
3848 Otherwise the default is 1.
3849
3850 ```
3851 integer my_zsys.zeroCopyRecv ()
3852 ```
3853
3854 Return ZMQ_ZERO_COPY_RECV option.
39543855
39553856 ```
39563857 nothing my_zsys.setFileStableAgeMsec (Number)
42124212 // Prototypes
42134213 Nan::SetPrototypeMethod (tpl, "destroy", destroy);
42144214 Nan::SetPrototypeMethod (tpl, "defined", defined);
4215 Nan::SetPrototypeMethod (tpl, "args", _args);
42154216 Nan::SetPrototypeMethod (tpl, "setArgs", _set_args);
4217 Nan::SetPrototypeMethod (tpl, "setArgsx", _set_argsx);
42164218 Nan::SetPrototypeMethod (tpl, "setEnv", _set_env);
42174219 Nan::SetPrototypeMethod (tpl, "run", _run);
42184220 Nan::SetPrototypeMethod (tpl, "returncode", _returncode);
42214223 Nan::SetPrototypeMethod (tpl, "wait", _wait);
42224224 Nan::SetPrototypeMethod (tpl, "kill", _kill);
42234225 Nan::SetPrototypeMethod (tpl, "setVerbose", _set_verbose);
4224 Nan::SetPrototypeMethod (tpl, "czmqVersion", _czmq_version);
4225 Nan::SetPrototypeMethod (tpl, "interrupted", _interrupted);
4226 Nan::SetPrototypeMethod (tpl, "hasCurve", _has_curve);
4227 Nan::SetPrototypeMethod (tpl, "hostname", _hostname);
4228 Nan::SetPrototypeMethod (tpl, "daemonize", _daemonize);
4229 Nan::SetPrototypeMethod (tpl, "runAs", _run_as);
4230 Nan::SetPrototypeMethod (tpl, "setIoThreads", _set_io_threads);
4231 Nan::SetPrototypeMethod (tpl, "setMaxSockets", _set_max_sockets);
4232 Nan::SetPrototypeMethod (tpl, "setBiface", _set_biface);
4233 Nan::SetPrototypeMethod (tpl, "biface", _biface);
4234 Nan::SetPrototypeMethod (tpl, "setLogIdent", _set_log_ident);
4235 Nan::SetPrototypeMethod (tpl, "setLogSender", _set_log_sender);
4236 Nan::SetPrototypeMethod (tpl, "setLogSystem", _set_log_system);
4237 Nan::SetPrototypeMethod (tpl, "logError", _log_error);
4238 Nan::SetPrototypeMethod (tpl, "logWarning", _log_warning);
4239 Nan::SetPrototypeMethod (tpl, "logNotice", _log_notice);
4240 Nan::SetPrototypeMethod (tpl, "logInfo", _log_info);
4241 Nan::SetPrototypeMethod (tpl, "logDebug", _log_debug);
42424226 Nan::SetPrototypeMethod (tpl, "test", _test);
42434227
42444228 constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ());
42774261 info.GetReturnValue ().Set (Nan::New (zproc->self != NULL));
42784262 }
42794263
4264 NAN_METHOD (Zproc::_args) {
4265 Zproc *zproc = Nan::ObjectWrap::Unwrap <Zproc> (info.Holder ());
4266 zlist_t *result = zproc_args (zproc->self);
4267 Zlist *zlist_result = new Zlist (result);
4268 if (zlist_result) {
4269 // Don't yet know how to return a new object
4270 // zlist->Wrap (info.This ());
4271 // info.GetReturnValue ().Set (info.This ());
4272 info.GetReturnValue ().Set (Nan::New<Boolean>(true));
4273 }
4274 }
4275
42804276 NAN_METHOD (Zproc::_set_args) {
42814277 Zproc *zproc = Nan::ObjectWrap::Unwrap <Zproc> (info.Holder ());
4282 Zlistx *args = Nan::ObjectWrap::Unwrap<Zlistx>(info [0].As<Object>());
4283 zproc_set_args (zproc->self, args->self);
4278 Zlist *arguments = Nan::ObjectWrap::Unwrap<Zlist>(info [0].As<Object>());
4279 zproc_set_args (zproc->self, &arguments->self);
4280 }
4281
4282 NAN_METHOD (Zproc::_set_argsx) {
4283 Zproc *zproc = Nan::ObjectWrap::Unwrap <Zproc> (info.Holder ());
4284 char *arguments;
4285 if (info [0]->IsUndefined ())
4286 return Nan::ThrowTypeError ("method requires a `arguments`");
4287 else
4288 if (!info [0]->IsString ())
4289 return Nan::ThrowTypeError ("`arguments` must be a string");
4290 //else { // bjornw: remove brackets to keep scope
4291 Nan::Utf8String arguments_utf8 (info [0].As<String>());
4292 arguments = *arguments_utf8;
4293 //} //bjornw end
4294 zproc_set_argsx (zproc->self, (const char *)arguments);
42844295 }
42854296
42864297 NAN_METHOD (Zproc::_set_env) {
42874298 Zproc *zproc = Nan::ObjectWrap::Unwrap <Zproc> (info.Holder ());
4288 Zhashx *args = Nan::ObjectWrap::Unwrap<Zhashx>(info [0].As<Object>());
4289 zproc_set_env (zproc->self, args->self);
4299 Zhash *arguments = Nan::ObjectWrap::Unwrap<Zhash>(info [0].As<Object>());
4300 zproc_set_env (zproc->self, &arguments->self);
42904301 }
42914302
42924303 NAN_METHOD (Zproc::_run) {
43664377 else
43674378 return Nan::ThrowTypeError ("`verbose` must be a Boolean");
43684379 zproc_set_verbose (zproc->self, (bool) verbose);
4369 }
4370
4371 NAN_METHOD (Zproc::_czmq_version) {
4372 int result = zproc_czmq_version ();
4373 info.GetReturnValue ().Set (Nan::New<Number>(result));
4374 }
4375
4376 NAN_METHOD (Zproc::_interrupted) {
4377 bool result = zproc_interrupted ();
4378 info.GetReturnValue ().Set (Nan::New<Boolean>(result));
4379 }
4380
4381 NAN_METHOD (Zproc::_has_curve) {
4382 bool result = zproc_has_curve ();
4383 info.GetReturnValue ().Set (Nan::New<Boolean>(result));
4384 }
4385
4386 NAN_METHOD (Zproc::_hostname) {
4387 char *result = (char *) zproc_hostname ();
4388 info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ());
4389 }
4390
4391 NAN_METHOD (Zproc::_daemonize) {
4392 char *workdir;
4393 if (info [0]->IsUndefined ())
4394 return Nan::ThrowTypeError ("method requires a `workdir`");
4395 else
4396 if (!info [0]->IsString ())
4397 return Nan::ThrowTypeError ("`workdir` must be a string");
4398 //else { // bjornw: remove brackets to keep scope
4399 Nan::Utf8String workdir_utf8 (info [0].As<String>());
4400 workdir = *workdir_utf8;
4401 //} //bjornw end
4402 zproc_daemonize ((const char *)workdir);
4403 }
4404
4405 NAN_METHOD (Zproc::_run_as) {
4406 char *lockfile;
4407 if (info [0]->IsUndefined ())
4408 return Nan::ThrowTypeError ("method requires a `lockfile`");
4409 else
4410 if (!info [0]->IsString ())
4411 return Nan::ThrowTypeError ("`lockfile` must be a string");
4412 //else { // bjornw: remove brackets to keep scope
4413 Nan::Utf8String lockfile_utf8 (info [0].As<String>());
4414 lockfile = *lockfile_utf8;
4415 //} //bjornw end
4416 char *group;
4417 if (info [1]->IsUndefined ())
4418 return Nan::ThrowTypeError ("method requires a `group`");
4419 else
4420 if (!info [1]->IsString ())
4421 return Nan::ThrowTypeError ("`group` must be a string");
4422 //else { // bjornw: remove brackets to keep scope
4423 Nan::Utf8String group_utf8 (info [1].As<String>());
4424 group = *group_utf8;
4425 //} //bjornw end
4426 char *user;
4427 if (info [2]->IsUndefined ())
4428 return Nan::ThrowTypeError ("method requires a `user`");
4429 else
4430 if (!info [2]->IsString ())
4431 return Nan::ThrowTypeError ("`user` must be a string");
4432 //else { // bjornw: remove brackets to keep scope
4433 Nan::Utf8String user_utf8 (info [2].As<String>());
4434 user = *user_utf8;
4435 //} //bjornw end
4436 zproc_run_as ((const char *)lockfile, (const char *)group, (const char *)user);
4437 }
4438
4439 NAN_METHOD (Zproc::_set_io_threads) {
4440 if (info [0]->IsUndefined ())
4441 return Nan::ThrowTypeError ("method requires a `io_threads`");
4442 else
4443 if (!info [0]->IsNumber ())
4444 return Nan::ThrowTypeError ("`io_threads` must be a number");
4445 size_t io_threads = Nan::To<int64_t>(info [0]).FromJust ();
4446 zproc_set_io_threads ((size_t) io_threads);
4447 }
4448
4449 NAN_METHOD (Zproc::_set_max_sockets) {
4450 if (info [0]->IsUndefined ())
4451 return Nan::ThrowTypeError ("method requires a `max_sockets`");
4452 else
4453 if (!info [0]->IsNumber ())
4454 return Nan::ThrowTypeError ("`max_sockets` must be a number");
4455 size_t max_sockets = Nan::To<int64_t>(info [0]).FromJust ();
4456 zproc_set_max_sockets ((size_t) max_sockets);
4457 }
4458
4459 NAN_METHOD (Zproc::_set_biface) {
4460 char *value;
4461 if (info [0]->IsUndefined ())
4462 return Nan::ThrowTypeError ("method requires a `value`");
4463 else
4464 if (!info [0]->IsString ())
4465 return Nan::ThrowTypeError ("`value` must be a string");
4466 //else { // bjornw: remove brackets to keep scope
4467 Nan::Utf8String value_utf8 (info [0].As<String>());
4468 value = *value_utf8;
4469 //} //bjornw end
4470 zproc_set_biface ((const char *)value);
4471 }
4472
4473 NAN_METHOD (Zproc::_biface) {
4474 char *result = (char *) zproc_biface ();
4475 info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ());
4476 }
4477
4478 NAN_METHOD (Zproc::_set_log_ident) {
4479 char *value;
4480 if (info [0]->IsUndefined ())
4481 return Nan::ThrowTypeError ("method requires a `value`");
4482 else
4483 if (!info [0]->IsString ())
4484 return Nan::ThrowTypeError ("`value` must be a string");
4485 //else { // bjornw: remove brackets to keep scope
4486 Nan::Utf8String value_utf8 (info [0].As<String>());
4487 value = *value_utf8;
4488 //} //bjornw end
4489 zproc_set_log_ident ((const char *)value);
4490 }
4491
4492 NAN_METHOD (Zproc::_set_log_sender) {
4493 char *endpoint;
4494 if (info [0]->IsUndefined ())
4495 return Nan::ThrowTypeError ("method requires a `endpoint`");
4496 else
4497 if (!info [0]->IsString ())
4498 return Nan::ThrowTypeError ("`endpoint` must be a string");
4499 //else { // bjornw: remove brackets to keep scope
4500 Nan::Utf8String endpoint_utf8 (info [0].As<String>());
4501 endpoint = *endpoint_utf8;
4502 //} //bjornw end
4503 zproc_set_log_sender ((const char *)endpoint);
4504 }
4505
4506 NAN_METHOD (Zproc::_set_log_system) {
4507 if (info [0]->IsUndefined ())
4508 return Nan::ThrowTypeError ("method requires a `logsystem`");
4509
4510 //bool logsystem; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int
4511 bool logsystem;
4512
4513
4514 if (info [0]->IsBoolean ())
4515 {
4516 logsystem = Nan::To<bool>(info [0]).FromJust ();
4517 }
4518 else
4519 return Nan::ThrowTypeError ("`logsystem` must be a Boolean");
4520 zproc_set_log_system ((bool) logsystem);
4521 }
4522
4523 NAN_METHOD (Zproc::_log_error) {
4524 char *format;
4525 if (info [0]->IsUndefined ())
4526 return Nan::ThrowTypeError ("method requires a `format`");
4527 else
4528 if (!info [0]->IsString ())
4529 return Nan::ThrowTypeError ("`format` must be a string");
4530 //else { // bjornw: remove brackets to keep scope
4531 Nan::Utf8String format_utf8 (info [0].As<String>());
4532 format = *format_utf8;
4533 //} //bjornw end
4534 zproc_log_error ("%s", format);
4535 }
4536
4537 NAN_METHOD (Zproc::_log_warning) {
4538 char *format;
4539 if (info [0]->IsUndefined ())
4540 return Nan::ThrowTypeError ("method requires a `format`");
4541 else
4542 if (!info [0]->IsString ())
4543 return Nan::ThrowTypeError ("`format` must be a string");
4544 //else { // bjornw: remove brackets to keep scope
4545 Nan::Utf8String format_utf8 (info [0].As<String>());
4546 format = *format_utf8;
4547 //} //bjornw end
4548 zproc_log_warning ("%s", format);
4549 }
4550
4551 NAN_METHOD (Zproc::_log_notice) {
4552 char *format;
4553 if (info [0]->IsUndefined ())
4554 return Nan::ThrowTypeError ("method requires a `format`");
4555 else
4556 if (!info [0]->IsString ())
4557 return Nan::ThrowTypeError ("`format` must be a string");
4558 //else { // bjornw: remove brackets to keep scope
4559 Nan::Utf8String format_utf8 (info [0].As<String>());
4560 format = *format_utf8;
4561 //} //bjornw end
4562 zproc_log_notice ("%s", format);
4563 }
4564
4565 NAN_METHOD (Zproc::_log_info) {
4566 char *format;
4567 if (info [0]->IsUndefined ())
4568 return Nan::ThrowTypeError ("method requires a `format`");
4569 else
4570 if (!info [0]->IsString ())
4571 return Nan::ThrowTypeError ("`format` must be a string");
4572 //else { // bjornw: remove brackets to keep scope
4573 Nan::Utf8String format_utf8 (info [0].As<String>());
4574 format = *format_utf8;
4575 //} //bjornw end
4576 zproc_log_info ("%s", format);
4577 }
4578
4579 NAN_METHOD (Zproc::_log_debug) {
4580 char *format;
4581 if (info [0]->IsUndefined ())
4582 return Nan::ThrowTypeError ("method requires a `format`");
4583 else
4584 if (!info [0]->IsString ())
4585 return Nan::ThrowTypeError ("`format` must be a string");
4586 //else { // bjornw: remove brackets to keep scope
4587 Nan::Utf8String format_utf8 (info [0].As<String>());
4588 format = *format_utf8;
4589 //} //bjornw end
4590 zproc_log_debug ("%s", format);
45914380 }
45924381
45934382 NAN_METHOD (Zproc::_test) {
70506839 Nan::SetPrototypeMethod (tpl, "createPipe", _create_pipe);
70516840 Nan::SetPrototypeMethod (tpl, "handlerReset", _handler_reset);
70526841 Nan::SetPrototypeMethod (tpl, "catchInterrupts", _catch_interrupts);
6842 Nan::SetPrototypeMethod (tpl, "isInterrupted", _is_interrupted);
6843 Nan::SetPrototypeMethod (tpl, "setInterrupted", _set_interrupted);
70536844 Nan::SetPrototypeMethod (tpl, "fileExists", _file_exists);
70546845 Nan::SetPrototypeMethod (tpl, "fileModified", _file_modified);
70556846 Nan::SetPrototypeMethod (tpl, "fileMode", _file_mode);
70746865 Nan::SetPrototypeMethod (tpl, "socketLimit", _socket_limit);
70756866 Nan::SetPrototypeMethod (tpl, "setMaxMsgsz", _set_max_msgsz);
70766867 Nan::SetPrototypeMethod (tpl, "maxMsgsz", _max_msgsz);
6868 Nan::SetPrototypeMethod (tpl, "setZeroCopyRecv", _set_zero_copy_recv);
6869 Nan::SetPrototypeMethod (tpl, "zeroCopyRecv", _zero_copy_recv);
70776870 Nan::SetPrototypeMethod (tpl, "setFileStableAgeMsec", _set_file_stable_age_msec);
70786871 Nan::SetPrototypeMethod (tpl, "fileStableAgeMsec", _file_stable_age_msec);
70796872 Nan::SetPrototypeMethod (tpl, "setLinger", _set_linger);
71636956 zsys_catch_interrupts ();
71646957 }
71656958
6959 NAN_METHOD (Zsys::_is_interrupted) {
6960 bool result = zsys_is_interrupted ();
6961 info.GetReturnValue ().Set (Nan::New<Boolean>(result));
6962 }
6963
6964 NAN_METHOD (Zsys::_set_interrupted) {
6965 zsys_set_interrupted ();
6966 }
6967
71666968 NAN_METHOD (Zsys::_file_exists) {
71676969 char *filename;
71686970 if (info [0]->IsUndefined ())
75017303
75027304 NAN_METHOD (Zsys::_max_msgsz) {
75037305 int result = zsys_max_msgsz ();
7306 info.GetReturnValue ().Set (Nan::New<Number>(result));
7307 }
7308
7309 NAN_METHOD (Zsys::_set_zero_copy_recv) {
7310 if (info [0]->IsUndefined ())
7311 return Nan::ThrowTypeError ("method requires a `zero copy`");
7312
7313 //int zero_copy; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int
7314 int zero_copy;
7315
7316
7317 if (info [0]->IsNumber ())
7318 {
7319 zero_copy = Nan::To<int>(info [0]).FromJust ();
7320 }
7321 else
7322 return Nan::ThrowTypeError ("`zero copy` must be a number");
7323 zsys_set_zero_copy_recv ((int) zero_copy);
7324 }
7325
7326 NAN_METHOD (Zsys::_zero_copy_recv) {
7327 int result = zsys_zero_copy_recv ();
75047328 info.GetReturnValue ().Set (Nan::New<Number>(result));
75057329 }
75067330
588588 static NAN_METHOD (New);
589589 static NAN_METHOD (destroy);
590590 static NAN_METHOD (defined);
591 static NAN_METHOD (_args);
591592 static NAN_METHOD (_set_args);
593 static NAN_METHOD (_set_argsx);
592594 static NAN_METHOD (_set_env);
593595 static NAN_METHOD (_run);
594596 static NAN_METHOD (_returncode);
597599 static NAN_METHOD (_wait);
598600 static NAN_METHOD (_kill);
599601 static NAN_METHOD (_set_verbose);
600 static NAN_METHOD (_czmq_version);
601 static NAN_METHOD (_interrupted);
602 static NAN_METHOD (_has_curve);
603 static NAN_METHOD (_hostname);
604 static NAN_METHOD (_daemonize);
605 static NAN_METHOD (_run_as);
606 static NAN_METHOD (_set_io_threads);
607 static NAN_METHOD (_set_max_sockets);
608 static NAN_METHOD (_set_biface);
609 static NAN_METHOD (_biface);
610 static NAN_METHOD (_set_log_ident);
611 static NAN_METHOD (_set_log_sender);
612 static NAN_METHOD (_set_log_system);
613 static NAN_METHOD (_log_error);
614 static NAN_METHOD (_log_warning);
615 static NAN_METHOD (_log_notice);
616 static NAN_METHOD (_log_info);
617 static NAN_METHOD (_log_debug);
618602 static NAN_METHOD (_test);
619603 };
620604
827811 static NAN_METHOD (_create_pipe);
828812 static NAN_METHOD (_handler_reset);
829813 static NAN_METHOD (_catch_interrupts);
814 static NAN_METHOD (_is_interrupted);
815 static NAN_METHOD (_set_interrupted);
830816 static NAN_METHOD (_file_exists);
831817 static NAN_METHOD (_file_modified);
832818 static NAN_METHOD (_file_mode);
851837 static NAN_METHOD (_socket_limit);
852838 static NAN_METHOD (_set_max_msgsz);
853839 static NAN_METHOD (_max_msgsz);
840 static NAN_METHOD (_set_zero_copy_recv);
841 static NAN_METHOD (_zero_copy_recv);
854842 static NAN_METHOD (_set_file_stable_age_msec);
855843 static NAN_METHOD (_file_stable_age_msec);
856844 static NAN_METHOD (_set_linger);
5555 ./configure --enable-drafts=yes "${CONFIG_OPTS[@]}"
5656 make VERBOSE=1 install
5757
58 LD_LIBRARY_PATH=$BUILD_PREFIX/lib python bindings/python/test.py
58 # LD_LIBRARY_PATH/DYLD_LIBRARY_PATH do not work anymore on OSX, change directory instead
59 BASE_PWD=${PWD}
60 cd ${BUILD_PREFIX}/lib
61 LD_LIBRARY_PATH=$BUILD_PREFIX/lib python ${BASE_PWD}/bindings/python/test.py
48154815 lib.zproc_new.argtypes = []
48164816 lib.zproc_destroy.restype = None
48174817 lib.zproc_destroy.argtypes = [POINTER(zproc_p)]
4818 lib.zproc_args.restype = zlist_p
4819 lib.zproc_args.argtypes = [zproc_p]
48184820 lib.zproc_set_args.restype = None
4819 lib.zproc_set_args.argtypes = [zproc_p, zlistx_p]
4821 lib.zproc_set_args.argtypes = [zproc_p, POINTER(zlist_p)]
4822 lib.zproc_set_argsx.restype = None
4823 lib.zproc_set_argsx.argtypes = [zproc_p, c_char_p]
48204824 lib.zproc_set_env.restype = None
4821 lib.zproc_set_env.argtypes = [zproc_p, zhashx_p]
4825 lib.zproc_set_env.argtypes = [zproc_p, POINTER(zhash_p)]
48224826 lib.zproc_set_stdin.restype = None
48234827 lib.zproc_set_stdin.argtypes = [zproc_p, c_void_p]
48244828 lib.zproc_set_stdout.restype = None
48474851 lib.zproc_kill.argtypes = [zproc_p, c_int]
48484852 lib.zproc_set_verbose.restype = None
48494853 lib.zproc_set_verbose.argtypes = [zproc_p, c_bool]
4850 lib.zproc_czmq_version.restype = c_int
4851 lib.zproc_czmq_version.argtypes = []
4852 lib.zproc_interrupted.restype = c_bool
4853 lib.zproc_interrupted.argtypes = []
4854 lib.zproc_has_curve.restype = c_bool
4855 lib.zproc_has_curve.argtypes = []
4856 lib.zproc_hostname.restype = POINTER(c_char)
4857 lib.zproc_hostname.argtypes = []
4858 lib.zproc_daemonize.restype = None
4859 lib.zproc_daemonize.argtypes = [c_char_p]
4860 lib.zproc_run_as.restype = None
4861 lib.zproc_run_as.argtypes = [c_char_p, c_char_p, c_char_p]
4862 lib.zproc_set_io_threads.restype = None
4863 lib.zproc_set_io_threads.argtypes = [c_size_t]
4864 lib.zproc_set_max_sockets.restype = None
4865 lib.zproc_set_max_sockets.argtypes = [c_size_t]
4866 lib.zproc_set_biface.restype = None
4867 lib.zproc_set_biface.argtypes = [c_char_p]
4868 lib.zproc_biface.restype = c_char_p
4869 lib.zproc_biface.argtypes = []
4870 lib.zproc_set_log_ident.restype = None
4871 lib.zproc_set_log_ident.argtypes = [c_char_p]
4872 lib.zproc_set_log_sender.restype = None
4873 lib.zproc_set_log_sender.argtypes = [c_char_p]
4874 lib.zproc_set_log_system.restype = None
4875 lib.zproc_set_log_system.argtypes = [c_bool]
4876 lib.zproc_log_error.restype = None
4877 lib.zproc_log_error.argtypes = [c_char_p]
4878 lib.zproc_log_warning.restype = None
4879 lib.zproc_log_warning.argtypes = [c_char_p]
4880 lib.zproc_log_notice.restype = None
4881 lib.zproc_log_notice.argtypes = [c_char_p]
4882 lib.zproc_log_info.restype = None
4883 lib.zproc_log_info.argtypes = [c_char_p]
4884 lib.zproc_log_debug.restype = None
4885 lib.zproc_log_debug.argtypes = [c_char_p]
48864854 lib.zproc_test.restype = None
48874855 lib.zproc_test.argtypes = [c_bool]
48884856
49364904 "Determine whether the object is valid by converting to boolean" # Python 2
49374905 return self._as_parameter_.__nonzero__()
49384906
4939 def set_args(self, args):
4907 def args(self):
4908 """
4909 Return command line arguments (the first item is the executable) or
4910 NULL if not set.
4911 """
4912 return Zlist(lib.zproc_args(self._as_parameter_), True)
4913
4914 def set_args(self, arguments):
49404915 """
49414916 Setup the command line arguments, the first item must be an (absolute) filename
49424917 to run.
49434918 """
4944 return lib.zproc_set_args(self._as_parameter_, args)
4945
4946 def set_env(self, args):
4919 return lib.zproc_set_args(self._as_parameter_, byref(zlist_p.from_param(arguments)))
4920
4921 def set_argsx(self, arguments, *args):
4922 """
4923 Setup the command line arguments, the first item must be an (absolute) filename
4924 to run. Variadic function, must be NULL terminated.
4925 """
4926 return lib.zproc_set_argsx(self._as_parameter_, arguments, *args)
4927
4928 def set_env(self, arguments):
49474929 """
49484930 Setup the environment variables for the process.
49494931 """
4950 return lib.zproc_set_env(self._as_parameter_, args)
4932 return lib.zproc_set_env(self._as_parameter_, byref(zhash_p.from_param(arguments)))
49514933
49524934 def set_stdin(self, socket):
49534935 """
49964978
49974979 def run(self):
49984980 """
4999 Starts the process.
4981 Starts the process, return just before execve/CreateProcess.
50004982 """
50014983 return lib.zproc_run(self._as_parameter_)
50024984
50415023 set verbose mode
50425024 """
50435025 return lib.zproc_set_verbose(self._as_parameter_, verbose)
5044
5045 @staticmethod
5046 def czmq_version():
5047 """
5048 Returns CZMQ version as a single 6-digit integer encoding the major
5049 version (x 10000), the minor version (x 100) and the patch.
5050 """
5051 return lib.zproc_czmq_version()
5052
5053 @staticmethod
5054 def interrupted():
5055 """
5056 Returns true if the process received a SIGINT or SIGTERM signal.
5057 It is good practice to use this method to exit any infinite loop
5058 processing messages.
5059 """
5060 return lib.zproc_interrupted()
5061
5062 @staticmethod
5063 def has_curve():
5064 """
5065 Returns true if the underlying libzmq supports CURVE security.
5066 """
5067 return lib.zproc_has_curve()
5068
5069 @staticmethod
5070 def hostname():
5071 """
5072 Return current host name, for use in public tcp:// endpoints.
5073 If the host name is not resolvable, returns NULL.
5074 """
5075 return return_fresh_string(lib.zproc_hostname())
5076
5077 @staticmethod
5078 def daemonize(workdir):
5079 """
5080 Move the current process into the background. The precise effect
5081 depends on the operating system. On POSIX boxes, moves to a specified
5082 working directory (if specified), closes all file handles, reopens
5083 stdin, stdout, and stderr to the null device, and sets the process to
5084 ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
5085 was an error.
5086 """
5087 return lib.zproc_daemonize(workdir)
5088
5089 @staticmethod
5090 def run_as(lockfile, group, user):
5091 """
5092 Drop the process ID into the lockfile, with exclusive lock, and
5093 switch the process to the specified group and/or user. Any of the
5094 arguments may be null, indicating a no-op. Returns 0 on success,
5095 -1 on failure. Note if you combine this with zsys_daemonize, run
5096 after, not before that method, or the lockfile will hold the wrong
5097 process ID.
5098 """
5099 return lib.zproc_run_as(lockfile, group, user)
5100
5101 @staticmethod
5102 def set_io_threads(io_threads):
5103 """
5104 Configure the number of I/O threads that ZeroMQ will use. A good
5105 rule of thumb is one thread per gigabit of traffic in or out. The
5106 default is 1, sufficient for most applications. If the environment
5107 variable ZSYS_IO_THREADS is defined, that provides the default.
5108 Note that this method is valid only before any socket is created.
5109 """
5110 return lib.zproc_set_io_threads(io_threads)
5111
5112 @staticmethod
5113 def set_max_sockets(max_sockets):
5114 """
5115 Configure the number of sockets that ZeroMQ will allow. The default
5116 is 1024. The actual limit depends on the system, and you can query it
5117 by using zsys_socket_limit (). A value of zero means "maximum".
5118 Note that this method is valid only before any socket is created.
5119 """
5120 return lib.zproc_set_max_sockets(max_sockets)
5121
5122 @staticmethod
5123 def set_biface(value):
5124 """
5125 Set network interface name to use for broadcasts, particularly zbeacon.
5126 This lets the interface be configured for test environments where required.
5127 For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
5128 the default when there is no specified interface. If the environment
5129 variable ZSYS_INTERFACE is set, use that as the default interface name.
5130 Setting the interface to "*" means "use all available interfaces".
5131 """
5132 return lib.zproc_set_biface(value)
5133
5134 @staticmethod
5135 def biface():
5136 """
5137 Return network interface to use for broadcasts, or "" if none was set.
5138 """
5139 return lib.zproc_biface()
5140
5141 @staticmethod
5142 def set_log_ident(value):
5143 """
5144 Set log identity, which is a string that prefixes all log messages sent
5145 by this process. The log identity defaults to the environment variable
5146 ZSYS_LOGIDENT, if that is set.
5147 """
5148 return lib.zproc_set_log_ident(value)
5149
5150 @staticmethod
5151 def set_log_sender(endpoint):
5152 """
5153 Sends log output to a PUB socket bound to the specified endpoint. To
5154 collect such log output, create a SUB socket, subscribe to the traffic
5155 you care about, and connect to the endpoint. Log traffic is sent as a
5156 single string frame, in the same format as when sent to stdout. The
5157 log system supports a single sender; multiple calls to this method will
5158 bind the same sender to multiple endpoints. To disable the sender, call
5159 this method with a null argument.
5160 """
5161 return lib.zproc_set_log_sender(endpoint)
5162
5163 @staticmethod
5164 def set_log_system(logsystem):
5165 """
5166 Enable or disable logging to the system facility (syslog on POSIX boxes,
5167 event log on Windows). By default this is disabled.
5168 """
5169 return lib.zproc_set_log_system(logsystem)
5170
5171 @staticmethod
5172 def log_error(format, *args):
5173 """
5174 Log error condition - highest priority
5175 """
5176 return lib.zproc_log_error(format, *args)
5177
5178 @staticmethod
5179 def log_warning(format, *args):
5180 """
5181 Log warning condition - high priority
5182 """
5183 return lib.zproc_log_warning(format, *args)
5184
5185 @staticmethod
5186 def log_notice(format, *args):
5187 """
5188 Log normal, but significant, condition - normal priority
5189 """
5190 return lib.zproc_log_notice(format, *args)
5191
5192 @staticmethod
5193 def log_info(format, *args):
5194 """
5195 Log informational message - low priority
5196 """
5197 return lib.zproc_log_info(format, *args)
5198
5199 @staticmethod
5200 def log_debug(format, *args):
5201 """
5202 Log debug-level message - lowest priority
5203 """
5204 return lib.zproc_log_debug(format, *args)
52055026
52065027 @staticmethod
52075028 def test(verbose):
72047025 lib.zsys_handler_reset.argtypes = []
72057026 lib.zsys_catch_interrupts.restype = None
72067027 lib.zsys_catch_interrupts.argtypes = []
7028 lib.zsys_is_interrupted.restype = c_bool
7029 lib.zsys_is_interrupted.argtypes = []
7030 lib.zsys_set_interrupted.restype = None
7031 lib.zsys_set_interrupted.argtypes = []
72077032 lib.zsys_file_exists.restype = c_bool
72087033 lib.zsys_file_exists.argtypes = [c_char_p]
72097034 lib.zsys_file_modified.restype = c_int
72627087 lib.zsys_set_max_msgsz.argtypes = [c_int]
72637088 lib.zsys_max_msgsz.restype = c_int
72647089 lib.zsys_max_msgsz.argtypes = []
7090 lib.zsys_set_zero_copy_recv.restype = None
7091 lib.zsys_set_zero_copy_recv.argtypes = [c_int]
7092 lib.zsys_zero_copy_recv.restype = c_int
7093 lib.zsys_zero_copy_recv.argtypes = []
72657094 lib.zsys_set_file_stable_age_msec.restype = None
72667095 lib.zsys_set_file_stable_age_msec.argtypes = [msecs_p]
72677096 lib.zsys_file_stable_age_msec.restype = msecs_p
74297258 return lib.zsys_catch_interrupts()
74307259
74317260 @staticmethod
7261 def is_interrupted():
7262 """
7263 Check if default interrupt handler of Ctrl-C or SIGTERM was called.
7264 Does not work if ZSYS_SIGHANDLER is false and code does not call
7265 set interrupted on signal.
7266 """
7267 return lib.zsys_is_interrupted()
7268
7269 @staticmethod
7270 def set_interrupted():
7271 """
7272 Set interrupted flag. This is done by default signal handler, however
7273 this can be handy for language bindings or cases without default
7274 signal handler.
7275 """
7276 return lib.zsys_set_interrupted()
7277
7278 @staticmethod
74327279 def file_exists(filename):
74337280 """
74347281 Return 1 if file exists, else zero
76787525 Return maximum message size.
76797526 """
76807527 return lib.zsys_max_msgsz()
7528
7529 @staticmethod
7530 def set_zero_copy_recv(zero_copy):
7531 """
7532 Configure whether to use zero copy strategy in libzmq. If the environment
7533 variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
7534 Otherwise the default is 1.
7535 """
7536 return lib.zsys_set_zero_copy_recv(zero_copy)
7537
7538 @staticmethod
7539 def zero_copy_recv():
7540 """
7541 Return ZMQ_ZERO_COPY_RECV option.
7542 """
7543 return lib.zsys_zero_copy_recv()
76817544
76827545 @staticmethod
76837546 def set_file_stable_age_msec(file_stable_age_msec):
0 ################################################################################
1 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
2 # Read the zproject/README.md for information about making permanent changes. #
3 ################################################################################
4 from setuptools import setup
5
6 setup(
7 name = "czmq",
8 version = "4.1.1",
9 license = "mplv2",
10 description = """Python bindings of: the high-level c binding for 0mq""",
11 url = "https://github.com/zeromq/czmq",
12 packages = ["czmq"],
13 install_requires = [
14 ],
15 )
16 ################################################################################
17 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
18 # Read the zproject/README.md for information about making permanent changes. #
19 ################################################################################
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
2525 # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface
2626 self._p = utils.ffi.gc(p, libczmq_destructors.zproc_destroy_py)
2727
28 def set_args(self, args):
28 def args(self):
29 """
30 Return command line arguments (the first item is the executable) or
31 NULL if not set.
32 """
33 return utils.lib.zproc_args(self._p)
34
35 def set_args(self, arguments):
2936 """
3037 Setup the command line arguments, the first item must be an (absolute) filename
3138 to run.
3239 """
33 utils.lib.zproc_set_args(self._p, args._p)
40 foo = utils.to_strings (argv_p)
41 if foo is not None:
42 foo_p = utils.ffi.new("struct _zlist_t *[1]")
43 foo_p [0] = foo
44 utils.lib.dproto_set_argv(self._p, foo_p)
45 return
3446
35 def set_env(self, args):
47 utils.lib.zproc_set_args(self._p, arguments._p)
48
49 def set_argsx(self, arguments, ):
50 """
51 Setup the command line arguments, the first item must be an (absolute) filename
52 to run. Variadic function, must be NULL terminated.
53 """
54 utils.lib.zproc_set_argsx(self._p, utils.to_bytes(arguments), )
55
56 def set_env(self, arguments):
3657 """
3758 Setup the environment variables for the process.
3859 """
39 utils.lib.zproc_set_env(self._p, args._p)
60 utils.lib.zproc_set_env(self._p, arguments._p)
4061
4162 def set_stdin(self, socket):
4263 """
85106
86107 def run(self):
87108 """
88 Starts the process.
109 Starts the process, return just before execve/CreateProcess.
89110 """
90111 return utils.lib.zproc_run(self._p)
91112
131152 """
132153 utils.lib.zproc_set_verbose(self._p, verbose)
133154
134 def czmq_version():
135 """
136 Returns CZMQ version as a single 6-digit integer encoding the major
137 version (x 10000), the minor version (x 100) and the patch.
138 """
139 return utils.lib.zproc_czmq_version()
140
141 def interrupted():
142 """
143 Returns true if the process received a SIGINT or SIGTERM signal.
144 It is good practice to use this method to exit any infinite loop
145 processing messages.
146 """
147 return utils.lib.zproc_interrupted()
148
149 def has_curve():
150 """
151 Returns true if the underlying libzmq supports CURVE security.
152 """
153 return utils.lib.zproc_has_curve()
154
155 def hostname():
156 """
157 Return current host name, for use in public tcp:// endpoints.
158 If the host name is not resolvable, returns NULL.
159 """
160 return utils.lib.zproc_hostname()
161
162 def daemonize(workdir):
163 """
164 Move the current process into the background. The precise effect
165 depends on the operating system. On POSIX boxes, moves to a specified
166 working directory (if specified), closes all file handles, reopens
167 stdin, stdout, and stderr to the null device, and sets the process to
168 ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
169 was an error.
170 """
171 utils.lib.zproc_daemonize(utils.to_bytes(workdir))
172
173 def run_as(lockfile, group, user):
174 """
175 Drop the process ID into the lockfile, with exclusive lock, and
176 switch the process to the specified group and/or user. Any of the
177 arguments may be null, indicating a no-op. Returns 0 on success,
178 -1 on failure. Note if you combine this with zsys_daemonize, run
179 after, not before that method, or the lockfile will hold the wrong
180 process ID.
181 """
182 utils.lib.zproc_run_as(utils.to_bytes(lockfile), utils.to_bytes(group), utils.to_bytes(user))
183
184 def set_io_threads(io_threads):
185 """
186 Configure the number of I/O threads that ZeroMQ will use. A good
187 rule of thumb is one thread per gigabit of traffic in or out. The
188 default is 1, sufficient for most applications. If the environment
189 variable ZSYS_IO_THREADS is defined, that provides the default.
190 Note that this method is valid only before any socket is created.
191 """
192 utils.lib.zproc_set_io_threads(io_threads)
193
194 def set_max_sockets(max_sockets):
195 """
196 Configure the number of sockets that ZeroMQ will allow. The default
197 is 1024. The actual limit depends on the system, and you can query it
198 by using zsys_socket_limit (). A value of zero means "maximum".
199 Note that this method is valid only before any socket is created.
200 """
201 utils.lib.zproc_set_max_sockets(max_sockets)
202
203 def set_biface(value):
204 """
205 Set network interface name to use for broadcasts, particularly zbeacon.
206 This lets the interface be configured for test environments where required.
207 For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
208 the default when there is no specified interface. If the environment
209 variable ZSYS_INTERFACE is set, use that as the default interface name.
210 Setting the interface to "*" means "use all available interfaces".
211 """
212 utils.lib.zproc_set_biface(utils.to_bytes(value))
213
214 def biface():
215 """
216 Return network interface to use for broadcasts, or "" if none was set.
217 """
218 return utils.lib.zproc_biface()
219
220 def set_log_ident(value):
221 """
222 Set log identity, which is a string that prefixes all log messages sent
223 by this process. The log identity defaults to the environment variable
224 ZSYS_LOGIDENT, if that is set.
225 """
226 utils.lib.zproc_set_log_ident(utils.to_bytes(value))
227
228 def set_log_sender(endpoint):
229 """
230 Sends log output to a PUB socket bound to the specified endpoint. To
231 collect such log output, create a SUB socket, subscribe to the traffic
232 you care about, and connect to the endpoint. Log traffic is sent as a
233 single string frame, in the same format as when sent to stdout. The
234 log system supports a single sender; multiple calls to this method will
235 bind the same sender to multiple endpoints. To disable the sender, call
236 this method with a null argument.
237 """
238 utils.lib.zproc_set_log_sender(utils.to_bytes(endpoint))
239
240 def set_log_system(logsystem):
241 """
242 Enable or disable logging to the system facility (syslog on POSIX boxes,
243 event log on Windows). By default this is disabled.
244 """
245 utils.lib.zproc_set_log_system(logsystem)
246
247 def log_error(format, ):
248 """
249 Log error condition - highest priority
250 """
251 utils.lib.zproc_log_error(format, )
252
253 def log_warning(format, ):
254 """
255 Log warning condition - high priority
256 """
257 utils.lib.zproc_log_warning(format, )
258
259 def log_notice(format, ):
260 """
261 Log normal, but significant, condition - normal priority
262 """
263 utils.lib.zproc_log_notice(format, )
264
265 def log_info(format, ):
266 """
267 Log informational message - low priority
268 """
269 utils.lib.zproc_log_info(format, )
270
271 def log_debug(format, ):
272 """
273 Log debug-level message - lowest priority
274 """
275 utils.lib.zproc_log_debug(format, )
276
277155 def test(verbose):
278156 """
279157 Self test of this class.
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
8686 """
8787 utils.lib.zsys_catch_interrupts()
8888
89 def is_interrupted():
90 """
91 Check if default interrupt handler of Ctrl-C or SIGTERM was called.
92 Does not work if ZSYS_SIGHANDLER is false and code does not call
93 set interrupted on signal.
94 """
95 return utils.lib.zsys_is_interrupted()
96
97 def set_interrupted():
98 """
99 Set interrupted flag. This is done by default signal handler, however
100 this can be handy for language bindings or cases without default
101 signal handler.
102 """
103 utils.lib.zsys_set_interrupted()
104
89105 def file_exists(filename):
90106 """
91107 Return 1 if file exists, else zero
307323 Return maximum message size.
308324 """
309325 return utils.lib.zsys_max_msgsz()
326
327 def set_zero_copy_recv(zero_copy):
328 """
329 Configure whether to use zero copy strategy in libzmq. If the environment
330 variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
331 Otherwise the default is 1.
332 """
333 utils.lib.zsys_set_zero_copy_recv(zero_copy)
334
335 def zero_copy_recv():
336 """
337 Return ZMQ_ZERO_COPY_RECV option.
338 """
339 return utils.lib.zsys_zero_copy_recv()
310340
311341 def set_file_stable_age_msec(file_stable_age_msec):
312342 """
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from . import destructors
66 libczmq_destructors = destructors.lib
77
11 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
4 import utils
4 from . import utils
55 from .Zactor import *
66 from .Zargs import *
7 MODE_BASE64_STD = 0 # Standard base 64
8 MODE_BASE64_URL = 1 # URL and filename friendly base 64
9 MODE_BASE32_STD = 2 # Standard base 32
10 MODE_BASE32_HEX = 3 # Extended hex base 32
11 MODE_BASE16 = 4 # Standard base 16
12 MODE_Z85 = 5 # Z85 from ZeroMQ RFC 32
713 from .Zarmour import *
814 from .Zcert import *
915 from .Zcertstore import *
1218 from .Zconfig import *
1319 from .Zdigest import *
1420 from .Zdir import *
21 CREATE = 1 # Creates a new file
22 DELETE = 2 # Delete a file
1523 from .ZdirPatch import *
1624 from .Zfile import *
25 MORE = 1 #
26 REUSE = 2 #
27 DONTWAIT = 4 #
1728 from .Zframe import *
1829 from .Zhash import *
1930 from .Zhashx import *
6767 //
6868 // An example - to send $KTHXBAI string
6969 //
70 // if (zstr_send (self->pipe, "$KTHXBAI") == 0)
71 // zsock_wait (self->pipe);
70 // if (zstr_send (self, "$KTHXBAI") == 0)
71 // zsock_wait (self);
7272 typedef void (zactor_destructor_fn) (
7373 zactor_t *self);
7474
22572257 void
22582258 zproc_destroy (zproc_t **self_p);
22592259
2260 // Return command line arguments (the first item is the executable) or
2261 // NULL if not set.
2262 zlist_t *
2263 zproc_args (zproc_t *self);
2264
22602265 // Setup the command line arguments, the first item must be an (absolute) filename
22612266 // to run.
22622267 void
2263 zproc_set_args (zproc_t *self, zlistx_t *args);
2268 zproc_set_args (zproc_t *self, zlist_t **arguments);
2269
2270 // Setup the command line arguments, the first item must be an (absolute) filename
2271 // to run. Variadic function, must be NULL terminated.
2272 void
2273 zproc_set_argsx (zproc_t *self, const char *arguments, ...);
22642274
22652275 // Setup the environment variables for the process.
22662276 void
2267 zproc_set_env (zproc_t *self, zhashx_t *args);
2277 zproc_set_env (zproc_t *self, zhash_t **arguments);
22682278
22692279 // Connects process stdin with a readable ('>', connect) zeromq socket. If
22702280 // socket argument is NULL, zproc creates own managed pair of inproc
22992309 void *
23002310 zproc_stderr (zproc_t *self);
23012311
2302 // Starts the process.
2312 // Starts the process, return just before execve/CreateProcess.
23032313 int
23042314 zproc_run (zproc_t *self);
23052315
23302340 // set verbose mode
23312341 void
23322342 zproc_set_verbose (zproc_t *self, bool verbose);
2333
2334 // Returns CZMQ version as a single 6-digit integer encoding the major
2335 // version (x 10000), the minor version (x 100) and the patch.
2336 int
2337 zproc_czmq_version (void);
2338
2339 // Returns true if the process received a SIGINT or SIGTERM signal.
2340 // It is good practice to use this method to exit any infinite loop
2341 // processing messages.
2342 bool
2343 zproc_interrupted (void);
2344
2345 // Returns true if the underlying libzmq supports CURVE security.
2346 bool
2347 zproc_has_curve (void);
2348
2349 // Return current host name, for use in public tcp:// endpoints.
2350 // If the host name is not resolvable, returns NULL.
2351 char *
2352 zproc_hostname (void);
2353
2354 // Move the current process into the background. The precise effect
2355 // depends on the operating system. On POSIX boxes, moves to a specified
2356 // working directory (if specified), closes all file handles, reopens
2357 // stdin, stdout, and stderr to the null device, and sets the process to
2358 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
2359 // was an error.
2360 void
2361 zproc_daemonize (const char *workdir);
2362
2363 // Drop the process ID into the lockfile, with exclusive lock, and
2364 // switch the process to the specified group and/or user. Any of the
2365 // arguments may be null, indicating a no-op. Returns 0 on success,
2366 // -1 on failure. Note if you combine this with zsys_daemonize, run
2367 // after, not before that method, or the lockfile will hold the wrong
2368 // process ID.
2369 void
2370 zproc_run_as (const char *lockfile, const char *group, const char *user);
2371
2372 // Configure the number of I/O threads that ZeroMQ will use. A good
2373 // rule of thumb is one thread per gigabit of traffic in or out. The
2374 // default is 1, sufficient for most applications. If the environment
2375 // variable ZSYS_IO_THREADS is defined, that provides the default.
2376 // Note that this method is valid only before any socket is created.
2377 void
2378 zproc_set_io_threads (size_t io_threads);
2379
2380 // Configure the number of sockets that ZeroMQ will allow. The default
2381 // is 1024. The actual limit depends on the system, and you can query it
2382 // by using zsys_socket_limit (). A value of zero means "maximum".
2383 // Note that this method is valid only before any socket is created.
2384 void
2385 zproc_set_max_sockets (size_t max_sockets);
2386
2387 // Set network interface name to use for broadcasts, particularly zbeacon.
2388 // This lets the interface be configured for test environments where required.
2389 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
2390 // the default when there is no specified interface. If the environment
2391 // variable ZSYS_INTERFACE is set, use that as the default interface name.
2392 // Setting the interface to "*" means "use all available interfaces".
2393 void
2394 zproc_set_biface (const char *value);
2395
2396 // Return network interface to use for broadcasts, or "" if none was set.
2397 const char *
2398 zproc_biface (void);
2399
2400 // Set log identity, which is a string that prefixes all log messages sent
2401 // by this process. The log identity defaults to the environment variable
2402 // ZSYS_LOGIDENT, if that is set.
2403 void
2404 zproc_set_log_ident (const char *value);
2405
2406 // Sends log output to a PUB socket bound to the specified endpoint. To
2407 // collect such log output, create a SUB socket, subscribe to the traffic
2408 // you care about, and connect to the endpoint. Log traffic is sent as a
2409 // single string frame, in the same format as when sent to stdout. The
2410 // log system supports a single sender; multiple calls to this method will
2411 // bind the same sender to multiple endpoints. To disable the sender, call
2412 // this method with a null argument.
2413 void
2414 zproc_set_log_sender (const char *endpoint);
2415
2416 // Enable or disable logging to the system facility (syslog on POSIX boxes,
2417 // event log on Windows). By default this is disabled.
2418 void
2419 zproc_set_log_system (bool logsystem);
2420
2421 // Log error condition - highest priority
2422 void
2423 zproc_log_error (const char *format, ...);
2424
2425 // Log warning condition - high priority
2426 void
2427 zproc_log_warning (const char *format, ...);
2428
2429 // Log normal, but significant, condition - normal priority
2430 void
2431 zproc_log_notice (const char *format, ...);
2432
2433 // Log informational message - low priority
2434 void
2435 zproc_log_info (const char *format, ...);
2436
2437 // Log debug-level message - lowest priority
2438 void
2439 zproc_log_debug (const char *format, ...);
24402343
24412344 // Self test of this class.
24422345 void
35943497 void
35953498 zsys_catch_interrupts (void);
35963499
3500 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
3501 // Does not work if ZSYS_SIGHANDLER is false and code does not call
3502 // set interrupted on signal.
3503 bool
3504 zsys_is_interrupted (void);
3505
3506 // Set interrupted flag. This is done by default signal handler, however
3507 // this can be handy for language bindings or cases without default
3508 // signal handler.
3509 void
3510 zsys_set_interrupted (void);
3511
35973512 // Return 1 if file exists, else zero
35983513 bool
35993514 zsys_file_exists (const char *filename);
37573672 // Return maximum message size.
37583673 int
37593674 zsys_max_msgsz (void);
3675
3676 // Configure whether to use zero copy strategy in libzmq. If the environment
3677 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
3678 // Otherwise the default is 1.
3679 void
3680 zsys_set_zero_copy_recv (int zero_copy);
3681
3682 // Return ZMQ_ZERO_COPY_RECV option.
3683 int
3684 zsys_zero_copy_recv (void);
37603685
37613686 // Configure the threshold value of filesystem object age per st_mtime
37623687 // that should elapse until we consider that object "stable" at the
55
66 setup(
77 name = "czmq_cffi",
8 version = "4.1.0",
8 version = "4.1.1",
99 license = "mplv2",
1010 description = """Python cffi bindings of: the high-level c binding for 0mq""",
1111 packages = ["czmq_cffi", ],
88
99
1010 ///
11 // Return command line arguments (the first item is the executable) or
12 // NULL if not set.
13 QmlZlist *QmlZproc::args () {
14 QmlZlist *retQ_ = new QmlZlist ();
15 retQ_->self = zproc_args (self);
16 return retQ_;
17 };
18
19 ///
1120 // Setup the command line arguments, the first item must be an (absolute) filename
1221 // to run.
13 void QmlZproc::setArgs (QmlZlistx *args) {
14 zproc_set_args (self, args->self);
22 void QmlZproc::setArgs (QmlZlist *arguments) {
23 zproc_set_args (self, &arguments->self);
24 };
25
26 ///
27 // Setup the command line arguments, the first item must be an (absolute) filename
28 // to run. Variadic function, must be NULL terminated.
29 void QmlZproc::setArgsx (const QString &arguments) {
30 zproc_set_argsx (self, arguments.toUtf8().data());
1531 };
1632
1733 ///
1834 // Setup the environment variables for the process.
19 void QmlZproc::setEnv (QmlZhashx *args) {
20 zproc_set_env (self, args->self);
35 void QmlZproc::setEnv (QmlZhash *arguments) {
36 zproc_set_env (self, &arguments->self);
2137 };
2238
2339 ///
6682 };
6783
6884 ///
69 // Starts the process.
85 // Starts the process, return just before execve/CreateProcess.
7086 int QmlZproc::run () {
7187 return zproc_run (self);
7288 };
120136
121137
122138 ///
123 // Returns CZMQ version as a single 6-digit integer encoding the major
124 // version (x 10000), the minor version (x 100) and the patch.
125 int QmlZprocAttached::czmqVersion () {
126 return zproc_czmq_version ();
127 };
128
129 ///
130 // Returns true if the process received a SIGINT or SIGTERM signal.
131 // It is good practice to use this method to exit any infinite loop
132 // processing messages.
133 bool QmlZprocAttached::interrupted () {
134 return zproc_interrupted ();
135 };
136
137 ///
138 // Returns true if the underlying libzmq supports CURVE security.
139 bool QmlZprocAttached::hasCurve () {
140 return zproc_has_curve ();
141 };
142
143 ///
144 // Return current host name, for use in public tcp:// endpoints.
145 // If the host name is not resolvable, returns NULL.
146 QString QmlZprocAttached::hostname () {
147 char *retStr_ = zproc_hostname ();
148 QString retQStr_ = QString (retStr_);
149 free (retStr_);
150 return retQStr_;
151 };
152
153 ///
154 // Move the current process into the background. The precise effect
155 // depends on the operating system. On POSIX boxes, moves to a specified
156 // working directory (if specified), closes all file handles, reopens
157 // stdin, stdout, and stderr to the null device, and sets the process to
158 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
159 // was an error.
160 void QmlZprocAttached::daemonize (const QString &workdir) {
161 zproc_daemonize (workdir.toUtf8().data());
162 };
163
164 ///
165 // Drop the process ID into the lockfile, with exclusive lock, and
166 // switch the process to the specified group and/or user. Any of the
167 // arguments may be null, indicating a no-op. Returns 0 on success,
168 // -1 on failure. Note if you combine this with zsys_daemonize, run
169 // after, not before that method, or the lockfile will hold the wrong
170 // process ID.
171 void QmlZprocAttached::runAs (const QString &lockfile, const QString &group, const QString &user) {
172 zproc_run_as (lockfile.toUtf8().data(), group.toUtf8().data(), user.toUtf8().data());
173 };
174
175 ///
176 // Configure the number of I/O threads that ZeroMQ will use. A good
177 // rule of thumb is one thread per gigabit of traffic in or out. The
178 // default is 1, sufficient for most applications. If the environment
179 // variable ZSYS_IO_THREADS is defined, that provides the default.
180 // Note that this method is valid only before any socket is created.
181 void QmlZprocAttached::setIoThreads (size_t ioThreads) {
182 zproc_set_io_threads (ioThreads);
183 };
184
185 ///
186 // Configure the number of sockets that ZeroMQ will allow. The default
187 // is 1024. The actual limit depends on the system, and you can query it
188 // by using zsys_socket_limit (). A value of zero means "maximum".
189 // Note that this method is valid only before any socket is created.
190 void QmlZprocAttached::setMaxSockets (size_t maxSockets) {
191 zproc_set_max_sockets (maxSockets);
192 };
193
194 ///
195 // Set network interface name to use for broadcasts, particularly zbeacon.
196 // This lets the interface be configured for test environments where required.
197 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
198 // the default when there is no specified interface. If the environment
199 // variable ZSYS_INTERFACE is set, use that as the default interface name.
200 // Setting the interface to "*" means "use all available interfaces".
201 void QmlZprocAttached::setBiface (const QString &value) {
202 zproc_set_biface (value.toUtf8().data());
203 };
204
205 ///
206 // Return network interface to use for broadcasts, or "" if none was set.
207 const QString QmlZprocAttached::biface () {
208 return QString (zproc_biface ());
209 };
210
211 ///
212 // Set log identity, which is a string that prefixes all log messages sent
213 // by this process. The log identity defaults to the environment variable
214 // ZSYS_LOGIDENT, if that is set.
215 void QmlZprocAttached::setLogIdent (const QString &value) {
216 zproc_set_log_ident (value.toUtf8().data());
217 };
218
219 ///
220 // Sends log output to a PUB socket bound to the specified endpoint. To
221 // collect such log output, create a SUB socket, subscribe to the traffic
222 // you care about, and connect to the endpoint. Log traffic is sent as a
223 // single string frame, in the same format as when sent to stdout. The
224 // log system supports a single sender; multiple calls to this method will
225 // bind the same sender to multiple endpoints. To disable the sender, call
226 // this method with a null argument.
227 void QmlZprocAttached::setLogSender (const QString &endpoint) {
228 zproc_set_log_sender (endpoint.toUtf8().data());
229 };
230
231 ///
232 // Enable or disable logging to the system facility (syslog on POSIX boxes,
233 // event log on Windows). By default this is disabled.
234 void QmlZprocAttached::setLogSystem (bool logsystem) {
235 zproc_set_log_system (logsystem);
236 };
237
238 ///
239 // Log error condition - highest priority
240 void QmlZprocAttached::logError (const QString &format) {
241 zproc_log_error ("%s", format.toUtf8().data());
242 };
243
244 ///
245 // Log warning condition - high priority
246 void QmlZprocAttached::logWarning (const QString &format) {
247 zproc_log_warning ("%s", format.toUtf8().data());
248 };
249
250 ///
251 // Log normal, but significant, condition - normal priority
252 void QmlZprocAttached::logNotice (const QString &format) {
253 zproc_log_notice ("%s", format.toUtf8().data());
254 };
255
256 ///
257 // Log informational message - low priority
258 void QmlZprocAttached::logInfo (const QString &format) {
259 zproc_log_info ("%s", format.toUtf8().data());
260 };
261
262 ///
263 // Log debug-level message - lowest priority
264 void QmlZprocAttached::logDebug (const QString &format) {
265 zproc_log_debug ("%s", format.toUtf8().data());
266 };
267
268 ///
269139 // Self test of this class.
270140 void QmlZprocAttached::test (bool verbose) {
271141 zproc_test (verbose);
2727 static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZproc.cpp
2828
2929 public slots:
30 // Return command line arguments (the first item is the executable) or
31 // NULL if not set.
32 QmlZlist *args ();
33
3034 // Setup the command line arguments, the first item must be an (absolute) filename
3135 // to run.
32 void setArgs (QmlZlistx *args);
36 void setArgs (QmlZlist *arguments);
37
38 // Setup the command line arguments, the first item must be an (absolute) filename
39 // to run. Variadic function, must be NULL terminated.
40 void setArgsx (const QString &arguments);
3341
3442 // Setup the environment variables for the process.
35 void setEnv (QmlZhashx *args);
43 void setEnv (QmlZhash *arguments);
3644
3745 // Connects process stdin with a readable ('>', connect) zeromq socket. If
3846 // socket argument is NULL, zproc creates own managed pair of inproc
6169 // not initialized or external sockets.
6270 void *stderr ();
6371
64 // Starts the process.
72 // Starts the process, return just before execve/CreateProcess.
6573 int run ();
6674
6775 // process exit code
97105 };
98106
99107 public slots:
100 // Returns CZMQ version as a single 6-digit integer encoding the major
101 // version (x 10000), the minor version (x 100) and the patch.
102 int czmqVersion ();
103
104 // Returns true if the process received a SIGINT or SIGTERM signal.
105 // It is good practice to use this method to exit any infinite loop
106 // processing messages.
107 bool interrupted ();
108
109 // Returns true if the underlying libzmq supports CURVE security.
110 bool hasCurve ();
111
112 // Return current host name, for use in public tcp:// endpoints.
113 // If the host name is not resolvable, returns NULL.
114 QString hostname ();
115
116 // Move the current process into the background. The precise effect
117 // depends on the operating system. On POSIX boxes, moves to a specified
118 // working directory (if specified), closes all file handles, reopens
119 // stdin, stdout, and stderr to the null device, and sets the process to
120 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
121 // was an error.
122 void daemonize (const QString &workdir);
123
124 // Drop the process ID into the lockfile, with exclusive lock, and
125 // switch the process to the specified group and/or user. Any of the
126 // arguments may be null, indicating a no-op. Returns 0 on success,
127 // -1 on failure. Note if you combine this with zsys_daemonize, run
128 // after, not before that method, or the lockfile will hold the wrong
129 // process ID.
130 void runAs (const QString &lockfile, const QString &group, const QString &user);
131
132 // Configure the number of I/O threads that ZeroMQ will use. A good
133 // rule of thumb is one thread per gigabit of traffic in or out. The
134 // default is 1, sufficient for most applications. If the environment
135 // variable ZSYS_IO_THREADS is defined, that provides the default.
136 // Note that this method is valid only before any socket is created.
137 void setIoThreads (size_t ioThreads);
138
139 // Configure the number of sockets that ZeroMQ will allow. The default
140 // is 1024. The actual limit depends on the system, and you can query it
141 // by using zsys_socket_limit (). A value of zero means "maximum".
142 // Note that this method is valid only before any socket is created.
143 void setMaxSockets (size_t maxSockets);
144
145 // Set network interface name to use for broadcasts, particularly zbeacon.
146 // This lets the interface be configured for test environments where required.
147 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
148 // the default when there is no specified interface. If the environment
149 // variable ZSYS_INTERFACE is set, use that as the default interface name.
150 // Setting the interface to "*" means "use all available interfaces".
151 void setBiface (const QString &value);
152
153 // Return network interface to use for broadcasts, or "" if none was set.
154 const QString biface ();
155
156 // Set log identity, which is a string that prefixes all log messages sent
157 // by this process. The log identity defaults to the environment variable
158 // ZSYS_LOGIDENT, if that is set.
159 void setLogIdent (const QString &value);
160
161 // Sends log output to a PUB socket bound to the specified endpoint. To
162 // collect such log output, create a SUB socket, subscribe to the traffic
163 // you care about, and connect to the endpoint. Log traffic is sent as a
164 // single string frame, in the same format as when sent to stdout. The
165 // log system supports a single sender; multiple calls to this method will
166 // bind the same sender to multiple endpoints. To disable the sender, call
167 // this method with a null argument.
168 void setLogSender (const QString &endpoint);
169
170 // Enable or disable logging to the system facility (syslog on POSIX boxes,
171 // event log on Windows). By default this is disabled.
172 void setLogSystem (bool logsystem);
173
174 // Log error condition - highest priority
175 void logError (const QString &format);
176
177 // Log warning condition - high priority
178 void logWarning (const QString &format);
179
180 // Log normal, but significant, condition - normal priority
181 void logNotice (const QString &format);
182
183 // Log informational message - low priority
184 void logInfo (const QString &format);
185
186 // Log debug-level message - lowest priority
187 void logDebug (const QString &format);
188
189108 // Self test of this class.
190109 void test (bool verbose);
191110
9292 };
9393
9494 ///
95 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
96 // Does not work if ZSYS_SIGHANDLER is false and code does not call
97 // set interrupted on signal.
98 bool QmlZsysAttached::isInterrupted () {
99 return zsys_is_interrupted ();
100 };
101
102 ///
103 // Set interrupted flag. This is done by default signal handler, however
104 // this can be handy for language bindings or cases without default
105 // signal handler.
106 void QmlZsysAttached::setInterrupted () {
107 zsys_set_interrupted ();
108 };
109
110 ///
95111 // Return 1 if file exists, else zero
96112 bool QmlZsysAttached::fileExists (const QString &filename) {
97113 return zsys_file_exists (filename.toUtf8().data());
313329 // Return maximum message size.
314330 int QmlZsysAttached::maxMsgsz () {
315331 return zsys_max_msgsz ();
332 };
333
334 ///
335 // Configure whether to use zero copy strategy in libzmq. If the environment
336 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
337 // Otherwise the default is 1.
338 void QmlZsysAttached::setZeroCopyRecv (int zeroCopy) {
339 zsys_set_zero_copy_recv (zeroCopy);
340 };
341
342 ///
343 // Return ZMQ_ZERO_COPY_RECV option.
344 int QmlZsysAttached::zeroCopyRecv () {
345 return zsys_zero_copy_recv ();
316346 };
317347
318348 ///
8888 // *** This is for CZMQ internal use only and may change arbitrarily ***
8989 void catchInterrupts ();
9090
91 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
92 // Does not work if ZSYS_SIGHANDLER is false and code does not call
93 // set interrupted on signal.
94 bool isInterrupted ();
95
96 // Set interrupted flag. This is done by default signal handler, however
97 // this can be handy for language bindings or cases without default
98 // signal handler.
99 void setInterrupted ();
100
91101 // Return 1 if file exists, else zero
92102 bool fileExists (const QString &filename);
93103
222232
223233 // Return maximum message size.
224234 int maxMsgsz ();
235
236 // Configure whether to use zero copy strategy in libzmq. If the environment
237 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
238 // Otherwise the default is 1.
239 void setZeroCopyRecv (int zeroCopy);
240
241 // Return ZMQ_ZERO_COPY_RECV option.
242 int zeroCopyRecv ();
225243
226244 // Configure the threshold value of filesystem object age per st_mtime
227245 // that should elapse until we consider that object "stable" at the
22 # Read the zproject/README.md for information about making permanent changes. #
33 ################################################################################
44 TEMPLATE = lib
5 VERSION = 4.1.0
5 VERSION = 4.1.1
66 CONFIG += qt dll qczmq-buildlib
77 mac:CONFIG += absolute_library_soname
88 win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all
3131 }
3232
3333 ///
34 // Return command line arguments (the first item is the executable) or
35 // NULL if not set.
36 QZlist * QZproc::args ()
37 {
38 QZlist *rv = new QZlist (zproc_args (self));
39 return rv;
40 }
41
42 ///
3443 // Setup the command line arguments, the first item must be an (absolute) filename
3544 // to run.
36 void QZproc::setArgs (QZlistx *args)
45 void QZproc::setArgs (QZlist *arguments)
3746 {
38 zproc_set_args (self, args->self);
47 zproc_set_args (self, &arguments->self);
3948
4049 }
4150
4251 ///
4352 // Setup the environment variables for the process.
44 void QZproc::setEnv (QZhashx *args)
53 void QZproc::setEnv (QZhash *arguments)
4554 {
46 zproc_set_env (self, args->self);
55 zproc_set_env (self, &arguments->self);
4756
4857 }
4958
105114 }
106115
107116 ///
108 // Starts the process.
117 // Starts the process, return just before execve/CreateProcess.
109118 int QZproc::run ()
110119 {
111120 int rv = zproc_run (self);
169178 }
170179
171180 ///
172 // Returns CZMQ version as a single 6-digit integer encoding the major
173 // version (x 10000), the minor version (x 100) and the patch.
174 int QZproc::czmqVersion ()
175 {
176 int rv = zproc_czmq_version ();
177 return rv;
178 }
179
180 ///
181 // Returns true if the process received a SIGINT or SIGTERM signal.
182 // It is good practice to use this method to exit any infinite loop
183 // processing messages.
184 bool QZproc::interrupted ()
185 {
186 bool rv = zproc_interrupted ();
187 return rv;
188 }
189
190 ///
191 // Returns true if the underlying libzmq supports CURVE security.
192 bool QZproc::hasCurve ()
193 {
194 bool rv = zproc_has_curve ();
195 return rv;
196 }
197
198 ///
199 // Return current host name, for use in public tcp:// endpoints.
200 // If the host name is not resolvable, returns NULL.
201 QString QZproc::hostname ()
202 {
203 char *retStr_ = zproc_hostname ();
204 QString rv = QString (retStr_);
205 zstr_free (&retStr_);
206 return rv;
207 }
208
209 ///
210 // Move the current process into the background. The precise effect
211 // depends on the operating system. On POSIX boxes, moves to a specified
212 // working directory (if specified), closes all file handles, reopens
213 // stdin, stdout, and stderr to the null device, and sets the process to
214 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
215 // was an error.
216 void QZproc::daemonize (const QString &workdir)
217 {
218 zproc_daemonize (workdir.toUtf8().data());
219
220 }
221
222 ///
223 // Drop the process ID into the lockfile, with exclusive lock, and
224 // switch the process to the specified group and/or user. Any of the
225 // arguments may be null, indicating a no-op. Returns 0 on success,
226 // -1 on failure. Note if you combine this with zsys_daemonize, run
227 // after, not before that method, or the lockfile will hold the wrong
228 // process ID.
229 void QZproc::runAs (const QString &lockfile, const QString &group, const QString &user)
230 {
231 zproc_run_as (lockfile.toUtf8().data(), group.toUtf8().data(), user.toUtf8().data());
232
233 }
234
235 ///
236 // Configure the number of I/O threads that ZeroMQ will use. A good
237 // rule of thumb is one thread per gigabit of traffic in or out. The
238 // default is 1, sufficient for most applications. If the environment
239 // variable ZSYS_IO_THREADS is defined, that provides the default.
240 // Note that this method is valid only before any socket is created.
241 void QZproc::setIoThreads (size_t ioThreads)
242 {
243 zproc_set_io_threads (ioThreads);
244
245 }
246
247 ///
248 // Configure the number of sockets that ZeroMQ will allow. The default
249 // is 1024. The actual limit depends on the system, and you can query it
250 // by using zsys_socket_limit (). A value of zero means "maximum".
251 // Note that this method is valid only before any socket is created.
252 void QZproc::setMaxSockets (size_t maxSockets)
253 {
254 zproc_set_max_sockets (maxSockets);
255
256 }
257
258 ///
259 // Set network interface name to use for broadcasts, particularly zbeacon.
260 // This lets the interface be configured for test environments where required.
261 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
262 // the default when there is no specified interface. If the environment
263 // variable ZSYS_INTERFACE is set, use that as the default interface name.
264 // Setting the interface to "*" means "use all available interfaces".
265 void QZproc::setBiface (const QString &value)
266 {
267 zproc_set_biface (value.toUtf8().data());
268
269 }
270
271 ///
272 // Return network interface to use for broadcasts, or "" if none was set.
273 const QString QZproc::biface ()
274 {
275 const QString rv = QString (zproc_biface ());
276 return rv;
277 }
278
279 ///
280 // Set log identity, which is a string that prefixes all log messages sent
281 // by this process. The log identity defaults to the environment variable
282 // ZSYS_LOGIDENT, if that is set.
283 void QZproc::setLogIdent (const QString &value)
284 {
285 zproc_set_log_ident (value.toUtf8().data());
286
287 }
288
289 ///
290 // Sends log output to a PUB socket bound to the specified endpoint. To
291 // collect such log output, create a SUB socket, subscribe to the traffic
292 // you care about, and connect to the endpoint. Log traffic is sent as a
293 // single string frame, in the same format as when sent to stdout. The
294 // log system supports a single sender; multiple calls to this method will
295 // bind the same sender to multiple endpoints. To disable the sender, call
296 // this method with a null argument.
297 void QZproc::setLogSender (const QString &endpoint)
298 {
299 zproc_set_log_sender (endpoint.toUtf8().data());
300
301 }
302
303 ///
304 // Enable or disable logging to the system facility (syslog on POSIX boxes,
305 // event log on Windows). By default this is disabled.
306 void QZproc::setLogSystem (bool logsystem)
307 {
308 zproc_set_log_system (logsystem);
309
310 }
311
312 ///
313 // Log error condition - highest priority
314 void QZproc::logError (const QString &param)
315 {
316 zproc_log_error ("%s", param.toUtf8().data());
317
318 }
319
320 ///
321 // Log warning condition - high priority
322 void QZproc::logWarning (const QString &param)
323 {
324 zproc_log_warning ("%s", param.toUtf8().data());
325
326 }
327
328 ///
329 // Log normal, but significant, condition - normal priority
330 void QZproc::logNotice (const QString &param)
331 {
332 zproc_log_notice ("%s", param.toUtf8().data());
333
334 }
335
336 ///
337 // Log informational message - low priority
338 void QZproc::logInfo (const QString &param)
339 {
340 zproc_log_info ("%s", param.toUtf8().data());
341
342 }
343
344 ///
345 // Log debug-level message - lowest priority
346 void QZproc::logDebug (const QString &param)
347 {
348 zproc_log_debug ("%s", param.toUtf8().data());
349
350 }
351
352 ///
353181 // Self test of this class.
354182 void QZproc::test (bool verbose)
355183 {
2424 // Destroy zproc, wait until process ends.
2525 ~QZproc ();
2626
27 // Return command line arguments (the first item is the executable) or
28 // NULL if not set.
29 QZlist * args ();
30
2731 // Setup the command line arguments, the first item must be an (absolute) filename
2832 // to run.
29 void setArgs (QZlistx *args);
33 void setArgs (QZlist *arguments);
3034
3135 // Setup the environment variables for the process.
32 void setEnv (QZhashx *args);
36 void setEnv (QZhash *arguments);
3337
3438 // Connects process stdin with a readable ('>', connect) zeromq socket. If
3539 // socket argument is NULL, zproc creates own managed pair of inproc
5862 // not initialized or external sockets.
5963 void * stderr ();
6064
61 // Starts the process.
65 // Starts the process, return just before execve/CreateProcess.
6266 int run ();
6367
6468 // process exit code
8286 // set verbose mode
8387 void setVerbose (bool verbose);
8488
85 // Returns CZMQ version as a single 6-digit integer encoding the major
86 // version (x 10000), the minor version (x 100) and the patch.
87 static int czmqVersion ();
88
89 // Returns true if the process received a SIGINT or SIGTERM signal.
90 // It is good practice to use this method to exit any infinite loop
91 // processing messages.
92 static bool interrupted ();
93
94 // Returns true if the underlying libzmq supports CURVE security.
95 static bool hasCurve ();
96
97 // Return current host name, for use in public tcp:// endpoints.
98 // If the host name is not resolvable, returns NULL.
99 static QString hostname ();
100
101 // Move the current process into the background. The precise effect
102 // depends on the operating system. On POSIX boxes, moves to a specified
103 // working directory (if specified), closes all file handles, reopens
104 // stdin, stdout, and stderr to the null device, and sets the process to
105 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
106 // was an error.
107 static void daemonize (const QString &workdir);
108
109 // Drop the process ID into the lockfile, with exclusive lock, and
110 // switch the process to the specified group and/or user. Any of the
111 // arguments may be null, indicating a no-op. Returns 0 on success,
112 // -1 on failure. Note if you combine this with zsys_daemonize, run
113 // after, not before that method, or the lockfile will hold the wrong
114 // process ID.
115 static void runAs (const QString &lockfile, const QString &group, const QString &user);
116
117 // Configure the number of I/O threads that ZeroMQ will use. A good
118 // rule of thumb is one thread per gigabit of traffic in or out. The
119 // default is 1, sufficient for most applications. If the environment
120 // variable ZSYS_IO_THREADS is defined, that provides the default.
121 // Note that this method is valid only before any socket is created.
122 static void setIoThreads (size_t ioThreads);
123
124 // Configure the number of sockets that ZeroMQ will allow. The default
125 // is 1024. The actual limit depends on the system, and you can query it
126 // by using zsys_socket_limit (). A value of zero means "maximum".
127 // Note that this method is valid only before any socket is created.
128 static void setMaxSockets (size_t maxSockets);
129
130 // Set network interface name to use for broadcasts, particularly zbeacon.
131 // This lets the interface be configured for test environments where required.
132 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
133 // the default when there is no specified interface. If the environment
134 // variable ZSYS_INTERFACE is set, use that as the default interface name.
135 // Setting the interface to "*" means "use all available interfaces".
136 static void setBiface (const QString &value);
137
138 // Return network interface to use for broadcasts, or "" if none was set.
139 static const QString biface ();
140
141 // Set log identity, which is a string that prefixes all log messages sent
142 // by this process. The log identity defaults to the environment variable
143 // ZSYS_LOGIDENT, if that is set.
144 static void setLogIdent (const QString &value);
145
146 // Sends log output to a PUB socket bound to the specified endpoint. To
147 // collect such log output, create a SUB socket, subscribe to the traffic
148 // you care about, and connect to the endpoint. Log traffic is sent as a
149 // single string frame, in the same format as when sent to stdout. The
150 // log system supports a single sender; multiple calls to this method will
151 // bind the same sender to multiple endpoints. To disable the sender, call
152 // this method with a null argument.
153 static void setLogSender (const QString &endpoint);
154
155 // Enable or disable logging to the system facility (syslog on POSIX boxes,
156 // event log on Windows). By default this is disabled.
157 static void setLogSystem (bool logsystem);
158
159 // Log error condition - highest priority
160 static void logError (const QString &param);
161
162 // Log warning condition - high priority
163 static void logWarning (const QString &param);
164
165 // Log normal, but significant, condition - normal priority
166 static void logNotice (const QString &param);
167
168 // Log informational message - low priority
169 static void logInfo (const QString &param);
170
171 // Log debug-level message - lowest priority
172 static void logDebug (const QString &param);
173
17489 // Self test of this class.
17590 static void test (bool verbose);
17691
109109 }
110110
111111 ///
112 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
113 // Does not work if ZSYS_SIGHANDLER is false and code does not call
114 // set interrupted on signal.
115 bool QZsys::isInterrupted ()
116 {
117 bool rv = zsys_is_interrupted ();
118 return rv;
119 }
120
121 ///
122 // Set interrupted flag. This is done by default signal handler, however
123 // this can be handy for language bindings or cases without default
124 // signal handler.
125 void QZsys::setInterrupted ()
126 {
127 zsys_set_interrupted ();
128
129 }
130
131 ///
112132 // Return 1 if file exists, else zero
113133 bool QZsys::fileExists (const QString &filename)
114134 {
358378 int QZsys::maxMsgsz ()
359379 {
360380 int rv = zsys_max_msgsz ();
381 return rv;
382 }
383
384 ///
385 // Configure whether to use zero copy strategy in libzmq. If the environment
386 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
387 // Otherwise the default is 1.
388 void QZsys::setZeroCopyRecv (int zeroCopy)
389 {
390 zsys_set_zero_copy_recv (zeroCopy);
391
392 }
393
394 ///
395 // Return ZMQ_ZERO_COPY_RECV option.
396 int QZsys::zeroCopyRecv ()
397 {
398 int rv = zsys_zero_copy_recv ();
361399 return rv;
362400 }
363401
6565 // *** This is for CZMQ internal use only and may change arbitrarily ***
6666 static void catchInterrupts ();
6767
68 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
69 // Does not work if ZSYS_SIGHANDLER is false and code does not call
70 // set interrupted on signal.
71 static bool isInterrupted ();
72
73 // Set interrupted flag. This is done by default signal handler, however
74 // this can be handy for language bindings or cases without default
75 // signal handler.
76 static void setInterrupted ();
77
6878 // Return 1 if file exists, else zero
6979 static bool fileExists (const QString &filename);
7080
187197
188198 // Return maximum message size.
189199 static int maxMsgsz ();
200
201 // Configure whether to use zero copy strategy in libzmq. If the environment
202 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
203 // Otherwise the default is 1.
204 static void setZeroCopyRecv (int zeroCopy);
205
206 // Return ZMQ_ZERO_COPY_RECV option.
207 static int zeroCopyRecv ();
190208
191209 // Configure the threshold value of filesystem object age per st_mtime
192210 // that should elapse until we consider that object "stable" at the
44
55 module CZMQ
66 module FFI
7 VERSION = '4.1.0'
7 VERSION = '4.1.1'
88 end
99 end
1010
9494 #
9595 # An example - to send $KTHXBAI string
9696 #
97 # if (zstr_send (self->pipe, "$KTHXBAI") == 0)
98 # zsock_wait (self->pipe);
97 # if (zstr_send (self, "$KTHXBAI") == 0)
98 # zsock_wait (self);
9999 # typedef void (zactor_destructor_fn) (
100100 # zactor_t *self);
101101 #
9191 result
9292 end
9393
94 # Return command line arguments (the first item is the executable) or
95 # NULL if not set.
96 #
97 # @return [Zlist]
98 def args()
99 raise DestroyedError unless @ptr
100 self_p = @ptr
101 result = ::CZMQ::FFI.zproc_args(self_p)
102 result = Zlist.__new result, true
103 result
104 end
105
94106 # Setup the command line arguments, the first item must be an (absolute) filename
95107 # to run.
96108 #
97 # @param args [Zlistx, #__ptr]
98 # @return [void]
99 def set_args(args)
100 raise DestroyedError unless @ptr
101 self_p = @ptr
102 args = args.__ptr if args
103 result = ::CZMQ::FFI.zproc_set_args(self_p, args)
109 # @param arguments [#__ptr_give_ref]
110 # @return [void]
111 def set_args(arguments)
112 raise DestroyedError unless @ptr
113 self_p = @ptr
114 arguments = arguments.__ptr_give_ref
115 result = ::CZMQ::FFI.zproc_set_args(self_p, arguments)
116 result
117 end
118
119 # Setup the command line arguments, the first item must be an (absolute) filename
120 # to run. Variadic function, must be NULL terminated.
121 #
122 # @param arguments [String, #to_s, nil]
123 # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
124 # @return [void]
125 def set_argsx(arguments, *args)
126 raise DestroyedError unless @ptr
127 self_p = @ptr
128 result = ::CZMQ::FFI.zproc_set_argsx(self_p, arguments, *args)
104129 result
105130 end
106131
107132 # Setup the environment variables for the process.
108133 #
109 # @param args [Zhashx, #__ptr]
110 # @return [void]
111 def set_env(args)
112 raise DestroyedError unless @ptr
113 self_p = @ptr
114 args = args.__ptr if args
115 result = ::CZMQ::FFI.zproc_set_env(self_p, args)
134 # @param arguments [#__ptr_give_ref]
135 # @return [void]
136 def set_env(arguments)
137 raise DestroyedError unless @ptr
138 self_p = @ptr
139 arguments = arguments.__ptr_give_ref
140 result = ::CZMQ::FFI.zproc_set_env(self_p, arguments)
116141 result
117142 end
118143
188213 result
189214 end
190215
191 # Starts the process.
216 # Starts the process, return just before execve/CreateProcess.
192217 #
193218 # @return [Integer]
194219 def run()
271296 self_p = @ptr
272297 verbose = !(0==verbose||!verbose) # boolean
273298 result = ::CZMQ::FFI.zproc_set_verbose(self_p, verbose)
274 result
275 end
276
277 # Returns CZMQ version as a single 6-digit integer encoding the major
278 # version (x 10000), the minor version (x 100) and the patch.
279 #
280 # @return [Integer]
281 def self.czmq_version()
282 result = ::CZMQ::FFI.zproc_czmq_version()
283 result
284 end
285
286 # Returns true if the process received a SIGINT or SIGTERM signal.
287 # It is good practice to use this method to exit any infinite loop
288 # processing messages.
289 #
290 # @return [Boolean]
291 def self.interrupted()
292 result = ::CZMQ::FFI.zproc_interrupted()
293 result
294 end
295
296 # Returns true if the underlying libzmq supports CURVE security.
297 #
298 # @return [Boolean]
299 def self.has_curve()
300 result = ::CZMQ::FFI.zproc_has_curve()
301 result
302 end
303
304 # Return current host name, for use in public tcp:// endpoints.
305 # If the host name is not resolvable, returns NULL.
306 #
307 # @return [::FFI::AutoPointer]
308 def self.hostname()
309 result = ::CZMQ::FFI.zproc_hostname()
310 result = ::FFI::AutoPointer.new(result, LibC.method(:free))
311 result
312 end
313
314 # Move the current process into the background. The precise effect
315 # depends on the operating system. On POSIX boxes, moves to a specified
316 # working directory (if specified), closes all file handles, reopens
317 # stdin, stdout, and stderr to the null device, and sets the process to
318 # ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
319 # was an error.
320 #
321 # @param workdir [String, #to_s, nil]
322 # @return [void]
323 def self.daemonize(workdir)
324 result = ::CZMQ::FFI.zproc_daemonize(workdir)
325 result
326 end
327
328 # Drop the process ID into the lockfile, with exclusive lock, and
329 # switch the process to the specified group and/or user. Any of the
330 # arguments may be null, indicating a no-op. Returns 0 on success,
331 # -1 on failure. Note if you combine this with zsys_daemonize, run
332 # after, not before that method, or the lockfile will hold the wrong
333 # process ID.
334 #
335 # @param lockfile [String, #to_s, nil]
336 # @param group [String, #to_s, nil]
337 # @param user [String, #to_s, nil]
338 # @return [void]
339 def self.run_as(lockfile, group, user)
340 result = ::CZMQ::FFI.zproc_run_as(lockfile, group, user)
341 result
342 end
343
344 # Configure the number of I/O threads that ZeroMQ will use. A good
345 # rule of thumb is one thread per gigabit of traffic in or out. The
346 # default is 1, sufficient for most applications. If the environment
347 # variable ZSYS_IO_THREADS is defined, that provides the default.
348 # Note that this method is valid only before any socket is created.
349 #
350 # @param io_threads [Integer, #to_int, #to_i]
351 # @return [void]
352 def self.set_io_threads(io_threads)
353 io_threads = Integer(io_threads)
354 result = ::CZMQ::FFI.zproc_set_io_threads(io_threads)
355 result
356 end
357
358 # Configure the number of sockets that ZeroMQ will allow. The default
359 # is 1024. The actual limit depends on the system, and you can query it
360 # by using zsys_socket_limit (). A value of zero means "maximum".
361 # Note that this method is valid only before any socket is created.
362 #
363 # @param max_sockets [Integer, #to_int, #to_i]
364 # @return [void]
365 def self.set_max_sockets(max_sockets)
366 max_sockets = Integer(max_sockets)
367 result = ::CZMQ::FFI.zproc_set_max_sockets(max_sockets)
368 result
369 end
370
371 # Set network interface name to use for broadcasts, particularly zbeacon.
372 # This lets the interface be configured for test environments where required.
373 # For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
374 # the default when there is no specified interface. If the environment
375 # variable ZSYS_INTERFACE is set, use that as the default interface name.
376 # Setting the interface to "*" means "use all available interfaces".
377 #
378 # @param value [String, #to_s, nil]
379 # @return [void]
380 def self.set_biface(value)
381 result = ::CZMQ::FFI.zproc_set_biface(value)
382 result
383 end
384
385 # Return network interface to use for broadcasts, or "" if none was set.
386 #
387 # @return [String]
388 def self.biface()
389 result = ::CZMQ::FFI.zproc_biface()
390 result
391 end
392
393 # Set log identity, which is a string that prefixes all log messages sent
394 # by this process. The log identity defaults to the environment variable
395 # ZSYS_LOGIDENT, if that is set.
396 #
397 # @param value [String, #to_s, nil]
398 # @return [void]
399 def self.set_log_ident(value)
400 result = ::CZMQ::FFI.zproc_set_log_ident(value)
401 result
402 end
403
404 # Sends log output to a PUB socket bound to the specified endpoint. To
405 # collect such log output, create a SUB socket, subscribe to the traffic
406 # you care about, and connect to the endpoint. Log traffic is sent as a
407 # single string frame, in the same format as when sent to stdout. The
408 # log system supports a single sender; multiple calls to this method will
409 # bind the same sender to multiple endpoints. To disable the sender, call
410 # this method with a null argument.
411 #
412 # @param endpoint [String, #to_s, nil]
413 # @return [void]
414 def self.set_log_sender(endpoint)
415 result = ::CZMQ::FFI.zproc_set_log_sender(endpoint)
416 result
417 end
418
419 # Enable or disable logging to the system facility (syslog on POSIX boxes,
420 # event log on Windows). By default this is disabled.
421 #
422 # @param logsystem [Boolean]
423 # @return [void]
424 def self.set_log_system(logsystem)
425 logsystem = !(0==logsystem||!logsystem) # boolean
426 result = ::CZMQ::FFI.zproc_set_log_system(logsystem)
427 result
428 end
429
430 # Log error condition - highest priority
431 #
432 # @param format [String, #to_s, nil]
433 # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
434 # @return [void]
435 def self.log_error(format, *args)
436 result = ::CZMQ::FFI.zproc_log_error(format, *args)
437 result
438 end
439
440 # Log warning condition - high priority
441 #
442 # @param format [String, #to_s, nil]
443 # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
444 # @return [void]
445 def self.log_warning(format, *args)
446 result = ::CZMQ::FFI.zproc_log_warning(format, *args)
447 result
448 end
449
450 # Log normal, but significant, condition - normal priority
451 #
452 # @param format [String, #to_s, nil]
453 # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
454 # @return [void]
455 def self.log_notice(format, *args)
456 result = ::CZMQ::FFI.zproc_log_notice(format, *args)
457 result
458 end
459
460 # Log informational message - low priority
461 #
462 # @param format [String, #to_s, nil]
463 # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
464 # @return [void]
465 def self.log_info(format, *args)
466 result = ::CZMQ::FFI.zproc_log_info(format, *args)
467 result
468 end
469
470 # Log debug-level message - lowest priority
471 #
472 # @param format [String, #to_s, nil]
473 # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
474 # @return [void]
475 def self.log_debug(format, *args)
476 result = ::CZMQ::FFI.zproc_log_debug(format, *args)
477299 result
478300 end
479301
196196 result
197197 end
198198
199 # Check if default interrupt handler of Ctrl-C or SIGTERM was called.
200 # Does not work if ZSYS_SIGHANDLER is false and code does not call
201 # set interrupted on signal.
202 #
203 # @return [Boolean]
204 def self.is_interrupted()
205 result = ::CZMQ::FFI.zsys_is_interrupted()
206 result
207 end
208
209 # Set interrupted flag. This is done by default signal handler, however
210 # this can be handy for language bindings or cases without default
211 # signal handler.
212 #
213 # @return [void]
214 def self.set_interrupted()
215 result = ::CZMQ::FFI.zsys_set_interrupted()
216 result
217 end
218
199219 # Return 1 if file exists, else zero
200220 #
201221 # @param filename [String, #to_s, nil]
522542 result
523543 end
524544
545 # Configure whether to use zero copy strategy in libzmq. If the environment
546 # variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
547 # Otherwise the default is 1.
548 #
549 # @param zero_copy [Integer, #to_int, #to_i]
550 # @return [void]
551 def self.set_zero_copy_recv(zero_copy)
552 zero_copy = Integer(zero_copy)
553 result = ::CZMQ::FFI.zsys_set_zero_copy_recv(zero_copy)
554 result
555 end
556
557 # Return ZMQ_ZERO_COPY_RECV option.
558 #
559 # @return [Integer]
560 def self.zero_copy_recv()
561 result = ::CZMQ::FFI.zsys_zero_copy_recv()
562 result
563 end
564
525565 # Configure the threshold value of filesystem object age per st_mtime
526566 # that should elapse until we consider that object "stable" at the
527567 # current zclock_time() moment.
515515
516516 attach_function :zproc_new, [], :pointer, **opts
517517 attach_function :zproc_destroy, [:pointer], :void, **opts
518 attach_function :zproc_args, [:pointer], :pointer, **opts
518519 attach_function :zproc_set_args, [:pointer, :pointer], :void, **opts
520 attach_function :zproc_set_argsx, [:pointer, :string, :varargs], :void, **opts
519521 attach_function :zproc_set_env, [:pointer, :pointer], :void, **opts
520522 attach_function :zproc_set_stdin, [:pointer, :pointer], :void, **opts
521523 attach_function :zproc_set_stdout, [:pointer, :pointer], :void, **opts
531533 attach_function :zproc_actor, [:pointer], :pointer, **opts
532534 attach_function :zproc_kill, [:pointer, :int], :void, **opts
533535 attach_function :zproc_set_verbose, [:pointer, :bool], :void, **opts
534 attach_function :zproc_czmq_version, [], :int, **opts
535 attach_function :zproc_interrupted, [], :bool, **opts
536 attach_function :zproc_has_curve, [], :bool, **opts
537 attach_function :zproc_hostname, [], :pointer, **opts
538 attach_function :zproc_daemonize, [:string], :void, **opts
539 attach_function :zproc_run_as, [:string, :string, :string], :void, **opts
540 attach_function :zproc_set_io_threads, [:size_t], :void, **opts
541 attach_function :zproc_set_max_sockets, [:size_t], :void, **opts
542 attach_function :zproc_set_biface, [:string], :void, **opts
543 attach_function :zproc_biface, [], :string, **opts
544 attach_function :zproc_set_log_ident, [:string], :void, **opts
545 attach_function :zproc_set_log_sender, [:string], :void, **opts
546 attach_function :zproc_set_log_system, [:bool], :void, **opts
547 attach_function :zproc_log_error, [:string, :varargs], :void, **opts
548 attach_function :zproc_log_warning, [:string, :varargs], :void, **opts
549 attach_function :zproc_log_notice, [:string, :varargs], :void, **opts
550 attach_function :zproc_log_info, [:string, :varargs], :void, **opts
551 attach_function :zproc_log_debug, [:string, :varargs], :void, **opts
552536 attach_function :zproc_test, [:bool], :void, **opts
553537
554538 require_relative 'ffi/zproc'
763747 attach_function :zsys_handler_set, [:pointer], :void, **opts
764748 attach_function :zsys_handler_reset, [], :void, **opts
765749 attach_function :zsys_catch_interrupts, [], :void, **opts
750 attach_function :zsys_is_interrupted, [], :bool, **opts
751 attach_function :zsys_set_interrupted, [], :void, **opts
766752 attach_function :zsys_file_exists, [:string], :bool, **opts
767753 attach_function :zsys_file_modified, [:string], :pointer, **opts
768754 attach_function :zsys_file_mode, [:string], :int, **opts
792778 attach_function :zsys_socket_limit, [], :size_t, **opts
793779 attach_function :zsys_set_max_msgsz, [:int], :void, **opts
794780 attach_function :zsys_max_msgsz, [], :int, **opts
781 attach_function :zsys_set_zero_copy_recv, [:int], :void, **opts
782 attach_function :zsys_zero_copy_recv, [], :int, **opts
795783 attach_function :zsys_set_file_stable_age_msec, [:pointer], :void, **opts
796784 attach_function :zsys_file_stable_age_msec, [], :pointer, **opts
797785 attach_function :zsys_set_linger, [:size_t], :void, **opts
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for czmq 4.1.0.
2 # Generated by GNU Autoconf 2.69 for czmq 4.1.1.
33 #
44 # Report bugs to <zeromq-dev@lists.zeromq.org>.
55 #
589589 # Identity of this package.
590590 PACKAGE_NAME='czmq'
591591 PACKAGE_TARNAME='czmq'
592 PACKAGE_VERSION='4.1.0'
593 PACKAGE_STRING='czmq 4.1.0'
592 PACKAGE_VERSION='4.1.1'
593 PACKAGE_STRING='czmq 4.1.1'
594594 PACKAGE_BUGREPORT='zeromq-dev@lists.zeromq.org'
595595 PACKAGE_URL=''
596596
684684 libzmq_LIBS
685685 libzmq_CFLAGS
686686 pkgconfigdir
687 WITH_CLANG_FORMAT_FALSE
688 WITH_CLANG_FORMAT_TRUE
689 WITH_CLANG_FORMAT
690 CLANG_FORMAT
687691 ENABLE_ASAN_FALSE
688692 ENABLE_ASAN_TRUE
689693 WITH_GCOV_FALSE
690694 WITH_GCOV_TRUE
695 WITH_CPPCHECK_FALSE
696 WITH_CPPCHECK_TRUE
697 WITH_CPPCHECK
691698 PKG_CONFIG_LIBDIR
692699 PKG_CONFIG_PATH
693700 PKG_CONFIG
13951402 # Omit some internal or obsolete options to make the list less imposing.
13961403 # This message is too long to be a string in the A/UX 3.1 sh.
13971404 cat <<_ACEOF
1398 \`configure' configures czmq 4.1.0 to adapt to many kinds of systems.
1405 \`configure' configures czmq 4.1.1 to adapt to many kinds of systems.
13991406
14001407 Usage: $0 [OPTION]... [VAR=VALUE]...
14011408
14651472
14661473 if test -n "$ac_init_help"; then
14671474 case $ac_init_help in
1468 short | recursive ) echo "Configuration of czmq 4.1.0:";;
1475 short | recursive ) echo "Configuration of czmq 4.1.1:";;
14691476 esac
14701477 cat <<\_ACEOF
14711478
16271634 test -n "$ac_init_help" && exit $ac_status
16281635 if $ac_init_version; then
16291636 cat <<\_ACEOF
1630 czmq configure 4.1.0
1637 czmq configure 4.1.1
16311638 generated by GNU Autoconf 2.69
16321639
16331640 Copyright (C) 2012 Free Software Foundation, Inc.
21042111 This file contains any messages produced by compilers while
21052112 running configure, to aid debugging if configure makes a mistake.
21062113
2107 It was created by czmq $as_me 4.1.0, which was
2114 It was created by czmq $as_me 4.1.1, which was
21082115 generated by GNU Autoconf 2.69. Invocation command line was
21092116
21102117 $ $0 $@
29712978
29722979 # Define the identity of the package.
29732980 PACKAGE='czmq'
2974 VERSION='4.1.0'
2981 VERSION='4.1.1'
29752982
29762983
29772984 cat >>confdefs.h <<_ACEOF
32443251 #
32453252 # Libtool -version-info (ABI version)
32463253 #
3247 # Currently 5:0:1 ("stable"). Don't change this unless you
3254 # Currently 5:1:1 ("stable"). Don't change this unless you
32483255 # know exactly what you're doing and have read and understand
32493256 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
32503257 #
32513258 # libczmq -version-info
3252 LTVER="5:0:1"
3259 LTVER="5:1:1"
32533260
32543261
32553262 # building in a subdirectory?
1289312900
1289412901
1289512902
12903 # See if cppcheck is in PATH; this variable unblocks the "cppcheck" recipe
12904 # (note that "make cppcheck.xml" can be used - and perhaps fail - regardless)
12905 # Extract the first word of "cppcheck", so it can be a program name with args.
12906 set dummy cppcheck; ac_word=$2
12907 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
12908 $as_echo_n "checking for $ac_word... " >&6; }
12909 if ${ac_cv_prog_WITH_CPPCHECK+:} false; then :
12910 $as_echo_n "(cached) " >&6
12911 else
12912 if test -n "$WITH_CPPCHECK"; then
12913 ac_cv_prog_WITH_CPPCHECK="$WITH_CPPCHECK" # Let the user override the test.
12914 else
12915 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
12916 for as_dir in $PATH
12917 do
12918 IFS=$as_save_IFS
12919 test -z "$as_dir" && as_dir=.
12920 for ac_exec_ext in '' $ac_executable_extensions; do
12921 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
12922 ac_cv_prog_WITH_CPPCHECK="true"
12923 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
12924 break 2
12925 fi
12926 done
12927 done
12928 IFS=$as_save_IFS
12929
12930 test -z "$ac_cv_prog_WITH_CPPCHECK" && ac_cv_prog_WITH_CPPCHECK="false"
12931 fi
12932 fi
12933 WITH_CPPCHECK=$ac_cv_prog_WITH_CPPCHECK
12934 if test -n "$WITH_CPPCHECK"; then
12935 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_CPPCHECK" >&5
12936 $as_echo "$WITH_CPPCHECK" >&6; }
12937 else
12938 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12939 $as_echo "no" >&6; }
12940 fi
12941
12942
12943 if $WITH_CPPCHECK; then
12944 WITH_CPPCHECK_TRUE=
12945 WITH_CPPCHECK_FALSE='#'
12946 else
12947 WITH_CPPCHECK_TRUE='#'
12948 WITH_CPPCHECK_FALSE=
12949 fi
12950
12951
1289612952 # Code coverage
1289712953 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable GCov" >&5
1289812954 $as_echo_n "checking whether to enable GCov... " >&6; }
1296813024 $as_echo "no" >&6; }
1296913025 fi
1297013026
13027 # See if clang-format is in PATH; the result unblocks the relevant recipes
13028 WITH_CLANG_FORMAT=""
13029 if test x"$CLANG_FORMAT" = x; then :
13030 # Extract the first word of "clang-format", so it can be a program name with args.
13031 set dummy clang-format; ac_word=$2
13032 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
13033 $as_echo_n "checking for $ac_word... " >&6; }
13034 if ${ac_cv_path_CLANG_FORMAT+:} false; then :
13035 $as_echo_n "(cached) " >&6
13036 else
13037 case $CLANG_FORMAT in
13038 [\\/]* | ?:[\\/]*)
13039 ac_cv_path_CLANG_FORMAT="$CLANG_FORMAT" # Let the user override the test with a path.
13040 ;;
13041 *)
13042 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
13043 for as_dir in $PATH
13044 do
13045 IFS=$as_save_IFS
13046 test -z "$as_dir" && as_dir=.
13047 for ac_exec_ext in '' $ac_executable_extensions; do
13048 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
13049 ac_cv_path_CLANG_FORMAT="$as_dir/$ac_word$ac_exec_ext"
13050 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
13051 break 2
13052 fi
13053 done
13054 done
13055 IFS=$as_save_IFS
13056
13057 ;;
13058 esac
13059 fi
13060 CLANG_FORMAT=$ac_cv_path_CLANG_FORMAT
13061 if test -n "$CLANG_FORMAT"; then
13062 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG_FORMAT" >&5
13063 $as_echo "$CLANG_FORMAT" >&6; }
13064 else
13065 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13066 $as_echo "no" >&6; }
13067 fi
13068
13069
13070 else
13071 # Extract the first word of "$CLANG_FORMAT", so it can be a program name with args.
13072 set dummy $CLANG_FORMAT; ac_word=$2
13073 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
13074 $as_echo_n "checking for $ac_word... " >&6; }
13075 if ${ac_cv_prog_WITH_CLANG_FORMAT+:} false; then :
13076 $as_echo_n "(cached) " >&6
13077 else
13078 if test -n "$WITH_CLANG_FORMAT"; then
13079 ac_cv_prog_WITH_CLANG_FORMAT="$WITH_CLANG_FORMAT" # Let the user override the test.
13080 else
13081 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
13082 for as_dir in $PATH
13083 do
13084 IFS=$as_save_IFS
13085 test -z "$as_dir" && as_dir=.
13086 for ac_exec_ext in '' $ac_executable_extensions; do
13087 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
13088 ac_cv_prog_WITH_CLANG_FORMAT="true"
13089 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
13090 break 2
13091 fi
13092 done
13093 done
13094 IFS=$as_save_IFS
13095
13096 test -z "$ac_cv_prog_WITH_CLANG_FORMAT" && ac_cv_prog_WITH_CLANG_FORMAT="fail"
13097 fi
13098 fi
13099 WITH_CLANG_FORMAT=$ac_cv_prog_WITH_CLANG_FORMAT
13100 if test -n "$WITH_CLANG_FORMAT"; then
13101 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_CLANG_FORMAT" >&5
13102 $as_echo "$WITH_CLANG_FORMAT" >&6; }
13103 else
13104 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13105 $as_echo "no" >&6; }
13106 fi
13107
13108
13109 fi
13110 if test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x; then :
13111 if test -x "$CLANG_FORMAT"; then :
13112 WITH_CLANG_FORMAT=true
13113 else
13114 # Extract the first word of "$CLANG_FORMAT", so it can be a program name with args.
13115 set dummy $CLANG_FORMAT; ac_word=$2
13116 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
13117 $as_echo_n "checking for $ac_word... " >&6; }
13118 if ${ac_cv_prog_WITH_CLANG_FORMAT+:} false; then :
13119 $as_echo_n "(cached) " >&6
13120 else
13121 if test -n "$WITH_CLANG_FORMAT"; then
13122 ac_cv_prog_WITH_CLANG_FORMAT="$WITH_CLANG_FORMAT" # Let the user override the test.
13123 else
13124 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
13125 for as_dir in $PATH
13126 do
13127 IFS=$as_save_IFS
13128 test -z "$as_dir" && as_dir=.
13129 for ac_exec_ext in '' $ac_executable_extensions; do
13130 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
13131 ac_cv_prog_WITH_CLANG_FORMAT="true"
13132 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
13133 break 2
13134 fi
13135 done
13136 done
13137 IFS=$as_save_IFS
13138
13139 test -z "$ac_cv_prog_WITH_CLANG_FORMAT" && ac_cv_prog_WITH_CLANG_FORMAT="false"
13140 fi
13141 fi
13142 WITH_CLANG_FORMAT=$ac_cv_prog_WITH_CLANG_FORMAT
13143 if test -n "$WITH_CLANG_FORMAT"; then
13144 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_CLANG_FORMAT" >&5
13145 $as_echo "$WITH_CLANG_FORMAT" >&6; }
13146 else
13147 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13148 $as_echo "no" >&6; }
13149 fi
13150
13151
13152 fi
13153 fi
13154 if test "$WITH_CLANG_FORMAT" = fail; then :
13155 as_fn_error $? "Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found" "$LINENO" 5
13156 fi
13157 if $WITH_CLANG_FORMAT; then
13158 WITH_CLANG_FORMAT_TRUE=
13159 WITH_CLANG_FORMAT_FALSE='#'
13160 else
13161 WITH_CLANG_FORMAT_TRUE='#'
13162 WITH_CLANG_FORMAT_FALSE=
13163 fi
13164
13165
1297113166 # Set pkgconfigdir
1297213167
1297313168 # Check whether --with-pkgconfigdir was given.
1300713202 # Check whether --with-libzmq was given.
1300813203 if test "${with_libzmq+set}" = set; then :
1300913204 withval=$with_libzmq;
13205 search_libzmq="yes"
13206
13207 else
13208
1301013209 search_libzmq="yes"
1301113210
1301213211 fi
1329713496 withval=$with_uuid;
1329813497 search_uuid="yes"
1329913498
13499 else
13500
13501 search_uuid="yes"
13502
1330013503 fi
1330113504
1330213505 case x"${with_uuid}" in #(
1359113794 withval=$with_libsystemd;
1359213795 search_libsystemd="yes"
1359313796
13797 else
13798
13799 search_libsystemd="yes"
13800
1359413801 fi
1359513802
1359613803 case x"${with_libsystemd}" in #(
1388314090 # Check whether --with-liblz4 was given.
1388414091 if test "${with_liblz4+set}" = set; then :
1388514092 withval=$with_liblz4;
14093 search_liblz4="yes"
14094
14095 else
14096
1388614097 search_liblz4="yes"
1388714098
1388814099 fi
1553315744 fi
1553415745
1553515746 # Specify output files
15536 ac_config_files="$ac_config_files Makefile doc/Makefile src/libczmq.pc"
15747 ac_config_files="$ac_config_files Makefile doc/Makefile include/Makefile src/libczmq.pc"
1553715748
1553815749
1553915750
1567515886 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1567615887 fi
1567715888
15889 if test -z "${WITH_CPPCHECK_TRUE}" && test -z "${WITH_CPPCHECK_FALSE}"; then
15890 as_fn_error $? "conditional \"WITH_CPPCHECK\" was never defined.
15891 Usually this means the macro was only invoked conditionally." "$LINENO" 5
15892 fi
1567815893 if test -z "${WITH_GCOV_TRUE}" && test -z "${WITH_GCOV_FALSE}"; then
1567915894 as_fn_error $? "conditional \"WITH_GCOV\" was never defined.
1568015895 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1568915904 fi
1569015905 if test -z "${ENABLE_ASAN_TRUE}" && test -z "${ENABLE_ASAN_FALSE}"; then
1569115906 as_fn_error $? "conditional \"ENABLE_ASAN\" was never defined.
15907 Usually this means the macro was only invoked conditionally." "$LINENO" 5
15908 fi
15909 if test -z "${WITH_CLANG_FORMAT_TRUE}" && test -z "${WITH_CLANG_FORMAT_FALSE}"; then
15910 as_fn_error $? "conditional \"WITH_CLANG_FORMAT\" was never defined.
1569215911 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1569315912 fi
1569415913
1614516364 # report actual input values of CONFIG_FILES etc. instead of their
1614616365 # values after options handling.
1614716366 ac_log="
16148 This file was extended by czmq $as_me 4.1.0, which was
16367 This file was extended by czmq $as_me 4.1.1, which was
1614916368 generated by GNU Autoconf 2.69. Invocation command line was
1615016369
1615116370 CONFIG_FILES = $CONFIG_FILES
1621116430 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1621216431 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1621316432 ac_cs_version="\\
16214 czmq config.status 4.1.0
16433 czmq config.status 4.1.1
1621516434 configured by $0, generated by GNU Autoconf 2.69,
1621616435 with options \\"\$ac_cs_config\\"
1621716436
1662416843 "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
1662516844 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
1662616845 "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
16846 "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
1662716847 "src/libczmq.pc") CONFIG_FILES="$CONFIG_FILES src/libczmq.pc" ;;
1662816848
1662916849 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
1807218292 echo " check for memory leaks"
1807318293 echo " - 'make coverage' generate project's selftest coverage report"
1807418294 echo " expects --with-gcov option for configure"
18295 echo " - 'make clang-format-check' check if project sources conform"
18296 echo " to style requirements"
18297 echo " - 'make clang-format' modify project sources to conform"
18298 echo " to style requirements"
18299 echo " - 'make clang-format-diff' modify as above and print 'git diff'"
1807518300 echo
1807618301
1807718302 ################################################################################
66 # Process this file with autoconf to produce a configure script.
77 AC_PREREQ(2.61)
88 #
9 AC_INIT([czmq],[4.1.0],[zeromq-dev@lists.zeromq.org])
9 AC_INIT([czmq],[4.1.1],[zeromq-dev@lists.zeromq.org])
1010
1111 AC_CONFIG_AUX_DIR(config)
1212 AC_CONFIG_MACRO_DIR(config)
3030 #
3131 # Libtool -version-info (ABI version)
3232 #
33 # Currently 5:0:1 ("stable"). Don't change this unless you
33 # Currently 5:1:1 ("stable"). Don't change this unless you
3434 # know exactly what you're doing and have read and understand
3535 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
3636 #
3737 # libczmq -version-info
38 LTVER="5:0:1"
38 LTVER="5:1:1"
3939 AC_SUBST(LTVER)
4040
4141 # building in a subdirectory?
6060 # Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) )
6161 AX_PROJECT_LOCAL_HOOK
6262
63 # See if cppcheck is in PATH; this variable unblocks the "cppcheck" recipe
64 # (note that "make cppcheck.xml" can be used - and perhaps fail - regardless)
65 AC_CHECK_PROG([WITH_CPPCHECK], [cppcheck], [true], [false])
66 AM_CONDITIONAL(WITH_CPPCHECK, $WITH_CPPCHECK)
67
6368 # Code coverage
6469 AC_MSG_CHECKING([whether to enable GCov])
6570 AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no],
96101 AC_MSG_RESULT([no])
97102 fi
98103
104 # See if clang-format is in PATH; the result unblocks the relevant recipes
105 WITH_CLANG_FORMAT=""
106 AS_IF([test x"$CLANG_FORMAT" = x],
107 [AC_PATH_PROG([CLANG_FORMAT], [clang-format], [])],
108 [AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [fail])])
109 AS_IF([test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x],
110 [AS_IF([test -x "$CLANG_FORMAT"],
111 [WITH_CLANG_FORMAT=true],
112 [AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [false])])])
113 AS_IF([test "$WITH_CLANG_FORMAT" = fail],
114 [AC_MSG_ERROR([Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found])])
115 AM_CONDITIONAL([WITH_CLANG_FORMAT], [$WITH_CLANG_FORMAT])
116
99117 # Set pkgconfigdir
100118 AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
101119 [Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
131149 [
132150 search_libzmq="yes"
133151 ],
134 [])
152 [
153 search_libzmq="yes"
154 ])
135155 AS_CASE([x"${with_libzmq}"],
136156 [xyes], [search_libzmq="yes"],
137157 [xno], [search_libzmq="no"])
218238 [
219239 search_uuid="yes"
220240 ],
221 [])
241 [
242 search_uuid="yes"
243 ])
222244 AS_CASE([x"${with_uuid}"],
223245 [xyes], [search_uuid="yes"],
224246 [xno], [search_uuid="no"])
303325 [
304326 search_libsystemd="yes"
305327 ],
306 [])
328 [
329 search_libsystemd="yes"
330 ])
307331 AS_CASE([x"${with_libsystemd}"],
308332 [xyes], [search_libsystemd="yes"],
309333 [xno], [search_libsystemd="no"])
388412 [
389413 search_liblz4="yes"
390414 ],
391 [])
415 [
416 search_liblz4="yes"
417 ])
392418 AS_CASE([x"${with_liblz4}"],
393419 [xyes], [search_liblz4="yes"],
394420 [xno], [search_liblz4="no"])
768794 # Specify output files
769795 AC_CONFIG_FILES([Makefile
770796 doc/Makefile
797 include/Makefile
771798 src/libczmq.pc
772799 ])
773800
844871 echo " check for memory leaks"
845872 echo " - 'make coverage' generate project's selftest coverage report"
846873 echo " expects --with-gcov option for configure"
874 echo " - 'make clang-format-check' check if project sources conform"
875 echo " to style requirements"
876 echo " - 'make clang-format' modify project sources to conform"
877 echo " to style requirements"
878 echo " - 'make clang-format-diff' modify as above and print 'git diff'"
847879 echo
848880 ])
849881
4141 asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
4242 -aczmq_version=@PACKAGE_VERSION@ -o$@ $<
4343 .xml.1:
44 xmlto man $<
44 xmlto -o $(@D) man $<
4545 .xml.3:
46 xmlto man $<
46 xmlto -o $(@D) man $<
4747
4848 # Special handling for project overview whose basename may collide
4949 # with a main or class name
5151 asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
5252 -aczmq_version=@PACKAGE_VERSION@ -o$@ $<
5353 .xml7.7:
54 xmlto man $<
54 xmlto -o $(@D) man $<
5555
5656 # List of *.txt and *.doc files generated during build from comments
5757 # in project program source files and further processed into manpages.
199199 zrex.txt: $(top_srcdir)/src/zrex.c
200200 "$(srcdir)/mkman" "zrex" "$(builddir)/zrex.txt" "$(srcdir)/.."
201201
202 ### Note: for mains, we keep the source name rather than flattened name:c
203 ### so that the manpages for binary programs match their name, at expense
204 ### of perhaps being built in a subdirectory under doc/.
202205 GENERATED_DOCS += zmakecert.txt zmakecert.doc
203206 zmakecert.txt: $(top_srcdir)/src/zmakecert.c
207 mkdir -p "$(builddir)/$(@D)"
204208 "$(srcdir)/mkman" "zmakecert" "$(builddir)/zmakecert.txt" "$(srcdir)/.."
205209
206210
165165 CC = @CC@
166166 CCDEPMODE = @CCDEPMODE@
167167 CFLAGS = @CFLAGS@
168 CLANG_FORMAT = @CLANG_FORMAT@
168169 CPP = @CPP@
169170 CPPFLAGS = @CPPFLAGS@
170171 CYGPATH_W = @CYGPATH_W@
220221 SHELL = @SHELL@
221222 STRIP = @STRIP@
222223 VERSION = @VERSION@
224 WITH_CLANG_FORMAT = @WITH_CLANG_FORMAT@
225 WITH_CPPCHECK = @WITH_CPPCHECK@
223226 abs_builddir = @abs_builddir@
224227 abs_srcdir = @abs_srcdir@
225228 abs_top_builddir = @abs_top_builddir@
313316
314317 # List of *.txt and *.doc files generated during build from comments
315318 # in project program source files and further processed into manpages.
319
320 ### Note: for mains, we keep the source name rather than flattened name:c
321 ### so that the manpages for binary programs match their name, at expense
322 ### of perhaps being built in a subdirectory under doc/.
316323 @BUILD_DOC_TRUE@GENERATED_DOCS = zactor.txt zactor.doc zargs.txt \
317324 @BUILD_DOC_TRUE@ zargs.doc zarmour.txt zarmour.doc zcert.txt \
318325 @BUILD_DOC_TRUE@ zcert.doc zcertstore.txt zcertstore.doc \
680687 @BUILD_DOC_TRUE@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
681688 @BUILD_DOC_TRUE@ -aczmq_version=@PACKAGE_VERSION@ -o$@ $<
682689 @BUILD_DOC_TRUE@.xml.1:
683 @BUILD_DOC_TRUE@ xmlto man $<
690 @BUILD_DOC_TRUE@ xmlto -o $(@D) man $<
684691 @BUILD_DOC_TRUE@.xml.3:
685 @BUILD_DOC_TRUE@ xmlto man $<
692 @BUILD_DOC_TRUE@ xmlto -o $(@D) man $<
686693
687694 # Special handling for project overview whose basename may collide
688695 # with a main or class name
690697 @BUILD_DOC_TRUE@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
691698 @BUILD_DOC_TRUE@ -aczmq_version=@PACKAGE_VERSION@ -o$@ $<
692699 @BUILD_DOC_TRUE@.xml7.7:
693 @BUILD_DOC_TRUE@ xmlto man $<
700 @BUILD_DOC_TRUE@ xmlto -o $(@D) man $<
694701
695702 # No-op, docs and texts are generated by mkman in one shot - just
696703 # make a dependency that can not parallelize and break stuff.
766773 @BUILD_DOC_TRUE@zrex.txt: $(top_srcdir)/src/zrex.c
767774 @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zrex" "$(builddir)/zrex.txt" "$(srcdir)/.."
768775 @BUILD_DOC_TRUE@zmakecert.txt: $(top_srcdir)/src/zmakecert.c
776 @BUILD_DOC_TRUE@ mkdir -p "$(builddir)/$(@D)"
769777 @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zmakecert" "$(builddir)/zmakecert.txt" "$(srcdir)/.."
770778
771779 @BUILD_DOC_TRUE@clean-local:
9292 $cat_text = "Program for ";
9393 last;
9494 }
95 elsif (/MAN3.*$name\.3/) {
95 elsif (/MAN3.*$outp_basename\.3/) {
9696 $source = "$rootsrcdir/src/$name.c";
9797 $header = "$rootsrcdir/include/$name.h";
9898 $cat = 3;
0 ################################################################################
1 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
2 # Read the zproject/README.md for information about making permanent changes. #
3 ################################################################################
4 include_HEADERS = \
5 czmq_prelude.h \
6 czmq.h \
7 zactor.h \
8 zarmour.h \
9 zcert.h \
10 zcertstore.h \
11 zchunk.h \
12 zclock.h \
13 zconfig.h \
14 zdigest.h \
15 zdir.h \
16 zdir_patch.h \
17 zfile.h \
18 zframe.h \
19 zhash.h \
20 zhashx.h \
21 ziflist.h \
22 zlist.h \
23 zlistx.h \
24 zloop.h \
25 zmsg.h \
26 zpoller.h \
27 zsock.h \
28 zstr.h \
29 zsys.h \
30 zuuid.h \
31 zauth.h \
32 zbeacon.h \
33 zgossip.h \
34 zmonitor.h \
35 zproxy.h \
36 zrex.h \
37 czmq_library.h
38
39 if ENABLE_DRAFTS
40 include_HEADERS += \
41 zargs.h \
42 zproc.h \
43 ztimerset.h \
44 ztrie.h
45
46 endif
47
48
49 ################################################################################
50 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
51 # Read the zproject/README.md for information about making permanent changes. #
52 ################################################################################
0 # Makefile.in generated by automake 1.14.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18 am__make_running_with_option = \
19 case $${target_option-} in \
20 ?) ;; \
21 *) echo "am__make_running_with_option: internal error: invalid" \
22 "target option '$${target_option-}' specified" >&2; \
23 exit 1;; \
24 esac; \
25 has_opt=no; \
26 sane_makeflags=$$MAKEFLAGS; \
27 if $(am__is_gnu_make); then \
28 sane_makeflags=$$MFLAGS; \
29 else \
30 case $$MAKEFLAGS in \
31 *\\[\ \ ]*) \
32 bs=\\; \
33 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
34 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
35 esac; \
36 fi; \
37 skip_next=no; \
38 strip_trailopt () \
39 { \
40 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
41 }; \
42 for flg in $$sane_makeflags; do \
43 test $$skip_next = yes && { skip_next=no; continue; }; \
44 case $$flg in \
45 *=*|--*) continue;; \
46 -*I) strip_trailopt 'I'; skip_next=yes;; \
47 -*I?*) strip_trailopt 'I';; \
48 -*O) strip_trailopt 'O'; skip_next=yes;; \
49 -*O?*) strip_trailopt 'O';; \
50 -*l) strip_trailopt 'l'; skip_next=yes;; \
51 -*l?*) strip_trailopt 'l';; \
52 -[dEDm]) skip_next=yes;; \
53 -[JT]) skip_next=yes;; \
54 esac; \
55 case $$flg in \
56 *$$target_option*) has_opt=yes; break;; \
57 esac; \
58 done; \
59 test $$has_opt = yes
60 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
61 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
62 pkgdatadir = $(datadir)/@PACKAGE@
63 pkgincludedir = $(includedir)/@PACKAGE@
64 pkglibdir = $(libdir)/@PACKAGE@
65 pkglibexecdir = $(libexecdir)/@PACKAGE@
66 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
67 install_sh_DATA = $(install_sh) -c -m 644
68 install_sh_PROGRAM = $(install_sh) -c
69 install_sh_SCRIPT = $(install_sh) -c
70 INSTALL_HEADER = $(INSTALL_DATA)
71 transform = $(program_transform_name)
72 NORMAL_INSTALL = :
73 PRE_INSTALL = :
74 POST_INSTALL = :
75 NORMAL_UNINSTALL = :
76 PRE_UNINSTALL = :
77 POST_UNINSTALL = :
78 build_triplet = @build@
79 host_triplet = @host@
80 @ENABLE_DRAFTS_TRUE@am__append_1 = \
81 @ENABLE_DRAFTS_TRUE@ zargs.h \
82 @ENABLE_DRAFTS_TRUE@ zproc.h \
83 @ENABLE_DRAFTS_TRUE@ ztimerset.h \
84 @ENABLE_DRAFTS_TRUE@ ztrie.h
85
86 subdir = include
87 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
88 $(am__include_HEADERS_DIST)
89 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
90 am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \
91 $(top_srcdir)/config/ltoptions.m4 \
92 $(top_srcdir)/config/ltsugar.m4 \
93 $(top_srcdir)/config/ltversion.m4 \
94 $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
95 $(top_srcdir)/configure.ac
96 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
97 $(ACLOCAL_M4)
98 mkinstalldirs = $(install_sh) -d
99 CONFIG_HEADER = $(top_builddir)/src/platform.h
100 CONFIG_CLEAN_FILES =
101 CONFIG_CLEAN_VPATH_FILES =
102 AM_V_P = $(am__v_P_@AM_V@)
103 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
104 am__v_P_0 = false
105 am__v_P_1 = :
106 AM_V_GEN = $(am__v_GEN_@AM_V@)
107 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
108 am__v_GEN_0 = @echo " GEN " $@;
109 am__v_GEN_1 =
110 AM_V_at = $(am__v_at_@AM_V@)
111 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
112 am__v_at_0 = @
113 am__v_at_1 =
114 SOURCES =
115 DIST_SOURCES =
116 am__can_run_installinfo = \
117 case $$AM_UPDATE_INFO_DIR in \
118 n|no|NO) false;; \
119 *) (install-info --version) >/dev/null 2>&1;; \
120 esac
121 am__include_HEADERS_DIST = czmq_prelude.h czmq.h zactor.h zarmour.h \
122 zcert.h zcertstore.h zchunk.h zclock.h zconfig.h zdigest.h \
123 zdir.h zdir_patch.h zfile.h zframe.h zhash.h zhashx.h \
124 ziflist.h zlist.h zlistx.h zloop.h zmsg.h zpoller.h zsock.h \
125 zstr.h zsys.h zuuid.h zauth.h zbeacon.h zgossip.h zmonitor.h \
126 zproxy.h zrex.h czmq_library.h zargs.h zproc.h ztimerset.h \
127 ztrie.h
128 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
129 am__vpath_adj = case $$p in \
130 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
131 *) f=$$p;; \
132 esac;
133 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
134 am__install_max = 40
135 am__nobase_strip_setup = \
136 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
137 am__nobase_strip = \
138 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
139 am__nobase_list = $(am__nobase_strip_setup); \
140 for p in $$list; do echo "$$p $$p"; done | \
141 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
142 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
143 if (++n[$$2] == $(am__install_max)) \
144 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
145 END { for (dir in files) print dir, files[dir] }'
146 am__base_list = \
147 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
148 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
149 am__uninstall_files_from_dir = { \
150 test -z "$$files" \
151 || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
152 || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
153 $(am__cd) "$$dir" && rm -f $$files; }; \
154 }
155 am__installdirs = "$(DESTDIR)$(includedir)"
156 HEADERS = $(include_HEADERS)
157 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
158 # Read a list of newline-separated strings from the standard input,
159 # and print each of them once, without duplicates. Input order is
160 # *not* preserved.
161 am__uniquify_input = $(AWK) '\
162 BEGIN { nonempty = 0; } \
163 { items[$$0] = 1; nonempty = 1; } \
164 END { if (nonempty) { for (i in items) print i; }; } \
165 '
166 # Make sure the list of sources is unique. This is necessary because,
167 # e.g., the same source file might be shared among _SOURCES variables
168 # for different programs/libraries.
169 am__define_uniq_tagged_files = \
170 list='$(am__tagged_files)'; \
171 unique=`for i in $$list; do \
172 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
173 done | $(am__uniquify_input)`
174 ETAGS = etags
175 CTAGS = ctags
176 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
177 ACLOCAL = @ACLOCAL@
178 AMTAR = @AMTAR@
179 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
180 AR = @AR@
181 AS = @AS@
182 AUTOCONF = @AUTOCONF@
183 AUTOHEADER = @AUTOHEADER@
184 AUTOMAKE = @AUTOMAKE@
185 AWK = @AWK@
186 BUILD_ARCH = @BUILD_ARCH@
187 BUILD_DATE = @BUILD_DATE@
188 BUILD_HOST = @BUILD_HOST@
189 BUILD_USER = @BUILD_USER@
190 BUILD_VERSION = @BUILD_VERSION@
191 CC = @CC@
192 CCDEPMODE = @CCDEPMODE@
193 CFLAGS = @CFLAGS@
194 CLANG_FORMAT = @CLANG_FORMAT@
195 CPP = @CPP@
196 CPPFLAGS = @CPPFLAGS@
197 CYGPATH_W = @CYGPATH_W@
198 DEFS = @DEFS@
199 DEPDIR = @DEPDIR@
200 DLLTOOL = @DLLTOOL@
201 DSYMUTIL = @DSYMUTIL@
202 DUMPBIN = @DUMPBIN@
203 ECHO_C = @ECHO_C@
204 ECHO_N = @ECHO_N@
205 ECHO_T = @ECHO_T@
206 EGREP = @EGREP@
207 EXEEXT = @EXEEXT@
208 FGREP = @FGREP@
209 GREP = @GREP@
210 INSTALL = @INSTALL@
211 INSTALL_DATA = @INSTALL_DATA@
212 INSTALL_PROGRAM = @INSTALL_PROGRAM@
213 INSTALL_SCRIPT = @INSTALL_SCRIPT@
214 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
215 LD = @LD@
216 LDFLAGS = @LDFLAGS@
217 LIBOBJS = @LIBOBJS@
218 LIBS = @LIBS@
219 LIBTOOL = @LIBTOOL@
220 LIPO = @LIPO@
221 LN_S = @LN_S@
222 LTLIBOBJS = @LTLIBOBJS@
223 LTVER = @LTVER@
224 MAKEINFO = @MAKEINFO@
225 MANIFEST_TOOL = @MANIFEST_TOOL@
226 MKDIR_P = @MKDIR_P@
227 NM = @NM@
228 NMEDIT = @NMEDIT@
229 OBJDUMP = @OBJDUMP@
230 OBJEXT = @OBJEXT@
231 OTOOL = @OTOOL@
232 OTOOL64 = @OTOOL64@
233 PACKAGE = @PACKAGE@
234 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
235 PACKAGE_NAME = @PACKAGE_NAME@
236 PACKAGE_STRING = @PACKAGE_STRING@
237 PACKAGE_TARNAME = @PACKAGE_TARNAME@
238 PACKAGE_URL = @PACKAGE_URL@
239 PACKAGE_VERSION = @PACKAGE_VERSION@
240 PATH_SEPARATOR = @PATH_SEPARATOR@
241 PKG_CONFIG = @PKG_CONFIG@
242 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
243 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
244 RANLIB = @RANLIB@
245 SED = @SED@
246 SET_MAKE = @SET_MAKE@
247 SHELL = @SHELL@
248 STRIP = @STRIP@
249 VERSION = @VERSION@
250 WITH_CLANG_FORMAT = @WITH_CLANG_FORMAT@
251 WITH_CPPCHECK = @WITH_CPPCHECK@
252 abs_builddir = @abs_builddir@
253 abs_srcdir = @abs_srcdir@
254 abs_top_builddir = @abs_top_builddir@
255 abs_top_srcdir = @abs_top_srcdir@
256 ac_ct_AR = @ac_ct_AR@
257 ac_ct_CC = @ac_ct_CC@
258 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
259 am__include = @am__include@
260 am__leading_dot = @am__leading_dot@
261 am__quote = @am__quote@
262 am__tar = @am__tar@
263 am__untar = @am__untar@
264 bindir = @bindir@
265 build = @build@
266 build_alias = @build_alias@
267 build_cpu = @build_cpu@
268 build_os = @build_os@
269 build_vendor = @build_vendor@
270 builddir = @builddir@
271 czmq_have_asciidoc = @czmq_have_asciidoc@
272 czmq_have_xmlto = @czmq_have_xmlto@
273 datadir = @datadir@
274 datarootdir = @datarootdir@
275 docdir = @docdir@
276 dvidir = @dvidir@
277 exec_prefix = @exec_prefix@
278 host = @host@
279 host_alias = @host_alias@
280 host_cpu = @host_cpu@
281 host_os = @host_os@
282 host_vendor = @host_vendor@
283 htmldir = @htmldir@
284 includedir = @includedir@
285 infodir = @infodir@
286 install_sh = @install_sh@
287 libdir = @libdir@
288 libexecdir = @libexecdir@
289 libzmq_CFLAGS = @libzmq_CFLAGS@
290 libzmq_LIBS = @libzmq_LIBS@
291 localedir = @localedir@
292 localstatedir = @localstatedir@
293 lz4_CFLAGS = @lz4_CFLAGS@
294 lz4_LIBS = @lz4_LIBS@
295 mandir = @mandir@
296 mkdir_p = @mkdir_p@
297 oldincludedir = @oldincludedir@
298 pdfdir = @pdfdir@
299 pkg_config_defines = @pkg_config_defines@
300 pkg_config_libs_private = @pkg_config_libs_private@
301 pkgconfig_name_liblz4 = @pkgconfig_name_liblz4@
302 pkgconfig_name_libsystemd = @pkgconfig_name_libsystemd@
303 pkgconfig_name_libzmq = @pkgconfig_name_libzmq@
304 pkgconfig_name_uuid = @pkgconfig_name_uuid@
305 pkgconfigdir = @pkgconfigdir@
306 prefix = @prefix@
307 program_transform_name = @program_transform_name@
308 psdir = @psdir@
309 sbindir = @sbindir@
310 sharedstatedir = @sharedstatedir@
311 srcdir = @srcdir@
312 sysconfdir = @sysconfdir@
313 systemd_CFLAGS = @systemd_CFLAGS@
314 systemd_LIBS = @systemd_LIBS@
315 target_alias = @target_alias@
316 top_build_prefix = @top_build_prefix@
317 top_builddir = @top_builddir@
318 top_srcdir = @top_srcdir@
319 uuid_CFLAGS = @uuid_CFLAGS@
320 uuid_LIBS = @uuid_LIBS@
321
322 ################################################################################
323 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
324 # Read the zproject/README.md for information about making permanent changes. #
325 ################################################################################
326 include_HEADERS = czmq_prelude.h czmq.h zactor.h zarmour.h zcert.h \
327 zcertstore.h zchunk.h zclock.h zconfig.h zdigest.h zdir.h \
328 zdir_patch.h zfile.h zframe.h zhash.h zhashx.h ziflist.h \
329 zlist.h zlistx.h zloop.h zmsg.h zpoller.h zsock.h zstr.h \
330 zsys.h zuuid.h zauth.h zbeacon.h zgossip.h zmonitor.h zproxy.h \
331 zrex.h czmq_library.h $(am__append_1)
332 all: all-am
333
334 .SUFFIXES:
335 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
336 @for dep in $?; do \
337 case '$(am__configure_deps)' in \
338 *$$dep*) \
339 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
340 && { if test -f $@; then exit 0; else break; fi; }; \
341 exit 1;; \
342 esac; \
343 done; \
344 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
345 $(am__cd) $(top_srcdir) && \
346 $(AUTOMAKE) --foreign include/Makefile
347 .PRECIOUS: Makefile
348 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
349 @case '$?' in \
350 *config.status*) \
351 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
352 *) \
353 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
354 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
355 esac;
356
357 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
358 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
359
360 $(top_srcdir)/configure: $(am__configure_deps)
361 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
362 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
363 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
364 $(am__aclocal_m4_deps):
365
366 mostlyclean-libtool:
367 -rm -f *.lo
368
369 clean-libtool:
370 -rm -rf .libs _libs
371 install-includeHEADERS: $(include_HEADERS)
372 @$(NORMAL_INSTALL)
373 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
374 if test -n "$$list"; then \
375 echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
376 $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
377 fi; \
378 for p in $$list; do \
379 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
380 echo "$$d$$p"; \
381 done | $(am__base_list) | \
382 while read files; do \
383 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
384 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
385 done
386
387 uninstall-includeHEADERS:
388 @$(NORMAL_UNINSTALL)
389 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
390 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
391 dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
392
393 ID: $(am__tagged_files)
394 $(am__define_uniq_tagged_files); mkid -fID $$unique
395 tags: tags-am
396 TAGS: tags
397
398 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
399 set x; \
400 here=`pwd`; \
401 $(am__define_uniq_tagged_files); \
402 shift; \
403 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
404 test -n "$$unique" || unique=$$empty_fix; \
405 if test $$# -gt 0; then \
406 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
407 "$$@" $$unique; \
408 else \
409 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
410 $$unique; \
411 fi; \
412 fi
413 ctags: ctags-am
414
415 CTAGS: ctags
416 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
417 $(am__define_uniq_tagged_files); \
418 test -z "$(CTAGS_ARGS)$$unique" \
419 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
420 $$unique
421
422 GTAGS:
423 here=`$(am__cd) $(top_builddir) && pwd` \
424 && $(am__cd) $(top_srcdir) \
425 && gtags -i $(GTAGS_ARGS) "$$here"
426 cscopelist: cscopelist-am
427
428 cscopelist-am: $(am__tagged_files)
429 list='$(am__tagged_files)'; \
430 case "$(srcdir)" in \
431 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
432 *) sdir=$(subdir)/$(srcdir) ;; \
433 esac; \
434 for i in $$list; do \
435 if test -f "$$i"; then \
436 echo "$(subdir)/$$i"; \
437 else \
438 echo "$$sdir/$$i"; \
439 fi; \
440 done >> $(top_builddir)/cscope.files
441
442 distclean-tags:
443 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
444
445 distdir: $(DISTFILES)
446 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
447 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
448 list='$(DISTFILES)'; \
449 dist_files=`for file in $$list; do echo $$file; done | \
450 sed -e "s|^$$srcdirstrip/||;t" \
451 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
452 case $$dist_files in \
453 */*) $(MKDIR_P) `echo "$$dist_files" | \
454 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
455 sort -u` ;; \
456 esac; \
457 for file in $$dist_files; do \
458 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
459 if test -d $$d/$$file; then \
460 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
461 if test -d "$(distdir)/$$file"; then \
462 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
463 fi; \
464 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
465 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
466 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
467 fi; \
468 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
469 else \
470 test -f "$(distdir)/$$file" \
471 || cp -p $$d/$$file "$(distdir)/$$file" \
472 || exit 1; \
473 fi; \
474 done
475 check-am: all-am
476 check: check-am
477 all-am: Makefile $(HEADERS)
478 installdirs:
479 for dir in "$(DESTDIR)$(includedir)"; do \
480 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
481 done
482 install: install-am
483 install-exec: install-exec-am
484 install-data: install-data-am
485 uninstall: uninstall-am
486
487 install-am: all-am
488 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
489
490 installcheck: installcheck-am
491 install-strip:
492 if test -z '$(STRIP)'; then \
493 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
494 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
495 install; \
496 else \
497 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
498 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
499 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
500 fi
501 mostlyclean-generic:
502
503 clean-generic:
504
505 distclean-generic:
506 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
507 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
508
509 maintainer-clean-generic:
510 @echo "This command is intended for maintainers to use"
511 @echo "it deletes files that may require special tools to rebuild."
512 clean: clean-am
513
514 clean-am: clean-generic clean-libtool mostlyclean-am
515
516 distclean: distclean-am
517 -rm -f Makefile
518 distclean-am: clean-am distclean-generic distclean-tags
519
520 dvi: dvi-am
521
522 dvi-am:
523
524 html: html-am
525
526 html-am:
527
528 info: info-am
529
530 info-am:
531
532 install-data-am: install-includeHEADERS
533
534 install-dvi: install-dvi-am
535
536 install-dvi-am:
537
538 install-exec-am:
539
540 install-html: install-html-am
541
542 install-html-am:
543
544 install-info: install-info-am
545
546 install-info-am:
547
548 install-man:
549
550 install-pdf: install-pdf-am
551
552 install-pdf-am:
553
554 install-ps: install-ps-am
555
556 install-ps-am:
557
558 installcheck-am:
559
560 maintainer-clean: maintainer-clean-am
561 -rm -f Makefile
562 maintainer-clean-am: distclean-am maintainer-clean-generic
563
564 mostlyclean: mostlyclean-am
565
566 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
567
568 pdf: pdf-am
569
570 pdf-am:
571
572 ps: ps-am
573
574 ps-am:
575
576 uninstall-am: uninstall-includeHEADERS
577
578 .MAKE: install-am install-strip
579
580 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
581 clean-libtool cscopelist-am ctags ctags-am distclean \
582 distclean-generic distclean-libtool distclean-tags distdir dvi \
583 dvi-am html html-am info info-am install install-am \
584 install-data install-data-am install-dvi install-dvi-am \
585 install-exec install-exec-am install-html install-html-am \
586 install-includeHEADERS install-info install-info-am \
587 install-man install-pdf install-pdf-am install-ps \
588 install-ps-am install-strip installcheck installcheck-am \
589 installdirs maintainer-clean maintainer-clean-generic \
590 mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
591 ps ps-am tags tags-am uninstall uninstall-am \
592 uninstall-includeHEADERS
593
594
595 ################################################################################
596 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
597 # Read the zproject/README.md for information about making permanent changes. #
598 ################################################################################
599
600 # Tell versions [3.59,3.63) of GNU make to not export all variables.
601 # Otherwise a system limit (for SysV at least) may be exceeded.
602 .NOEXPORT:
2727 // CZMQ version macros for compile-time API detection
2828 #define CZMQ_VERSION_MAJOR 4
2929 #define CZMQ_VERSION_MINOR 1
30 #define CZMQ_VERSION_PATCH 0
30 #define CZMQ_VERSION_PATCH 1
3131
3232 #define CZMQ_MAKE_VERSION(major, minor, patch) \
3333 ((major) * 10000 + (minor) * 100 + (patch))
175175 #endif // CZMQ_BUILD_DRAFT_API
176176
177177 #ifdef CZMQ_BUILD_DRAFT_API
178
179 #ifdef __cplusplus
180 extern "C" {
181 #endif
182
178183 // Self test for private classes
179184 CZMQ_EXPORT void
180 czmq_private_selftest (bool verbose);
185 czmq_private_selftest (bool verbose, const char *subtest);
186
187 #ifdef __cplusplus
188 }
189 #endif
181190 #endif // CZMQ_BUILD_DRAFT_API
182191
183192 #endif
385385 # define S_ISREG(m) (((m) & S_IFREG) != 0)
386386 #endif
387387
388 #if defined (_MAX_PATH) && !defined (PATH_MAX)
389 # define PATH_MAX _MAX_PATH
390 #endif
391 #if !defined (PATH_MAX)
392 # define PATH_MAX 1024
393 #endif
394
395 #if defined (WIN32)
396 # define getcwd _getcwd
397 #endif
388398
389399 //- Check compiler data type sizes ------------------------------------------
390400
524534 # if (!defined (__cplusplus) && (!defined (inline)))
525535 # define inline __inline
526536 # endif
527 # define strtoull _strtoui64
528 # define atoll _atoi64
537 # if (!defined (__MINGW32__))
538 # define strtoull _strtoui64
539 # define atoll _atoi64
540 # endif
529541 # define srandom srand
530542 # define TIMEZONE _timezone
531543 # if (!defined (__MINGW32__))
682694 #if defined (__UTYPE_OSX) && !defined (HAVE_UUID)
683695 # define HAVE_UUID 1
684696 #endif
697 #if defined (__UTYPE_FREEBSD) && !defined (HAVE_UUID)
698 # define HAVE_UUID 1
699 #endif
685700 #if defined (HAVE_UUID)
686701 # if defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) || defined(__UTYPE_OPENBSD)
687702 # include <uuid.h>
7272 //
7373 // An example - to send $KTHXBAI string
7474 //
75 // if (zstr_send (self->pipe, "$KTHXBAI") == 0)
76 // zsock_wait (self->pipe);
75 // if (zstr_send (self, "$KTHXBAI") == 0)
76 // zsock_wait (self);
7777 typedef void (zactor_destructor_fn) (
7878 zactor_t *self);
7979
3838 zproc_destroy (zproc_t **self_p);
3939
4040 // *** Draft method, for development use, may change without warning ***
41 // Return command line arguments (the first item is the executable) or
42 // NULL if not set.
43 // Caller owns return value and must destroy it when done.
44 CZMQ_EXPORT zlist_t *
45 zproc_args (zproc_t *self);
46
47 // *** Draft method, for development use, may change without warning ***
4148 // Setup the command line arguments, the first item must be an (absolute) filename
4249 // to run.
4350 CZMQ_EXPORT void
44 zproc_set_args (zproc_t *self, zlistx_t *args);
51 zproc_set_args (zproc_t *self, zlist_t **arguments);
52
53 // *** Draft method, for development use, may change without warning ***
54 // Setup the command line arguments, the first item must be an (absolute) filename
55 // to run. Variadic function, must be NULL terminated.
56 CZMQ_EXPORT void
57 zproc_set_argsx (zproc_t *self, const char *arguments, ...);
4558
4659 // *** Draft method, for development use, may change without warning ***
4760 // Setup the environment variables for the process.
4861 CZMQ_EXPORT void
49 zproc_set_env (zproc_t *self, zhashx_t *args);
62 zproc_set_env (zproc_t *self, zhash_t **arguments);
5063
5164 // *** Draft method, for development use, may change without warning ***
5265 // Connects process stdin with a readable ('>', connect) zeromq socket. If
88101 zproc_stderr (zproc_t *self);
89102
90103 // *** Draft method, for development use, may change without warning ***
91 // Starts the process.
104 // Starts the process, return just before execve/CreateProcess.
92105 CZMQ_EXPORT int
93106 zproc_run (zproc_t *self);
94107
128141 zproc_set_verbose (zproc_t *self, bool verbose);
129142
130143 // *** Draft method, for development use, may change without warning ***
131 // Returns CZMQ version as a single 6-digit integer encoding the major
132 // version (x 10000), the minor version (x 100) and the patch.
133 CZMQ_EXPORT int
134 zproc_czmq_version (void);
135
136 // *** Draft method, for development use, may change without warning ***
137 // Returns true if the process received a SIGINT or SIGTERM signal.
138 // It is good practice to use this method to exit any infinite loop
139 // processing messages.
140 CZMQ_EXPORT bool
141 zproc_interrupted (void);
142
143 // *** Draft method, for development use, may change without warning ***
144 // Returns true if the underlying libzmq supports CURVE security.
145 CZMQ_EXPORT bool
146 zproc_has_curve (void);
147
148 // *** Draft method, for development use, may change without warning ***
149 // Return current host name, for use in public tcp:// endpoints.
150 // If the host name is not resolvable, returns NULL.
151 // Caller owns return value and must destroy it when done.
152 CZMQ_EXPORT char *
153 zproc_hostname (void);
154
155 // *** Draft method, for development use, may change without warning ***
156 // Move the current process into the background. The precise effect
157 // depends on the operating system. On POSIX boxes, moves to a specified
158 // working directory (if specified), closes all file handles, reopens
159 // stdin, stdout, and stderr to the null device, and sets the process to
160 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
161 // was an error.
162 CZMQ_EXPORT void
163 zproc_daemonize (const char *workdir);
164
165 // *** Draft method, for development use, may change without warning ***
166 // Drop the process ID into the lockfile, with exclusive lock, and
167 // switch the process to the specified group and/or user. Any of the
168 // arguments may be null, indicating a no-op. Returns 0 on success,
169 // -1 on failure. Note if you combine this with zsys_daemonize, run
170 // after, not before that method, or the lockfile will hold the wrong
171 // process ID.
172 CZMQ_EXPORT void
173 zproc_run_as (const char *lockfile, const char *group, const char *user);
174
175 // *** Draft method, for development use, may change without warning ***
176 // Configure the number of I/O threads that ZeroMQ will use. A good
177 // rule of thumb is one thread per gigabit of traffic in or out. The
178 // default is 1, sufficient for most applications. If the environment
179 // variable ZSYS_IO_THREADS is defined, that provides the default.
180 // Note that this method is valid only before any socket is created.
181 CZMQ_EXPORT void
182 zproc_set_io_threads (size_t io_threads);
183
184 // *** Draft method, for development use, may change without warning ***
185 // Configure the number of sockets that ZeroMQ will allow. The default
186 // is 1024. The actual limit depends on the system, and you can query it
187 // by using zsys_socket_limit (). A value of zero means "maximum".
188 // Note that this method is valid only before any socket is created.
189 CZMQ_EXPORT void
190 zproc_set_max_sockets (size_t max_sockets);
191
192 // *** Draft method, for development use, may change without warning ***
193 // Set network interface name to use for broadcasts, particularly zbeacon.
194 // This lets the interface be configured for test environments where required.
195 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
196 // the default when there is no specified interface. If the environment
197 // variable ZSYS_INTERFACE is set, use that as the default interface name.
198 // Setting the interface to "*" means "use all available interfaces".
199 CZMQ_EXPORT void
200 zproc_set_biface (const char *value);
201
202 // *** Draft method, for development use, may change without warning ***
203 // Return network interface to use for broadcasts, or "" if none was set.
204 CZMQ_EXPORT const char *
205 zproc_biface (void);
206
207 // *** Draft method, for development use, may change without warning ***
208 // Set log identity, which is a string that prefixes all log messages sent
209 // by this process. The log identity defaults to the environment variable
210 // ZSYS_LOGIDENT, if that is set.
211 CZMQ_EXPORT void
212 zproc_set_log_ident (const char *value);
213
214 // *** Draft method, for development use, may change without warning ***
215 // Sends log output to a PUB socket bound to the specified endpoint. To
216 // collect such log output, create a SUB socket, subscribe to the traffic
217 // you care about, and connect to the endpoint. Log traffic is sent as a
218 // single string frame, in the same format as when sent to stdout. The
219 // log system supports a single sender; multiple calls to this method will
220 // bind the same sender to multiple endpoints. To disable the sender, call
221 // this method with a null argument.
222 CZMQ_EXPORT void
223 zproc_set_log_sender (const char *endpoint);
224
225 // *** Draft method, for development use, may change without warning ***
226 // Enable or disable logging to the system facility (syslog on POSIX boxes,
227 // event log on Windows). By default this is disabled.
228 CZMQ_EXPORT void
229 zproc_set_log_system (bool logsystem);
230
231 // *** Draft method, for development use, may change without warning ***
232 // Log error condition - highest priority
233 CZMQ_EXPORT void
234 zproc_log_error (const char *format, ...) CHECK_PRINTF (1);
235
236 // *** Draft method, for development use, may change without warning ***
237 // Log warning condition - high priority
238 CZMQ_EXPORT void
239 zproc_log_warning (const char *format, ...) CHECK_PRINTF (1);
240
241 // *** Draft method, for development use, may change without warning ***
242 // Log normal, but significant, condition - normal priority
243 CZMQ_EXPORT void
244 zproc_log_notice (const char *format, ...) CHECK_PRINTF (1);
245
246 // *** Draft method, for development use, may change without warning ***
247 // Log informational message - low priority
248 CZMQ_EXPORT void
249 zproc_log_info (const char *format, ...) CHECK_PRINTF (1);
250
251 // *** Draft method, for development use, may change without warning ***
252 // Log debug-level message - lowest priority
253 CZMQ_EXPORT void
254 zproc_log_debug (const char *format, ...) CHECK_PRINTF (1);
255
256 // *** Draft method, for development use, may change without warning ***
257144 // Self test of this class.
258145 CZMQ_EXPORT void
259146 zproc_test (bool verbose);
403403
404404 #ifdef CZMQ_BUILD_DRAFT_API
405405 // *** Draft method, for development use, may change without warning ***
406 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
407 // Does not work if ZSYS_SIGHANDLER is false and code does not call
408 // set interrupted on signal.
409 CZMQ_EXPORT bool
410 zsys_is_interrupted (void);
411
412 // *** Draft method, for development use, may change without warning ***
413 // Set interrupted flag. This is done by default signal handler, however
414 // this can be handy for language bindings or cases without default
415 // signal handler.
416 CZMQ_EXPORT void
417 zsys_set_interrupted (void);
418
419 // *** Draft method, for development use, may change without warning ***
420 // Configure whether to use zero copy strategy in libzmq. If the environment
421 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
422 // Otherwise the default is 1.
423 CZMQ_EXPORT void
424 zsys_set_zero_copy_recv (int zero_copy);
425
426 // *** Draft method, for development use, may change without warning ***
427 // Return ZMQ_ZERO_COPY_RECV option.
428 CZMQ_EXPORT int
429 zsys_zero_copy_recv (void);
430
431 // *** Draft method, for development use, may change without warning ***
406432 // Configure the threshold value of filesystem object age per st_mtime
407433 // that should elapse until we consider that object "stable" at the
408434 // current zclock_time() moment.
1010 src_test_randof_CPPFLAGS += $(test_randof_macros)
1111 endif
1212
13 # Make sure there is the helper utility for the zproc tests
14 if ENABLE_ZSP
15 coverage \
16 check-local check-verbose \
17 memcheck memcheck-verbose \
18 debug debug-verbose \
19 callcheck callcheck-verbose \
20 animate animate-verbose \
21 : src/zsp
22 endif
23
1324 check-py: src/libczmq.la
1425 $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py
1111 lib_LTLIBRARIES += src/libczmq.la
1212 pkgconfig_DATA = src/libczmq.pc
1313
14 include_HEADERS = \
15 include/czmq_prelude.h \
16 include/czmq.h \
17 include/zactor.h \
18 include/zarmour.h \
19 include/zcert.h \
20 include/zcertstore.h \
21 include/zchunk.h \
22 include/zclock.h \
23 include/zconfig.h \
24 include/zdigest.h \
25 include/zdir.h \
26 include/zdir_patch.h \
27 include/zfile.h \
28 include/zframe.h \
29 include/zhash.h \
30 include/zhashx.h \
31 include/ziflist.h \
32 include/zlist.h \
33 include/zlistx.h \
34 include/zloop.h \
35 include/zmsg.h \
36 include/zpoller.h \
37 include/zsock.h \
38 include/zstr.h \
39 include/zsys.h \
40 include/zuuid.h \
41 include/zauth.h \
42 include/zbeacon.h \
43 include/zgossip.h \
44 include/zmonitor.h \
45 include/zproxy.h \
46 include/zrex.h \
47 include/czmq_library.h
48
49 if ENABLE_DRAFTS
50 include_HEADERS += \
51 include/zargs.h \
52 include/zproc.h \
53 include/ztimerset.h \
54 include/ztrie.h
55
56 endif
5714 src_libczmq_la_SOURCES = \
5815 src/zactor.c \
5916 src/zarmour.c \
163120 # Install api files into /usr/local/share/zproject
164121 apidir = @datadir@/zproject/czmq
165122 dist_api_DATA = \
123 api/python_cffi.slurp \
166124 api/zactor.api \
167125 api/zargs.api \
168126 api/zarmour.api \
346304 @exit 1
347305 endif
348306
307 # A series of tests that the codebase and recipes are pretty, easy
308 # to maintain and with predictable behavior. These generally are not
309 # expected to directly expose functional issues in the code, but
310 # still - there can be many reasons for failing such tests, and
311 # many lurking issues uncoverable by making code stylish again.
312 CHECK_STYLE_DEPS = check-gitignore
313 if WITH_CLANG_FORMAT
314 CHECK_STYLE_DEPS += clang-format-check
315 endif
316 check-style: $(CHECK_STYLE_DEPS)
317
318 if WITH_CLANG_FORMAT
319 ALL_SOURCE_FILES = $(wildcard \
320 $(top_srcdir)/src/*.c \
321 $(top_srcdir)/src/*.cc \
322 $(top_srcdir)/src/*.cpp \
323 $(top_srcdir)/src/*.h \
324 $(top_srcdir)/src/*.hpp \
325 $(top_srcdir)/tests/*.c \
326 $(top_srcdir)/tests/*.cc \
327 $(top_srcdir)/tests/*.cpp \
328 $(top_srcdir)/tests/*.h \
329 $(top_srcdir)/tests/*.hpp \
330 $(top_srcdir)/perf/*.c \
331 $(top_srcdir)/perf/*.cc \
332 $(top_srcdir)/perf/*.cpp \
333 $(top_srcdir)/perf/*.h \
334 $(top_srcdir)/perf/*.hpp \
335 $(top_srcdir)/tools/*.c \
336 $(top_srcdir)/tools/*.cc \
337 $(top_srcdir)/tools/*.cpp \
338 $(top_srcdir)/tools/*.h \
339 $(top_srcdir)/tools/*.hpp \
340 $(top_srcdir)/include/*.h \
341 $(top_srcdir)/include/*.hpp \
342 )
343
344 # Check if any sources need to be fixed, report the filenames and an error code
345 clang-format-check: $(ALL_SOURCE_FILES)
346 @if test -z "$(CLANG_FORMAT)" ; then \
347 echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \
348 exit 1 ; \
349 fi
350 @FAILED=0 ; IFS=";" ; IDS="`printf '\n\b'`" ; export IFS IDS; \
351 for FILE in $(ALL_SOURCE_FILES) ; do \
352 test -s $$FILE || continue ; \
353 $(CLANG_FORMAT) -style=file -output-replacements-xml "$$FILE" | grep "<replacement " >/dev/null && \
354 { echo "$$FILE is not correctly formatted" >&2 ; FAILED=1; } ; \
355 done; \
356 if test "$$FAILED" != 0 ; then \
357 exit 1 ; \
358 fi
359
360 # Change source formatting
361 clang-format: $(ALL_SOURCE_FILES)
362 @if test -z "$(CLANG_FORMAT)" ; then \
363 echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \
364 exit 1 ; \
365 fi
366 $(CLANG_FORMAT) -style=file -i $(ALL_SOURCE_FILES)
367
368 # Change source formatting AND report the diff
369 clang-format-diff: clang-format
370 git diff $(ALL_SOURCE_FILES)
371
372 # A destructive (will change code in workspace) but informative check; this is
373 # primarily intended for CI temporary workspaces where mutilation is acceptable.
374 # The envvar/makearg CI_REQUIRE_GOOD_CLANG_FORMAT manages if this test is fatal.
375 clang-format-check-CI:
376 @echo "CI-checking code style ..." >&2
377 @if $(MAKE) clang-format-check ; then \
378 echo "SUCCESS : Style checks have passed" >&2 ; \
379 else \
380 echo "" >&2 ; \
381 if test -n "$(CLANG_FORMAT)" ; then \
382 echo "Style mismatches were found by clang-format; detailing below:" >&2 ; \
383 $(MAKE) VERBOSE=1 clang-format-diff ; \
384 fi ; \
385 if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \
386 echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \
387 exit 1 ; \
388 fi ; \
389 echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 ; \
390 fi
391
392 else
393 clang-format clang-format-check clang-format-diff:
394 @echo "Install the clang-format program, reconfigure and re-run this request"
395 @exit 1
396
397 clang-format-check-CI:
398 @echo "Install the clang-format program, reconfigure and re-run this request"
399 @if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \
400 echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \
401 exit 1 ; \
402 fi ; \
403 echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2
404 endif
405
406 # Note: analysis is not a target executed by default, so there is no
407 # safety-net for the "cppcheck.xml" recipe; there is one for the wrapper.
408 # A developer is expected to install tools in build environment, if needed.
409 # The results can be used to produce some statistics how project quality
410 # changes over many builds (with a relevant Jenkins plugin, for example).
411 if WITH_CPPCHECK
412 cppcheck: cppcheck.xml
413 else
414 cppcheck:
415 @echo "NOT ENABLED: cppcheck static analysis. Please install the toolkit and reconfigure, and/or make cppcheck.xml directly."
416 endif
417
418 cppcheck.xml:
419 @echo "Performing cppcheck static analysis..."
420 cppcheck --enable=all --inconclusive --xml --xml-version=2 . 2>"$@"
421 @echo "The cppcheck static analysis is done"
422
423 # Note: this recipe tests that the Git-based workspace reports no changed
424 # or untracked files - meaning there are no unexpected behaviors in the
425 # recipes (when checking after a build), and nothing was missed while
426 # updating the project structure (when checking in the midst of development
427 # or after regenerating the zproject skeletons), for example. For best
428 # results, developers are advised to also run this after executing their
429 # tests, to make sure they are stateless and clean as well. Caller may
430 # export envvar (or pass make argument) CI_REQUIRE_GOOD_GITIGNORE=false
431 # to explicitly disable fatality of this check, while still logging it.
432
433 # This recipe is "stateless" by itself, not causing any workspace changes:
434 check-gitignore:
435 @(if which git >/dev/null 2>&1 ; then \
436 RES=0; \
437 echo "Checking for untracked and not-ignored files in the workspace (should have no output below)..."; \
438 git status -s | egrep '^\?\? ' && RES=1 ; \
439 echo "Checking for modified tracked files in the workspace (should have no output below)..."; \
440 git status -s | egrep '^ *M ' && RES=1 && git diff | cat ; \
441 if [ "$$RES" = 0 ]; then \
442 echo "PASS: $@"; exit 0 ; \
443 else \
444 if [ x"$(CI_REQUIRE_GOOD_GITIGNORE)" = xfalse ] ; then \
445 echo "WARNING: $@ found newly changed or untracked and not-ignored files (not a test failure due to CI_REQUIRE_GOOD_GITIGNORE==false)"; exit 0 ; \
446 fi; \
447 echo "FAIL: $@ (see workspace checks above)"; exit 1; \
448 fi; \
449 else \
450 echo "SKIP: $@ (no git)"; exit 0 ; \
451 fi )
452
453 # This calls the recipe above after building the project products and
454 # the selftest binary, and preparing the workspace for self-testing:
455 check-gitignore-all: all src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
456 $@$(MAKE) check-gitignore
457
458
349459 ################################################################################
350460 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
351461 # Read the zproject/README.md for information about making permanent changes. #
4343 //
4444 // An example - to send $KTHXBAI string
4545 //
46 // if (zstr_send (self->pipe, "$KTHXBAI") == 0)
47 // zsock_wait (self->pipe);
46 // if (zstr_send (self, "$KTHXBAI") == 0)
47 // zsock_wait (self);
4848 typedef void (zactor_destructor_fn) (
4949 zactor_t *self);
5050
269269 zstr_str (void *source);
270270
271271 // *** Draft method, defined for internal use only ***
272 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
273 // Does not work if ZSYS_SIGHANDLER is false and code does not call
274 // set interrupted on signal.
275 CZMQ_PRIVATE bool
276 zsys_is_interrupted (void);
277
278 // *** Draft method, defined for internal use only ***
279 // Set interrupted flag. This is done by default signal handler, however
280 // this can be handy for language bindings or cases without default
281 // signal handler.
282 CZMQ_PRIVATE void
283 zsys_set_interrupted (void);
284
285 // *** Draft method, defined for internal use only ***
286 // Configure whether to use zero copy strategy in libzmq. If the environment
287 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
288 // Otherwise the default is 1.
289 CZMQ_PRIVATE void
290 zsys_set_zero_copy_recv (int zero_copy);
291
292 // *** Draft method, defined for internal use only ***
293 // Return ZMQ_ZERO_COPY_RECV option.
294 CZMQ_PRIVATE int
295 zsys_zero_copy_recv (void);
296
297 // *** Draft method, defined for internal use only ***
272298 // Configure the threshold value of filesystem object age per st_mtime
273299 // that should elapse until we consider that object "stable" at the
274300 // current zclock_time() moment.
380406
381407 // Self test for private classes
382408 CZMQ_PRIVATE void
383 czmq_private_selftest (bool verbose);
409 czmq_private_selftest (bool verbose, const char *subtest);
384410
385411 #endif // CZMQ_BUILD_DRAFT_API
386412
2626 //
2727
2828 void
29 czmq_private_selftest (bool verbose)
29 czmq_private_selftest (bool verbose, const char *subtest)
3030 {
3131 // Tests for stable private classes:
32 zgossip_msg_test (verbose);
32 if (streq (subtest, "$ALL") || streq (subtest, "zgossip_msg_test"))
33 zgossip_msg_test (verbose);
3334 }
3435 /*
3536 ################################################################################
2020
2121 #include "czmq_classes.h"
2222
23 #include <stdio.h>
24 #include <string.h>
25
2326 typedef struct {
24 const char *testname;
25 void (*test) (bool);
27 const char *testname; // test name, can be called from command line this way
28 void (*test) (bool); // function to run the test (or NULL for private tests)
29 bool stable; // true if class is declared as stable
30 bool pub; // true if class is declared as public
31 const char *subtest; // name of private subtest to run
2632 } test_item_t;
2733
2834 static test_item_t
2935 all_tests [] = {
3036 // Tests for stable public classes:
31 { "zactor", zactor_test },
32 { "zarmour", zarmour_test },
33 { "zcert", zcert_test },
34 { "zcertstore", zcertstore_test },
35 { "zchunk", zchunk_test },
36 { "zclock", zclock_test },
37 { "zconfig", zconfig_test },
38 { "zdigest", zdigest_test },
39 { "zdir", zdir_test },
40 { "zdir_patch", zdir_patch_test },
41 { "zfile", zfile_test },
42 { "zframe", zframe_test },
43 { "zhash", zhash_test },
44 { "zhashx", zhashx_test },
45 { "ziflist", ziflist_test },
46 { "zlist", zlist_test },
47 { "zlistx", zlistx_test },
48 { "zloop", zloop_test },
49 { "zmsg", zmsg_test },
50 { "zpoller", zpoller_test },
51 { "zsock", zsock_test },
52 { "zstr", zstr_test },
53 { "zsys", zsys_test },
54 { "zuuid", zuuid_test },
55 { "zauth", zauth_test },
56 { "zbeacon", zbeacon_test },
57 { "zgossip", zgossip_test },
58 { "zmonitor", zmonitor_test },
59 { "zproxy", zproxy_test },
60 { "zrex", zrex_test },
37 { "zactor", zactor_test, true, true, NULL },
38 { "zarmour", zarmour_test, true, true, NULL },
39 { "zcert", zcert_test, true, true, NULL },
40 { "zcertstore", zcertstore_test, true, true, NULL },
41 { "zchunk", zchunk_test, true, true, NULL },
42 { "zclock", zclock_test, true, true, NULL },
43 { "zconfig", zconfig_test, true, true, NULL },
44 { "zdigest", zdigest_test, true, true, NULL },
45 { "zdir", zdir_test, true, true, NULL },
46 { "zdir_patch", zdir_patch_test, true, true, NULL },
47 { "zfile", zfile_test, true, true, NULL },
48 { "zframe", zframe_test, true, true, NULL },
49 { "zhash", zhash_test, true, true, NULL },
50 { "zhashx", zhashx_test, true, true, NULL },
51 { "ziflist", ziflist_test, true, true, NULL },
52 { "zlist", zlist_test, true, true, NULL },
53 { "zlistx", zlistx_test, true, true, NULL },
54 { "zloop", zloop_test, true, true, NULL },
55 { "zmsg", zmsg_test, true, true, NULL },
56 { "zpoller", zpoller_test, true, true, NULL },
57 { "zsock", zsock_test, true, true, NULL },
58 { "zstr", zstr_test, true, true, NULL },
59 { "zsys", zsys_test, true, true, NULL },
60 { "zuuid", zuuid_test, true, true, NULL },
61 { "zauth", zauth_test, true, true, NULL },
62 { "zbeacon", zbeacon_test, true, true, NULL },
63 { "zgossip", zgossip_test, true, true, NULL },
64 { "zmonitor", zmonitor_test, true, true, NULL },
65 { "zproxy", zproxy_test, true, true, NULL },
66 { "zrex", zrex_test, true, true, NULL },
6167 #ifdef CZMQ_BUILD_DRAFT_API
6268 // Tests for draft public classes:
63 { "zargs", zargs_test },
64 { "zproc", zproc_test },
65 { "ztimerset", ztimerset_test },
66 { "ztrie", ztrie_test },
69 { "zargs", zargs_test, false, true, NULL },
70 { "zproc", zproc_test, false, true, NULL },
71 { "ztimerset", ztimerset_test, false, true, NULL },
72 { "ztrie", ztrie_test, false, true, NULL },
6773 #endif // CZMQ_BUILD_DRAFT_API
6874 #ifdef CZMQ_BUILD_DRAFT_API
69 { "private_classes", czmq_private_selftest },
70 #endif // CZMQ_BUILD_DRAFT_API
71 {0, 0} // Sentinel
75 // Tests for stable/draft private classes:
76 // Now built only with --enable-drafts, so even stable builds are hidden behind the flag
77 { "zgossip_msg", NULL, true, false, "zgossip_msg_test" },
78 { "private_classes", NULL, false, false, "$ALL" }, // compat option for older projects
79 #endif // CZMQ_BUILD_DRAFT_API
80 {NULL, NULL, 0, 0, NULL} // Sentinel
7281 };
7382
7483 // -------------------------------------------------------------------------
8089 test_available (const char *testname)
8190 {
8291 test_item_t *item;
83 for (item = all_tests; item->test; item++) {
84 if (streq (testname, item->testname))
92 for (item = all_tests; item->testname; item++) {
93 if (strcmp (testname, item->testname) == 0)
8594 return item;
8695 }
8796 return NULL;
96105 {
97106 test_item_t *item;
98107 printf ("Running czmq selftests...\n");
99 for (item = all_tests; item->test; item++)
100 item->test (verbose);
108 for (item = all_tests; item->testname; item++) {
109 if (strcmp (item->testname, "private_classes") == 0)
110 continue;
111 if (!item->subtest)
112 item->test (verbose);
113 #ifdef CZMQ_BUILD_DRAFT_API // selftest is still in draft
114 else
115 czmq_private_selftest (verbose, item->subtest);
116 #endif // CZMQ_BUILD_DRAFT_API
117 }
101118
102119 printf ("Tests passed OK\n");
120 }
121
122 static void
123 test_list (void)
124 {
125 test_item_t *item;
126 puts ("Available tests:");
127 for (item = all_tests; item->testname; item++)
128 printf (" %-40s - %s %s\n",
129 item->testname,
130 item->stable ? "stable" : "draft",
131 item->pub ? "public" : "private"
132 );
133 }
134
135 static void
136 test_number (void)
137 {
138 int n = 0;
139 test_item_t *item;
140 for (item = all_tests; item->testname; item++) {
141 if (strcmp (item->testname, "private_classes") == 0)
142 n++;
143 }
144 printf ("%d\n", n);
103145 }
104146
105147 int
109151 test_item_t *test = 0;
110152 int argn;
111153 for (argn = 1; argn < argc; argn++) {
112 if (streq (argv [argn], "--help")
113 || streq (argv [argn], "-h")) {
154 if (strcmp (argv [argn], "--help") == 0
155 || strcmp (argv [argn], "-h") == 0) {
114156 puts ("czmq_selftest.c [options] ...");
115157 puts (" --verbose / -v verbose test output");
116158 puts (" --number / -n report number of tests");
119161 puts (" --continue / -c continue on exception (on Windows)");
120162 return 0;
121163 }
122 if (streq (argv [argn], "--verbose")
123 || streq (argv [argn], "-v"))
164 if (strcmp (argv [argn], "--verbose") == 0
165 || strcmp (argv [argn], "-v") == 0)
124166 verbose = true;
125167 else
126 if (streq (argv [argn], "--number")
127 || streq (argv [argn], "-n")) {
128 puts ("35");
168 if (strcmp (argv [argn], "--number") == 0
169 || strcmp (argv [argn], "-n") == 0) {
170 test_number ();
129171 return 0;
130172 }
131173 else
132 if (streq (argv [argn], "--list")
133 || streq (argv [argn], "-l")) {
134 puts ("Available tests:");
135 puts (" zactor\t\t- stable");
136 puts (" zargs\t\t- draft");
137 puts (" zarmour\t\t- stable");
138 puts (" zcert\t\t- stable");
139 puts (" zcertstore\t\t- stable");
140 puts (" zchunk\t\t- stable");
141 puts (" zclock\t\t- stable");
142 puts (" zconfig\t\t- stable");
143 puts (" zdigest\t\t- stable");
144 puts (" zdir\t\t- stable");
145 puts (" zdir_patch\t\t- stable");
146 puts (" zfile\t\t- stable");
147 puts (" zframe\t\t- stable");
148 puts (" zhash\t\t- stable");
149 puts (" zhashx\t\t- stable");
150 puts (" ziflist\t\t- stable");
151 puts (" zlist\t\t- stable");
152 puts (" zlistx\t\t- stable");
153 puts (" zloop\t\t- stable");
154 puts (" zmsg\t\t- stable");
155 puts (" zpoller\t\t- stable");
156 puts (" zproc\t\t- draft");
157 puts (" zsock\t\t- stable");
158 puts (" zstr\t\t- stable");
159 puts (" zsys\t\t- stable");
160 puts (" ztimerset\t\t- draft");
161 puts (" ztrie\t\t- draft");
162 puts (" zuuid\t\t- stable");
163 puts (" zauth\t\t- stable");
164 puts (" zbeacon\t\t- stable");
165 puts (" zgossip\t\t- stable");
166 puts (" zmonitor\t\t- stable");
167 puts (" zproxy\t\t- stable");
168 puts (" zrex\t\t- stable");
169 puts (" private_classes\t- draft");
174 if (strcmp (argv [argn], "--list") == 0
175 || strcmp (argv [argn], "-l") == 0) {
176 test_list ();
170177 return 0;
171178 }
172179 else
173 if (streq (argv [argn], "--test")
174 || streq (argv [argn], "-t")) {
180 if (strcmp (argv [argn], "--test") == 0
181 || strcmp (argv [argn], "-t") == 0) {
175182 argn++;
176183 if (argn >= argc) {
177184 fprintf (stderr, "--test needs an argument\n");
184191 }
185192 }
186193 else
187 if (streq (argv [argn], "--continue")
188 || streq (argv [argn], "-c")) {
194 if (strcmp (argv [argn], "--continue") == 0
195 || strcmp (argv [argn], "-c") == 0) {
189196 #ifdef _MSC_VER
190197 // When receiving an abort signal, only print to stderr (no dialog)
191198 _set_abort_behavior (0, _WRITE_ABORT_MSG);
204211
205212 if (test) {
206213 printf ("Running czmq test '%s'...\n", test->testname);
207 test->test (verbose);
214 if (!test->subtest)
215 test->test (verbose);
216 #ifdef CZMQ_BUILD_DRAFT_API // selftest is still in draft
217 else
218 czmq_private_selftest (verbose, test->subtest);
219 #endif // CZMQ_BUILD_DRAFT_API
208220 }
209221 else
210222 test_runall (verbose);
173173 #define PACKAGE_NAME "czmq"
174174
175175 /* Define to the full name and version of this package. */
176 #define PACKAGE_STRING "czmq 4.1.0"
176 #define PACKAGE_STRING "czmq 4.1.1"
177177
178178 /* Define to the one symbol short name of this package. */
179179 #define PACKAGE_TARNAME "czmq"
182182 #define PACKAGE_URL ""
183183
184184 /* Define to the version of this package. */
185 #define PACKAGE_VERSION "4.1.0"
185 #define PACKAGE_VERSION "4.1.1"
186186
187187 /* CZMQ major version */
188188 #define PACKAGE_VERSION_MAJOR 4
191191 #define PACKAGE_VERSION_MINOR 1
192192
193193 /* CZMQ patchlevel */
194 #define PACKAGE_VERSION_PATCH 0
194 #define PACKAGE_VERSION_PATCH 1
195195
196196 /* Define as the return type of signal handlers (`int' or `void'). */
197197 #define RETSIGTYPE void
203203 #define TIME_WITH_SYS_TIME 1
204204
205205 /* Version number of package */
206 #define VERSION "4.1.0"
206 #define VERSION "4.1.1"
207207
208208 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
209209 significant byte first (like Motorola and SPARC, unlike Intel). */
3434
3535 // zactor_t instances always have this tag as the first 4 octets of
3636 // their data, which lets us do runtime object typing & validation.
37 #define ZACTOR_TAG 0x0005cafe
37 #define ZACTOR_TAG 0xcafe0005
3838
3939 // Structure of our class
4040
299299 static void
300300 KTHXBAI_destructor (zactor_t *self) {
301301 assert (self);
302 if (zstr_send (self->pipe, "$KTHXBAI") == 0)
303 zsock_wait (self->pipe);
302 if (zstr_send (self, "$KTHXBAI") == 0)
303 zsock_wait (self);
304 }
305
306 static void
307 BSEND_actor (zsock_t *pipe, void *args) {
308
309 zsock_signal (pipe, 0);
310 while (!zsys_interrupted) {
311 char *str = NULL;
312 void *ptr = NULL;
313 int r = zsock_brecv (pipe, "s", &str, &ptr);
314 if (r == -1)
315 break;
316 int done = streq (str, "$TERM");
317 if (done)
318 break;
319 }
320 }
321
322 static void
323 BSEND_destructor (zactor_t *self) {
324 assert (self);
325 const char *str = "$TERM";
326 const void *ptr = str;
327 if (zsock_bsend (self, "s", str, ptr) == 0)
328 zsock_wait (self);
304329 }
305330
306331 // --------------------------------------------------------------------------
328353 zactor_set_destructor (KTHXBAI, KTHXBAI_destructor);
329354 zactor_destroy (&KTHXBAI);
330355
356 // custom destructor
357 // destructor using bsend/brecv
358 zactor_t *BSEND = zactor_new (BSEND_actor, NULL);
359 assert (BSEND);
360 zactor_set_destructor (BSEND, BSEND_destructor);
361 zactor_destroy (&BSEND);
331362 #if defined (__WINDOWS__)
332363 zsys_shutdown();
333364 #endif
2222
2323 // zchunk_t instances always have this tag as the first 4 octets of
2424 // their data, which lets us do runtime object typing & validation.
25 #define ZCHUNK_TAG 0x0001cafe
25 #define ZCHUNK_TAG 0xcafe0001
2626
2727 // Structure of our class
2828
140140 self->fullname = strdup (name);
141141 self->handle = fopen (self->fullname, "w");
142142 #else
143
144 # if (defined (PATH_MAX))
143145 char buffer [PATH_MAX];
144 strcpy (buffer, "/tmp/czmq_zfile.XXXXXX");
146 # else
147 # if (defined (_MAX_PATH))
148 char buffer [_MAX_PATH];
149 # else
150 char buffer [1024];
151 # endif
152 # endif
153 memset (buffer, 0, sizeof (buffer));
154 strncpy (buffer, "/tmp/czmq_zfile.XXXXXX", sizeof(buffer)-1);
145155 int fd = mkstemp (buffer);
146156 if (fd == -1)
147157 return NULL;
2727
2828 // zframe_t instances always have this tag as the first 4 octets of
2929 // their data, which lets us do runtime object typing & validation.
30 #define ZFRAME_TAG 0x0002cafe
30 #define ZFRAME_TAG 0xcafe0002
3131
3232 // Structure of our class
3333
408408 strcpy (self->group, group);
409409 return 0;
410410 #else
411 errno = EINVAL;
411 errno = ENOTSUP;
412412 return -1;
413413 #endif
414414 }
744744
745745 zsock_destroy (&dish);
746746 zsock_destroy (&radio);
747 #else
748 frame = zframe_new ("Hello", 5);
749 rc = zframe_set_group (frame, "World");
750 assert(rc == -1);
751 assert(errno == ENOTSUP);
752 zframe_destroy (&frame);
747753 #endif
748754
749755 #if defined (__WINDOWS__)
2525
2626 #include "czmq_classes.h"
2727
28 #define NODE_TAG 0x0006cafe
28 #define NODE_TAG 0xcafe0006
2929
3030 // List node, used internally only
3131
8080
8181 // As we pass void * to/from the caller for working with tickets, we
8282 // check validity using an object tag. This value is unique in CZMQ.
83 #define TICKET_TAG 0x0007cafe
83 #define TICKET_TAG 0xcafe0007
8484
8585 struct _s_ticket_t {
8686 uint32_t tag; // Object tag for runtime detection
2424
2525 // zmsg_t instances always have this tag as the first 4 octets of
2626 // their data, which lets us do runtime object typing & validation.
27 #define ZMSG_TAG 0x0003cafe
27 #define ZMSG_TAG 0xcafe0003
2828
2929 // Structure of our class
3030
00 /* =========================================================================
11 zproc - process configuration and status
22
3 Copyright (c) the Contributors as noted in the AUTHORS file.
4 This file is part of CZMQ, the high-level C binding for 0MQ:
5 http://czmq.zeromq.org.
6
3 Copyright (c) the Contributors as noted in the AUTHORS file.
4 This file is part of CZMQ, the high-level C binding for 0MQ:
5 http://czmq.zeromq.org.
6
77 This Source Code Form is subject to the terms of the Mozilla Public
88 License, v. 2.0. If a copy of the MPL was not distributed with this
9 file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 file, You can obtain one at http://mozilla.org/MPL/2.0/.
1010 =========================================================================
1111 */
1212
4040 |zmq://stdin |zmq://stdout |zmq://stderr |
4141 | [zproc supervisor] |
4242 +----------------------------------------+
43
43
4444 ----------> zeromq magic here <-----------
4545
4646 +----------------------------------------+
5757
5858 #include "czmq_classes.h"
5959
60 #if defined (__UNIX__)
61 # if defined (__UTYPE_OSX)
62 // issue#1836
63 #include <crt_externs.h>
64 #define environ (*_NSGetEnviron ())
65 # else
66 extern char **environ; // should be declared as a part of unistd.h, but fail in some targets in Travis
67 // declare it explicitly
68 # endif
69 #endif
70
6071 // For getcwd() variants
6172 #if (defined (WIN32))
6273 # include <direct.h>
6374 #else
6475 # include <unistd.h>
76 #endif
77
78 #if defined (__UTYPE_OSX)
79 #include <crt_externs.h>
6580 #endif
6681
6782 #define ZPROC_RUNNING -42
179194 // ####### internal helpers for zproc #######
180195
181196 struct _zproc_t {
182 #if ! defined (__WINDOWS__)
197 #if defined (__WINDOWS__)
198 PROCESS_INFORMATION piProcInfo;
199 #else
183200 //TODO: there is no windows port, so lets exclude pid from struct
184201 // zproc wasn't ported there, so no reason to do so
185202 pid_t pid;
195212 int stdoutpipe [2]; // stdout pipe
196213 int stderrpipe [2]; // stderr pipe
197214
215 zpair_t *execpair; // pair used to synchronize zproc_run with actor
198216 zpair_t *stdinpair; // stdin socketpair
199217 zpair_t *stdoutpair; // stdout socketpair
200218 zpair_t *stderrpair; // stderr socketpair
201219
202 zlistx_t *args; // command line arguments
203 zhashx_t *env; // environment
220 zlist_t *args; // command line arguments
221 zhash_t *env; // environment
204222 };
205223
206224 zproc_t*
207225 zproc_new ()
208226 {
209 #if defined (__WINDOWS__)
210 zsys_error ("zproc_set_stdin not implemented for Windows");
211 return NULL;
212 #elif ZMQ_VERSION_MAJOR < 4
227 #if ZMQ_VERSION_MAJOR < 4
213228 zsys_error ("Cannot use zproc with zmq older than 4");
214229 return NULL;
215230 #endif
223238 zproc_t *self = (zproc_t*) zmalloc (sizeof (zproc_t));
224239 self->verbose = false;
225240
241 self->stdinpipe [0] = -1;
242 self->stdinpipe [1] = -1;
243 self->stdoutpipe [0] = -1;
244 self->stdoutpipe [1] = -1;
245 self->stderrpipe [0] = -1;
246 self->stderrpipe [1] = -1;
247
226248 zuuid_t *uuid = zuuid_new ();
249 self->execpair = zpair_new (
250 zsys_sprintf ("#inproc://zproc-%s-exec", zuuid_str_canonical (uuid))
251 );
252 zpair_mkpair (self->execpair);
227253 self->stdinpair = zpair_new (
228254 zsys_sprintf ("#inproc://zproc-%s-stdin", zuuid_str_canonical (uuid))
229255 );
238264 return self;
239265 }
240266
267
241268 void
242269 zproc_destroy (zproc_t **self_p) {
243270 assert (self_p);
246273 zproc_wait (self, true);
247274 zactor_destroy (&self->actor);
248275
249 close (self->stdinpipe [0]);
250 close (self->stdinpipe [1]);
251 close (self->stdoutpipe [0]);
252 close (self->stdoutpipe [1]);
253 close (self->stderrpipe [0]);
254 close (self->stderrpipe [1]);
255
276 if (self->stdinpipe [0] != -1) {
277 close (self->stdinpipe [0]);
278 close (self->stdinpipe [1]);
279 }
280 if (self->stdoutpipe [0] != -1) {
281 close (self->stdoutpipe [0]);
282 close (self->stdoutpipe [1]);
283 }
284 if (self->stderrpipe [0] != -1) {
285 close (self->stderrpipe [0]);
286 close (self->stderrpipe [1]);
287 }
288
289 zpair_destroy (&self->execpair);
256290 zpair_destroy (&self->stdinpair);
257291 zpair_destroy (&self->stdoutpair);
258292 zpair_destroy (&self->stderrpair);
259293
260 zlistx_destroy (&self->args);
261 zhashx_destroy (&self->env);
262 freen (self);
294 zlist_destroy (&self->args);
295 zhash_destroy (&self->env);
296 free (self);
263297 *self_p = NULL;
264298 }
265299 }
266300
301 // --------------------------------------------------------------------------
302 // Return command line arguments (the first item is the executable) or
303 // NULL if not set.
304 // Caller owns return value and must destroy it when done.
305
306 zlist_t *
307 zproc_args (zproc_t *self)
308 {
309 assert (self);
310 if (self->args) {
311 zlist_t *args_dup = zlist_dup (self->args);
312 assert (args_dup);
313 return args_dup;
314 }
315 return NULL;
316 }
317
318
267319 void
268 zproc_set_args (zproc_t *self, zlistx_t *args) {
269 assert (self);
270 zlistx_destroy (&self->args);
320 zproc_set_args (zproc_t *self, zlist_t **args_p) {
321 assert (self);
322 assert (*args_p);
323 zlist_t *args = *args_p;
324 zlist_destroy (&self->args);
271325 self->args = args;
272 }
273
326 *args_p = NULL;
327 }
328
329 // Setup the command line arguments, the first item must be an (absolute) filename
330 // to run. Variadic function, must be NULL terminated.
274331 void
275 zproc_set_env (zproc_t *self, zhashx_t *env) {
276 assert (self);
277 zhashx_destroy (&self->env);
332 zproc_set_argsx (zproc_t *self, const char *args, ...)
333 {
334 assert (self);
335 va_list vargs;
336 va_start (vargs, args);
337 zlist_t *zargs = zlist_new ();
338 zlist_autofree (zargs);
339 while (args) {
340 zlist_append (zargs, (void*) args);
341 args = va_arg (vargs, const char *);
342 }
343 zproc_set_args (self, &zargs);
344 }
345
346 void
347 zproc_set_env (zproc_t *self, zhash_t **env_p) {
348 assert (self);
349 assert (*env_p);
350 zhash_t *env = *env_p;
351 zhash_destroy (&self->env);
278352 self->env = env;
353 *env_p = NULL;
279354 }
280355
281356 void
285360 zsys_error ("zproc_set_stdin not implemented for Windows");
286361 return;
287362 #else
288 assert (self->stdinpipe [0] == 0);
363 if (self->stdinpipe [0] != -1)
364 return;
289365 int r = pipe (self->stdinpipe);
290366 assert (r == 0);
291367
303379 zsys_error ("zproc_set_stdout not implemented for Windows");
304380 return;
305381 #else
306 assert (self->stdoutpipe [0] == 0);
382 if (self->stdoutpipe [0] != -1)
383 return;
307384 int r = pipe (self->stdoutpipe);
308385 assert (r == 0);
309386
321398 zsys_error ("zproc_set_stdout not implemented for Windows");
322399 return;
323400 #else
324 assert (self->stderrpipe [0] == 0);
401 if (self->stderrpipe [0] != -1)
402 return;
325403 int r = pipe (self->stderrpipe);
326404 assert (r == 0);
327405
350428 int
351429 zproc_returncode (zproc_t *self) {
352430 assert (self);
353 #if defined (__WINDOWS__)
354 zsys_error ("zproc_returncode not implemented on Windows");
355 return -1;
356 #else
357 assert (self->pid);
431 assert (zproc_pid(self));
358432 zproc_wait (self, false);
359433 return self->return_code;
360 #endif
361434 }
362435
363436 int
364437 zproc_pid (zproc_t *self) {
365438 assert (self);
366439 #if defined (__WINDOWS__)
367 zsys_error ("zproc_pid not implemented on Windows");
368 return -1;
440 return self->piProcInfo.dwProcessId;
369441 #else
370442 return self->pid;
371443 #endif
375447 static int
376448 s_fd_in_handler (zloop_t *self, zmq_pollitem_t *item, void *socket)
377449 {
378 #define BUF_SIZE 1024
450 #if defined (PIPE_BUF)
451 # define BUF_SIZE PIPE_BUF
452 #else
453 # define BUF_SIZE 65535
454 #endif
379455 byte buf [BUF_SIZE];
380456 ssize_t r = 1;
381457
382458 while (r > 0) {
459 memset (buf, '\0', BUF_SIZE);
383460 r = read (item->fd, buf, BUF_SIZE);
384461 if (r == -1) {
385462 zsys_error ("read from fd %d: %s", item->fd, strerror (errno));
451528 static int
452529 s_zproc_execve (zproc_t *self)
453530 {
531 assert (self);
454532 #if defined(__WINDOWS__)
455 zsys_debug ("s_zproc_execve not implemented on Windows");
456 return -1;
533 STARTUPINFOA siStartInfo;
534 ZeroMemory (&siStartInfo, sizeof (siStartInfo));
535
536 char *commandline = strdup ((char *)zlist_first (self->args));
537 char *arg = (char *) zlist_next (self->args);
538 while (arg) {
539 char *tmp = zsys_sprintf ("%s %s", commandline, arg);
540 zstr_free (&commandline);
541 commandline = tmp;
542 arg = (char *) zlist_next (self->args);
543 }
544 if (self->verbose)
545 zsys_debug ("zproc: command to start: %s", commandline);
546
547 siStartInfo.cb = sizeof (siStartInfo);
548 zsock_signal (zpair_write (self->execpair), 0);
549 self->running = CreateProcessA(
550 NULL, // app name
551 commandline, // command line
552 NULL, // process security attributes
553 NULL, // primary thread security attributes
554 TRUE, // handles are not inherited
555 0, // creation flags
556 NULL, // use parent's environment
557 NULL , // use parent's current directory
558 &siStartInfo, // STARTUPINFO pointer
559 &self->piProcInfo); // receives PROCESS_INFORMATION
560 WaitForInputIdle (self->piProcInfo.hProcess, 1000);
561 if (self->verbose)
562 zsys_debug ("zproc: %s", self->running ? "started" : "failed to start");
563 zstr_free (&commandline);
564 return 0;
457565 #else
458 assert (self);
459566 int r;
460567
461 char *filename = (char*) zlistx_first (self->args);
568 char *filename = (char*) zlist_first (self->args);
462569 self->pid = fork ();
463570 if (self->pid == 0) {
464
465 if (self->stdinpipe [0] != 0) {
571 // Child
572 if (self->stdinpipe [0] != -1) {
466573 int o_flags = fcntl (self->stdinpipe [0], F_GETFL);
467574 int n_flags = o_flags & (~O_NONBLOCK);
468575 fcntl (self->stdinpipe [0], F_SETFL, n_flags);
471578 }
472579
473580 // redirect stdout if set_stdout was called
474 if (self->stdoutpipe [0] != 0) {
581 if (self->stdoutpipe [0] != -1) {
475582 close (self->stdoutpipe [0]);
476583 dup2 (self->stdoutpipe [1], STDOUT_FILENO);
477584 }
478585
479 // redirect stdout if set_stderr was called
480 if (self->stderrpipe [0] != 0) {
586 // redirect stderr if set_stderr was called
587 if (self->stderrpipe [0] != -1) {
481588 close (self->stderrpipe [0]);
482589 dup2 (self->stderrpipe [1], STDERR_FILENO);
483590 }
484591
485592 // build argv for now and use self->args
486 char **argv2 = arr_new (zlistx_size (self->args) + 1);
593 char **argv2 = arr_new (zlist_size (self->args) + 1);
487594
488595 size_t i = 0;
489 for (char *arg = (char*) zlistx_first (self->args);
596 for (char *arg = (char*) zlist_first (self->args);
490597 arg != NULL;
491 arg = (char*) zlistx_next (self->args)) {
598 arg = (char*) zlist_next (self->args)) {
492599 arr_add_ref (argv2, i, arg);
493600 i++;
494601 }
495602 arr_add_ref (argv2, i, NULL);
496603
497604 // build environ for a new process
498 char **env = arr_new (zhashx_size (self->env) + 1);
499
500 i = 0;
501 for (char *arg = (char*) zhashx_first (self->env);
502 arg != NULL;
503 arg = (char*) zhashx_next (self->env)) {
504 char *name = (char*) zhashx_cursor (self->env);
505 arr_add_ref (env, i, zsys_sprintf ("%s=%s", name, arg));
506 i++;
507 }
508 arr_add_ref (env, i, NULL);
509
605 char **env = NULL;
606
607 if (self->env) {
608 env = arr_new (zhash_size (self->env) + 1);
609
610 i = 0;
611 for (char *arg = (char*) zhash_first (self->env);
612 arg != NULL;
613 arg = (char*) zhash_next (self->env)) {
614 char *name = (char*) zhash_cursor (self->env);
615 arr_add_ref (env, i, zsys_sprintf ("%s=%s", name, arg));
616 i++;
617 }
618 arr_add_ref (env, i, NULL);
619 }
620 else
621 env = environ;
622
623 zsock_signal (zpair_write (self->execpair), 0);
510624 r = execve (filename, argv2, env);
511625 if (r == -1) {
512626 zsys_error ("fail to run %s: %s", filename, strerror (errno));
518632 }
519633 else
520634 if (self->pid == -1) {
635 // Error (still in parent)
521636 zsys_error ("error fork: %s", strerror (errno));
522637 exit (EXIT_FAILURE);
523638 }
524639 else {
640 // Parent
525641 if (self->verbose)
526642 zsys_debug ("process %s with pid %d started", filename, self->pid);
527643
528 if (self->stdinpipe [0] != 0) {
644 if (self->stdinpipe [0] != -1) {
529645 s_zproc_addfd (self, self->stdinpipe [1], zpair_read (self->stdinpair), ZMQ_POLLOUT);
530646 close (self->stdinpipe [0]);
531647 }
532648
533649 // add a handler for read end of stdout
534 if (self->stdoutpipe [1] != 0) {
650 if (self->stdoutpipe [1] != -1) {
535651 s_zproc_addfd (self, self->stdoutpipe [0], zpair_write (self->stdoutpair), ZMQ_POLLIN);
536 close(self->stdoutpipe[1]);
652 close (self->stdoutpipe[1]);
537653 }
538654 // add a handler for read end of stderr
539 if (self->stderrpipe [1] != 0) {
655 if (self->stderrpipe [1] != -1) {
540656 s_zproc_addfd (self, self->stderrpipe [0], zpair_write (self->stderrpair), ZMQ_POLLIN);
541 close(self->stderrpipe[1]);
657 close (self->stderrpipe[1]);
542658 }
543659 }
544660
568684 }
569685
570686 s_zproc_execve (self);
687 zsock_wait (self->execpair);
688 zsock_signal (pipe, 0);
571689 }
572690
573691 end:
599717 int
600718 zproc_run (zproc_t *self)
601719 {
602 #if defined (__WINDOWS__)
603 zsys_error ("zproc not yet implemented for Windows");
604 return -1;
605 #endif
606720 assert (self);
607721 assert (!self->actor);
608722
609 if (!self->args || zlistx_size (self->args) == 0) {
723 if (!self->args || zlist_size (self->args) == 0) {
610724 zsys_error ("No arguments, nothing to run. Call zproc_set_args before");
611725 return -1;
612726 }
616730 self->return_code = ZPROC_RUNNING;
617731
618732 zstr_send (self->actor, "RUN");
733 zsock_wait (self->actor);
619734 return 0;
620735 }
621736
622737 int
623738 zproc_wait (zproc_t *self, bool wait) {
624739 #if defined (__WINDOWS__)
625 zsys_error ("zproc not yet implemented for Windows");
740 if (!self->running) {
741 if (self->verbose)
742 zsys_debug ("zproc_wait: not running");
743 return self->return_code;
744 }
745
746 uint32_t r = WaitForSingleObject (self->piProcInfo.hProcess, wait ? INFINITE : 0);
747 if (self->verbose)
748 zsys_debug ("zproc_wait [%d]:\twaitforsingleobject, r=%d", zproc_pid (self), r);
749 if (!wait && r == 0x00000102) {
750 // still running
751 return self->return_code;
752 }
753 if (r == 0) {
754 // finished
755 DWORD exitcode = 0;
756 if (!GetExitCodeProcess(self->piProcInfo.hProcess, &exitcode))
757 zsys_error ("zproc_wait: [%d]\tfailed to get exit code", zproc_pid (self));
758 self->return_code = exitcode;
759 CloseHandle (self->piProcInfo.hProcess);
760 CloseHandle (self->piProcInfo.hThread);
761 return self->return_code;
762 }
626763 return -1;
627764 #else
628765 assert (self);
647784 return self->return_code;
648785
649786 if (WIFEXITED(status)) {
650 if (self->verbose)
651 zsys_debug ("zproc_wait [%d]:\tWIFEXITED", self->pid);
652787 self->running = false;
653788 self->return_code = WEXITSTATUS(status);
789 if (self->verbose)
790 zsys_debug ("zproc_wait [%d]:\tWIFEXITED, self->return_code=%d", self->pid, self->return_code);
791 return self->return_code;
654792 }
655793 else if (WIFSIGNALED(status)) {
656 if (self->verbose)
657 zsys_debug ("zproc_wait [%d]:\tWIFSIGNALED", self->pid);
658794 self->running = false;
659795 self->return_code = - WTERMSIG(status);
796 if (self->verbose)
797 zsys_debug ("zproc_wait [%d]:\tWIFSIGNALED, self->return_code=%d", self->pid, self->return_code);
798 return self->return_code;
660799
661800 /*
662801 if (WCOREDUMP(status)) {
673812 bool
674813 zproc_running (zproc_t *self) {
675814 assert (self);
676 #if defined (__WINDOWS__)
677 zsys_debug ("zproc_running not implemented on Windows");
678 return false;
679 #else
680 assert (self->pid);
815 assert (zproc_pid (self));
681816 return zproc_wait (self, false) == ZPROC_RUNNING;
682 #endif
683817 }
684818
685819 void *
693827 zproc_kill (zproc_t *self, int signum) {
694828 assert (self);
695829 #if defined (__WINDOWS__)
696 zsys_debug ("zproc_kill not implemented on Windows");
697 return;
830 if (zproc_pid (self)) {
831 if (signum == SIGTERM) {
832 if (! TerminateProcess (self->piProcInfo.hProcess, 255))
833 zsys_error ("zproc_kill [%d]:\tTerminateProcess failed", zproc_pid (self));
834 zproc_wait (self, false);
835 } else {
836 zsys_error ("zproc_kill: [%d]:\tOnly SIGTERM is implemented on windows", zproc_pid (self));
837 }
838 }
698839 #else
699 int r = kill (self->pid, signum);
700 if (r != 0)
701 zsys_error ("kill of pid=%d failed: %s", self->pid, strerror (errno));
702 zproc_wait (self, false);
840 if (zproc_pid (self) > 0) {
841 int r = kill (self->pid, signum);
842 if (r != 0)
843 zsys_error ("kill of pid=%d failed: %s", self->pid, strerror (errno));
844 zproc_wait (self, false);
845 }
703846 #endif
704847 }
705848
708851 assert (self);
709852 self->verbose = verbose;
710853 }
711
712 // --------------------------------------------------------------------------
713 // Returns CZMQ version as a single 6-digit integer encoding the major
714 // version (x 10000), the minor version (x 100) and the patch.
715
716 int
717 zproc_czmq_version (void)
718 {
719 return CZMQ_VERSION;
720 }
721
722
723 // --------------------------------------------------------------------------
724 // Returns true if the process received a SIGINT or SIGTERM signal.
725 // It is good practice to use this method to exit any infinite loop
726 // processing messages.
727
728 bool
729 zproc_interrupted (void)
730 {
731 return zsys_interrupted == 1;
732 }
733
734 // --------------------------------------------------------------------------
735 // Returns true if the underlying libzmq supports CURVE security.
736
737 bool
738 zproc_has_curve (void)
739 {
740 return zsys_has_curve ();
741 }
742
743
744 // --------------------------------------------------------------------------
745 // Return current host name, for use in public tcp:// endpoints.
746 // If the host name is not resolvable, returns NULL. The caller is
747 // responsible for destroying the return value when finished with it.
748
749 char *
750 zproc_hostname (void)
751 {
752 return zsys_hostname ();
753 }
754
755
756 // --------------------------------------------------------------------------
757 // Move the current process into the background. The precise effect
758 // depends on the operating system. On POSIX boxes, moves to a specified
759 // working directory (if specified), closes all file handles, reopens
760 // stdin, stdout, and stderr to the null device, and sets the process to
761 // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
762 // was an error.
763
764 void
765 zproc_daemonize (const char *workdir)
766 {
767 zsys_daemonize (workdir);
768 }
769
770
771 // --------------------------------------------------------------------------
772 // Drop the process ID into the lockfile, with exclusive lock, and
773 // switch the process to the specified group and/or user. Any of the
774 // arguments may be null, indicating a no-op. Returns 0 on success,
775 // -1 on failure. Note if you combine this with zsys_daemonize, run
776 // after, not before that method, or the lockfile will hold the wrong
777 // process ID.
778
779 void
780 zproc_run_as (const char *lockfile, const char *group, const char *user)
781 {
782 zsys_run_as (lockfile, group, user);
783 }
784
785
786 // --------------------------------------------------------------------------
787 // Configure the number of I/O threads that ZeroMQ will use. A good
788 // rule of thumb is one thread per gigabit of traffic in or out. The
789 // default is 1, sufficient for most applications. If the environment
790 // variable ZSYS_IO_THREADS is defined, that provides the default.
791 // Note that this method is valid only before any socket is created.
792
793 void
794 zproc_set_io_threads (size_t io_threads)
795 {
796 zsys_set_io_threads (io_threads);
797 }
798
799
800 // --------------------------------------------------------------------------
801 // Configure the number of sockets that ZeroMQ will allow. The default
802 // is 1024. The actual limit depends on the system, and you can query it
803 // by using zsys_socket_limit (). A value of zero means "maximum".
804 // Note that this method is valid only before any socket is created.
805
806 void
807 zproc_set_max_sockets (size_t max_sockets)
808 {
809 zsys_set_max_sockets (max_sockets);
810 }
811
812
813 // --------------------------------------------------------------------------
814 // Set network interface name to use for broadcasts, particularly zbeacon.
815 // This lets the interface be configured for test environments where required.
816 // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
817 // the default when there is no specified interface. If the environment
818 // variable ZSYS_INTERFACE is set, use that as the default interface name.
819 // Setting the interface to "*" means "use all available interfaces".
820
821 void
822 zproc_set_biface (const char *value)
823 {
824 zsys_set_interface (value);
825 }
826
827
828 // --------------------------------------------------------------------------
829 // Return network interface to use for broadcasts, or "" if none was set.
830
831 const char *
832 zproc_biface (void)
833 {
834 return zsys_interface ();
835 }
836
837
838 // --------------------------------------------------------------------------
839 // Set log identity, which is a string that prefixes all log messages sent
840 // by this process. The log identity defaults to the environment variable
841 // ZSYS_LOGIDENT, if that is set.
842
843 void
844 zproc_set_log_ident (const char *value)
845 {
846 zsys_set_logident (value);
847 }
848
849
850 // --------------------------------------------------------------------------
851 // Sends log output to a PUB socket bound to the specified endpoint. To
852 // collect such log output, create a SUB socket, subscribe to the traffic
853 // you care about, and connect to the endpoint. Log traffic is sent as a
854 // single string frame, in the same format as when sent to stdout. The
855 // log system supports a single sender; multiple calls to this method will
856 // bind the same sender to multiple endpoints. To disable the sender, call
857 // this method with a null argument.
858
859 void
860 zproc_set_log_sender (const char *endpoint)
861 {
862 zsys_set_logsender (endpoint);
863 }
864
865
866 // --------------------------------------------------------------------------
867 // Enable or disable logging to the system facility (syslog on POSIX boxes,
868 // event log on Windows). By default this is disabled.
869
870 void
871 zproc_set_log_system (bool logsystem)
872 {
873 zsys_set_logsystem (logsystem);
874 }
875
876
877 // --------------------------------------------------------------------------
878 // Log error condition - highest priority
879
880 void
881 zproc_log_error (const char *format, ...)
882 {
883 va_list argptr;
884 va_start (argptr, format);
885 char *string = zsys_vprintf (format, argptr);
886 va_end (argptr);
887 zsys_error (string);
888 zstr_free (&string);
889 }
890
891
892 // --------------------------------------------------------------------------
893 // Log warning condition - high priority
894
895 void
896 zproc_log_warning (const char *format, ...)
897 {
898 va_list argptr;
899 va_start (argptr, format);
900 char *string = zsys_vprintf (format, argptr);
901 va_end (argptr);
902 zsys_warning (string);
903 zstr_free (&string);
904 }
905
906
907 // --------------------------------------------------------------------------
908 // Log normal, but significant, condition - normal priority
909
910 void
911 zproc_log_notice (const char *format, ...)
912 {
913 va_list argptr;
914 va_start (argptr, format);
915 char *string = zsys_vprintf (format, argptr);
916 va_end (argptr);
917 zsys_notice (string);
918 zstr_free (&string);
919 }
920
921
922 // --------------------------------------------------------------------------
923 // Log informational message - low priority
924
925 void
926 zproc_log_info (const char *format, ...)
927 {
928 va_list argptr;
929 va_start (argptr, format);
930 char *string = zsys_vprintf (format, argptr);
931 va_end (argptr);
932 zsys_info (string);
933 zstr_free (&string);
934 }
935
936
937 // --------------------------------------------------------------------------
938 // Log debug-level message - lowest priority
939
940 void
941 zproc_log_debug (const char *format, ...)
942 {
943 va_list argptr;
944 va_start (argptr, format);
945 char *string = zsys_vprintf (format, argptr);
946 va_end (argptr);
947 zsys_debug (string);
948 zstr_free (&string);
949 }
950
951854
952855 // --------------------------------------------------------------------------
953856 // Self test of this class.
957860 {
958861 printf (" * zproc: ");
959862
960 // @selftest
961 #if defined (__WINDOWS__)
962 printf ("SKIPPED (on Windows)\n");
963 return;
964 #endif
965863 #if ZMQ_VERSION_MAJOR < 4
966864 printf ("SKIPPED (on zmq pre-4)\n");
967865 return;
973871 return;
974872 }
975873
976 // @selftest
977874 // 0. initialization
978875
979876 if (verbose) {
980877 printf("\n");
981878 }
982879
880 #ifdef __WINDOWS__
881 # define ZSPBIN "zsp.exe"
882 #else
883 # define ZSPBIN "zsp"
884 #endif
983885 // find the right binary for current build (in-tree, distcheck, etc.)
984886 char *file = NULL;
985 if (zsys_file_exists ("src/zsp") || zsys_file_exists ("./src/zsp"))
986 file = "./src/zsp";
987 else
988 if (zsys_file_exists ("../zsp"))
887 if (zsys_file_exists ("src/" ZSPBIN) || zsys_file_exists ("./src/" ZSPBIN))
888 file = "./src/" ZSPBIN;
889 else
890 if (zsys_file_exists ("../" ZSPBIN))
989891 // WHOA: zproc: zproc_test() : current working directory is
990892 // /home/travis/build/username/czmq/czmq-4.0.3/_build/src/selftest-rw
991893 file = "../zsp";
992894 else
993 if (zsys_file_exists ("_build/../src/zsp"))
994 file = "_build/../src/zsp";
995 else
996 if (zsys_file_exists ("_build/src/zsp"))
997 file = "_build/src/zsp";
998 else
999 if (zsys_file_exists ("../_build/src/zsp"))
1000 file = "../_build/src/zsp";
1001 else
1002 if (zsys_file_exists ("../../_build/src/zsp"))
1003 file = "../../_build/src/zsp";
1004 else
1005 if (zsys_file_exists ("_build/sub/src/zsp"))
1006 file = "_build/sub/src/zsp";
1007 else
1008 if (zsys_file_exists ("../_build/sub/src/zsp"))
1009 file = "../_build/sub/src/zsp";
1010 else
1011 if (zsys_file_exists ("../../_build/sub/src/zsp"))
1012 file = "../../_build/sub/src/zsp";
1013 else
1014 if (zsys_file_exists ("zsp") || zsys_file_exists ("./zsp"))
1015 file = "./zsp";
1016 else
1017 if (zsys_file_exists ("../src/zsp"))
1018 file = "../src/zsp";
895 if (zsys_file_exists ("_build/../src/" ZSPBIN))
896 file = "_build/../src/" ZSPBIN;
897 else
898 if (zsys_file_exists ("_build/src/" ZSPBIN))
899 file = "_build/src/" ZSPBIN;
900 else
901 if (zsys_file_exists ("../_build/src/" ZSPBIN))
902 file = "../_build/src/" ZSPBIN;
903 else
904 if (zsys_file_exists ("../../_build/src/" ZSPBIN))
905 file = "../../_build/src/" ZSPBIN;
906 else
907 if (zsys_file_exists ("_build/sub/src/" ZSPBIN))
908 file = "_build/sub/src/" ZSPBIN;
909 else
910 if (zsys_file_exists ("../_build/sub/src/" ZSPBIN))
911 file = "../_build/sub/src/" ZSPBIN;
912 else
913 if (zsys_file_exists ("../../_build/sub/src/" ZSPBIN))
914 file = "../../_build/sub/src/" ZSPBIN;
915 else
916 if (zsys_file_exists ("" ZSPBIN) || zsys_file_exists ("./" ZSPBIN))
917 file = "./" ZSPBIN;
918 else
919 if (zsys_file_exists ("../src/" ZSPBIN))
920 file = "../src/" ZSPBIN;
1019921
1020922 if (file == NULL || !zsys_file_exists (file)) {
1021923 zsys_warning ("cannot detect zsp binary, %s does not exist", file ? file : "<null>");
1022924
1023925 printf ("SKIPPED (zsp helper not found)\n");
1024
1025 #if (defined (PATH_MAX))
1026 char cwd[PATH_MAX];
1027 #else
1028 # if (defined (_MAX_PATH))
1029 char cwd[_MAX_PATH];
1030 # else
1031 char cwd[1024];
1032 # endif
1033 #endif
926 char cwd [PATH_MAX];
1034927 memset (cwd, 0, sizeof (cwd));
1035 #if (defined (WIN32))
1036 if (_getcwd(cwd, sizeof(cwd)) != NULL)
1037 #else
1038928 if (getcwd(cwd, sizeof(cwd)) != NULL)
1039 #endif
1040929 printf ("zproc_test() : current working directory is %s\n", cwd);
1041930
1042931 return;
1045934 zsys_info ("zproc_test() : detected a zsp binary at %s\n", file);
1046935 }
1047936
1048 // Create new subproc instance
937 // @selftest
938
939 // variable file contains path to zsp executable:
940 // char *file = "path/to/zsp";
941
942 #if defined (__WINDOWS__)
943 printf ("Very limited (on Windows) ");
944 {
945 zsys_init ();
946 zproc_t *self = zproc_new ();
947 assert (self);
948
949 zproc_set_verbose (self, verbose);
950 zproc_set_argsx (self, file, "-v", NULL);
951 zproc_run (self);
952 zclock_sleep (100); // to let actor start the process
953 assert (zproc_pid (self));
954
955 zproc_kill (self, SIGTERM);
956 assert (zproc_returncode (self) == 255);
957 zproc_destroy (&self);
958 }
959 printf ("OK\n");
960 return;
961 #endif
962 // Test case #1: run command, wait until it ends and get the (stdandard) output
1049963 zproc_t *self = zproc_new ();
964 assert (self);
965 zproc_set_verbose (self, verbose);
966
967 // join stdout of the process to zeromq socket
968 // all data will be readable from zproc_stdout socket
969 assert (!zproc_stdout (self));
970 zproc_set_stdout (self, NULL);
971 assert (zproc_stdout (self));
972
973 zproc_set_argsx (self, file, "--help", NULL);
974
975 if (verbose)
976 zsys_debug("zproc_test() : launching helper '%s' --help", file );
977
978 int r = zproc_run (self);
979 assert (r == 0);
980 zframe_t *frame;
981 zsock_brecv (zproc_stdout (self), "f", &frame);
982 assert (frame);
983 assert (zframe_data (frame));
984 // TODO: real test
985 if (verbose)
986 zframe_print (frame, "1:");
987 zframe_destroy (&frame);
988 r = zproc_wait (self, true);
989 assert (r == 0);
990 zproc_destroy (&self);
991
992 // Test case #2: use never ending subprocess and poller to read data from it
993 // Create new zproc instance
994 self = zproc_new ();
1050995 zproc_set_verbose (self, verbose);
1051996 assert (self);
1052997 // join stdout of the process to zeromq socket
1053998 // all data will be readable from zproc_stdout socket
1054999 zproc_set_stdout (self, NULL);
10551000
1056 zlistx_t *args = zlistx_new ();
1057 zlistx_add_end (args, file);
1058 zlistx_add_end (args, "--stdout");
1059 zproc_set_args (self, args);
1060
1061 zhashx_t *env = zhashx_new ();
1062 zhashx_insert (env, "ZSP_MESSAGE", "czmq is great\n");
1063 zproc_set_env (self, env);
1001 zlist_t *args = zlist_new ();
1002 zlist_autofree (args);
1003 zlist_append (args, file);
1004 zlist_append (args, "--stdout");
1005 zproc_set_args (self, &args);
1006
1007 zhash_t *env = zhash_new ();
1008 zhash_autofree (env);
1009 zhash_insert (env, "ZSP_MESSAGE", "czmq is great\n");
1010 zproc_set_env (self, &env);
10641011
10651012 // execute the binary. It runs in own actor, which monitor the process and
10661013 // pass data accross pipes and zeromq sockets
559559 sink = zsock_new_sub(">inproc://backend", "whatever");
560560 #else
561561 // vagrant vms don't like using shared storage for ipc pipes..
562 if (streq(getenv("USER"), "vagrant"))
562 if (getenv("USER") && streq(getenv("USER"), "vagrant"))
563563 sink = zsock_new_sub (">ipc:///tmp/backend", "whatever");
564564 else
565565 sink = zsock_new_sub (">ipc://backend", "whatever");
570570 zstr_sendx (proxy, "BACKEND", "XPUB", "inproc://backend", NULL);
571571 #else
572572 // vagrant vms don't like using shared storage for ipc pipes..
573 if (streq(getenv("USER"), "vagrant"))
573 if (getenv("USER") && streq(getenv("USER"), "vagrant"))
574574 zstr_sendx(proxy, "BACKEND", "XPUB", "ipc:///tmp/backend", NULL);
575575 else
576576 zstr_sendx(proxy, "BACKEND", "XPUB", "ipc://backend", NULL);
2727
2828 // zsock_t instances always have this tag as the first 4 octets of
2929 // their data, which lets us do runtime object typing & validation.
30 #define ZSOCK_TAG 0x0004cafe
30 #define ZSOCK_TAG 0xcafe0004
3131
3232 // This port range is defined by IANA for dynamic or private ports
3333 // We use this when choosing a port for dynamic binding.
297297 zsock_destroy (&sock);
298298 return sock;
299299 #else
300 // errno = ENOTSUP; // too late, stable API would be broken
300301 return NULL; // Not implemented
301302 #endif
302303 }
320321 zsock_destroy (&sock);
321322 return sock;
322323 #else
324 // errno = ENOTSUP; // too late, stable API would be broken
323325 return NULL; // Not implemented
324326 #endif
325327 }
362364 zsock_destroy (&sock);
363365 return sock;
364366 #else
367 // errno = ENOTSUP; // too late, stable API would be broken
365368 return NULL; // Not implemented
366369 #endif
367370 }
384387 zsock_destroy (&sock);
385388 return sock;
386389 #else
390 errno = ENOTSUP;
387391 return NULL;
388392 #endif
389393 }
406410 zsock_destroy (&sock);
407411 return sock;
408412 #else
413 errno = ENOTSUP;
409414 return NULL;
410415 #endif
411416 }
429434 zsock_destroy (&sock);
430435 return sock;
431436 #else
437 errno = ENOTSUP;
432438 return NULL;
433439 #endif
434440 }
452458 zsock_destroy (&sock);
453459 return sock;
454460 #else
461 errno = ENOTSUP;
455462 return NULL;
456463 #endif
457464 }
475482 zsock_destroy (&sock);
476483 return sock;
477484 #else
485 errno = ENOTSUP;
478486 return NULL;
479487 #endif
480488 }
498506 zsock_destroy (&sock);
499507 return sock;
500508 #else
509 errno = ENOTSUP;
501510 return NULL;
502511 #endif
503512 }
17351744 #ifdef ZMQ_DISH
17361745 return zmq_join (zsock_resolve (self), group);
17371746 #else
1738 errno = EINVAL;
1747 errno = ENOTSUP;
17391748 return -1;
17401749 #endif
17411750 }
17521761 #ifdef ZMQ_DISH
17531762 return zmq_leave (zsock_resolve (self), group);
17541763 #else
1755 errno = EINVAL;
1764 errno = ENOTSUP;
17561765 return -1;
17571766 #endif
17581767 }
19111920 assert (port >= 60000 && port <= 60500);
19121921
19131922 // Test zsock_attach method
1914 zsock_t *server = zsock_new (ZMQ_DEALER);
1915 assert (server);
1916 rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:*,inproc://others", true);
1923 zsock_t *dealer = zsock_new (ZMQ_DEALER);
1924 assert (dealer);
1925 rc = zsock_attach (dealer, "@inproc://myendpoint,tcp://127.0.0.1:*,inproc://others", true);
19171926 assert (rc == 0);
1918 rc = zsock_attach (server, "", false);
1927 rc = zsock_attach (dealer, "", false);
19191928 assert (rc == 0);
1920 rc = zsock_attach (server, NULL, true);
1929 rc = zsock_attach (dealer, NULL, true);
19211930 assert (rc == 0);
1922 rc = zsock_attach (server, ">a,@b, c,, ", false);
1931 rc = zsock_attach (dealer, ">a,@b, c,, ", false);
19231932 assert (rc == -1);
1924 zsock_destroy (&server);
1933 zsock_destroy (&dealer);
19251934
19261935 // Test zsock_endpoint method
19271936 rc = zsock_bind (writer, "inproc://test.%s", "writer");
20982107 #ifdef ZMQ_SERVER
20992108
21002109 // Test zsock_bsend/brecv pictures with binary encoding on SERVER and CLIENT sockets
2101 server = zsock_new (ZMQ_SERVER);
2110 zsock_t *server = zsock_new (ZMQ_SERVER);
21022111 assert (server);
21032112 port = zsock_bind (server, "tcp://127.0.0.1:*");
21042113 assert (port != -1);
21642173 zsock_destroy (&client);
21652174 zsock_destroy (&server);
21662175
2176 #else
2177 errno = 0;
2178 zsock_t* server = zsock_new_server (NULL);
2179 assert(server == NULL);
2180 assert(errno == ENOTSUP);
2181
2182 errno = 0;
2183 zsock_t* client = zsock_new_client (NULL);
2184 assert(client == NULL);
2185 assert(errno == ENOTSUP);
21672186 #endif
21682187
21692188 #ifdef ZMQ_SCATTER
21832202
21842203 zsock_destroy (&gather);
21852204 zsock_destroy (&scatter);
2186
2205 #else
2206 errno = 0;
2207 zsock_t* scatter = zsock_new_scatter (NULL);
2208 assert(scatter == NULL);
2209 assert(errno == ENOTSUP);
2210
2211 errno = 0;
2212 zsock_t* gather = zsock_new_gather (NULL);
2213 assert(gather == NULL);
2214 assert(errno == ENOTSUP);
2215 #endif
2216
2217 #ifndef ZMQ_RADIO
2218 errno = 0;
2219 zsock_t* radio = zsock_new_radio (NULL);
2220 assert(radio == NULL);
2221 assert(errno == ENOTSUP);
2222
2223 errno = 0;
2224 zsock_t* dish = zsock_new_dish (NULL);
2225 assert(dish == NULL);
2226 assert(errno == ENOTSUP);
2227
2228 errno = 0;
2229 zsock_t* sock = zsock_new_req (NULL); // any supported socket type
2230 rc = zsock_join (sock, "group1");
2231 assert(rc == -1);
2232 assert(errno == ENOTSUP);
2233 errno = 0;
2234 rc = zsock_leave (sock, "group1");
2235 assert(rc == -1);
2236 assert(errno == ENOTSUP);
2237 zsock_destroy (&sock);
21872238 #endif
21882239
21892240 // Check that we can send a zproto format message
9898 static FILE *s_logstream = NULL; // ZSYS_LOGSTREAM=stdout/stderr
9999 static bool s_logsystem = false; // ZSYS_LOGSYSTEM=true/false
100100 static zsock_t *s_logsender = NULL; // ZSYS_LOGSENDER=
101 static int s_zero_copy_recv = 1; // ZSYS_ZERO_COPY_RECV=1
101102
102103 // Track number of open sockets so we can zmq_term() safely
103104 static size_t s_open_sockets = 0;
156157 if (getenv ("ZSYS_MAX_MSGSZ"))
157158 s_max_msgsz = atoi (getenv ("ZSYS_MAX_MSGSZ"));
158159
160 if (getenv ("ZSYS_ZERO_COPY_RECV"))
161 s_zero_copy_recv = atoi (getenv ("ZSYS_ZERO_COPY_RECV"));
162
159163 if (getenv ("ZSYS_FILE_STABLE_AGE_MSEC"))
160164 s_file_stable_age_msec = atoi (getenv ("ZSYS_FILE_STABLE_AGE_MSEC"));
161165
204208 return NULL;
205209 }
206210 srandom ((unsigned) time (NULL));
207 atexit (zsys_shutdown);
208211
209212 assert (!s_process_ctx);
210213 // We use zmq_init/zmq_term to keep compatibility back to ZMQ v2
214217 #endif
215218 s_initialized = true;
216219
220 atexit (zsys_shutdown);
221
217222 // The following functions call zsys_init(), so they MUST be called after
218223 // s_initialized is set in order to avoid an infinite recursion
219224 if (getenv ("ZSYS_INTERFACE"))
235240 zsys_set_logsender (getenv ("ZSYS_LOGSENDER"));
236241
237242 zsys_set_max_msgsz (s_max_msgsz);
243
244 #if defined ZMQ_ZERO_COPY_RECV
245 zmq_ctx_set (s_process_ctx, ZMQ_ZERO_COPY_RECV, s_zero_copy_recv);
246 #endif
238247
239248 zsys_set_file_stable_age_msec (s_file_stable_age_msec);
240249
14901499 ZMUTEX_UNLOCK (s_mutex);
14911500 }
14921501
1502 // --------------------------------------------------------------------------
1503 // Configure whether to use zero copy strategy in libzmq. If the environment
1504 // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
1505 // Otherwise the default is 1.
1506
1507 void
1508 zsys_set_zero_copy_recv(int zero_copy)
1509 {
1510 zsys_init ();
1511 ZMUTEX_LOCK (s_mutex);
1512 s_zero_copy_recv = zero_copy;
1513 #if defined (ZMQ_ZERO_COPY_RECV)
1514 zmq_ctx_set (s_process_ctx, ZMQ_ZERO_COPY_RECV, s_zero_copy_recv);
1515 #endif
1516 ZMUTEX_UNLOCK (s_mutex);
1517 }
1518
1519 // --------------------------------------------------------------------------
1520 // Return ZMQ_ZERO_COPY_RECV option.
1521 int
1522 zsys_zero_copy_recv()
1523 {
1524 zsys_init ();
1525 ZMUTEX_LOCK (s_mutex);
1526 #if defined (ZMQ_ZERO_COPY_RECV)
1527 s_zero_copy_recv = zmq_ctx_get (s_process_ctx, ZMQ_ZERO_COPY_RECV);
1528 #endif
1529 ZMUTEX_UNLOCK (s_mutex);
1530 return s_zero_copy_recv;
1531 }
1532
14931533
14941534 // --------------------------------------------------------------------------
14951535 // Return maximum message size.
15061546 return s_max_msgsz;
15071547 }
15081548
1549
1550 // --------------------------------------------------------------------------
1551 // *** Draft method, for development use, may change without warning ***
1552 // Check if default interrupt handler of Ctrl-C or SIGTERM was called.
1553 // Does not work if ZSYS_SIGHANDLER is false and code does not call
1554 // set interrupted on signal.
1555 bool
1556 zsys_is_interrupted (void)
1557 {
1558 return zsys_interrupted != 0;
1559 }
1560
1561 // --------------------------------------------------------------------------
1562 // *** Draft method, for development use, may change without warning ***
1563 // Set interrupted flag. This is done by default signal handler, however
1564 // this can be handy for language bindings or cases without default
1565 // signal handler.
1566 void
1567 zsys_set_interrupted (void)
1568 {
1569 zctx_interrupted = 1;
1570 zsys_interrupted = 1;
1571 }
15091572
15101573 // --------------------------------------------------------------------------
15111574 // Configure the threshold value of filesystem object age per st_mtime
19852048 zstr_free (&string);
19862049 }
19872050
1988
19892051 // --------------------------------------------------------------------------
19902052 // Selftest
19912053
20172079 freen (hostname);
20182080 zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ());
20192081 }
2082 #ifdef CZMQ_BUILD_DRAFT_API
20202083 zsys_set_file_stable_age_msec (5123);
20212084 assert (zsys_file_stable_age_msec() == 5123);
20222085 zsys_set_file_stable_age_msec (-1);
20232086 assert (zsys_file_stable_age_msec() == 5123);
2087 #endif // CZMQ_BUILD_DRAFT_API
20242088 zsys_set_linger (0);
20252089 zsys_set_sndhwm (1000);
20262090 zsys_set_rcvhwm (1000);
20292093 zsys_set_ipv6 (0);
20302094 zsys_set_thread_priority (-1);
20312095 zsys_set_thread_sched_policy (-1);
2096 zsys_set_zero_copy_recv(0);
2097 assert (0 == zsys_zero_copy_recv());
2098 zsys_set_zero_copy_recv(1);
2099 assert (1 == zsys_zero_copy_recv());
20322100
20332101 // Test pipe creation
20342102 zsock_t *pipe_back;
4646 assert (sizeof (uuid) == ZUUID_LEN);
4747 UuidCreate (&uuid);
4848 zuuid_set (self, (byte *) &uuid);
49 #elif defined (HAVE_UUID)
49 #elif defined (HAVE_UUID) && !defined (__UTYPE_FREEBSD)
5050 uuid_t uuid;
5151 assert (sizeof (uuid) == ZUUID_LEN);
5252 uuid_generate (uuid);
212212 if (!self->str_canonical)
213213 self->str_canonical = (char *) zmalloc (8 + 4 + 4 + 4 + 12 + 5);
214214 *self->str_canonical = 0;
215 strncat (self->str_canonical, self->str, 8);
216 strcat (self->str_canonical, "-");
217 strncat (self->str_canonical, self->str + 8, 4);
218 strcat (self->str_canonical, "-");
219 strncat (self->str_canonical, self->str + 12, 4);
220 strcat (self->str_canonical, "-");
221 strncat (self->str_canonical, self->str + 16, 4);
222 strcat (self->str_canonical, "-");
223 strncat (self->str_canonical, self->str + 20, 12);
215 memcpy (self->str_canonical, self->str, 8);
216 self->str_canonical[8] = '-';
217 memcpy (self->str_canonical + 9, self->str + 8, 4);
218 self->str_canonical[13] = '-';
219 memcpy (self->str_canonical + 14, self->str + 12, 4);
220 self->str_canonical[18] = '-';
221 memcpy (self->str_canonical + 19, self->str + 16, 4);
222 self->str_canonical[23] = '-';
223 memcpy (self->str_canonical + 24, self->str + 20, 12);
224 self->str_canonical[36] = '\0';
224225
225226 int char_nbr;
226227 for (char_nbr = 0; char_nbr < 36; char_nbr++)