laag-libczmq 4.1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (697) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +57 -0
  3. data/LICENSE.txt +373 -0
  4. data/README.org +34 -0
  5. data/ext/laag/libczmq/extconf.rb +24 -0
  6. data/laag-libczmq.gemspec +21 -0
  7. data/lib/laag/libczmq.rb +30 -0
  8. data/vendor/github.com/zeromq/czmq/.editorconfig +19 -0
  9. data/vendor/github.com/zeromq/czmq/.gitattributes +5 -0
  10. data/vendor/github.com/zeromq/czmq/.github/PULL_REQUEST_TEMPLATE.md +28 -0
  11. data/vendor/github.com/zeromq/czmq/.gitignore +137 -0
  12. data/vendor/github.com/zeromq/czmq/.travis.yml +126 -0
  13. data/vendor/github.com/zeromq/czmq/AUTHORS +69 -0
  14. data/vendor/github.com/zeromq/czmq/CMakeLists.txt +653 -0
  15. data/vendor/github.com/zeromq/czmq/CONTRIBUTING.md +19 -0
  16. data/vendor/github.com/zeromq/czmq/Dockerfile +29 -0
  17. data/vendor/github.com/zeromq/czmq/Findlibsodium.cmake +47 -0
  18. data/vendor/github.com/zeromq/czmq/Findlibzmq.cmake +49 -0
  19. data/vendor/github.com/zeromq/czmq/Findlz4.cmake +49 -0
  20. data/vendor/github.com/zeromq/czmq/Findsystemd.cmake +49 -0
  21. data/vendor/github.com/zeromq/czmq/Finduuid.cmake +49 -0
  22. data/vendor/github.com/zeromq/czmq/INSTALL.cygwin +13 -0
  23. data/vendor/github.com/zeromq/czmq/ISSUES.cygwin +6 -0
  24. data/vendor/github.com/zeromq/czmq/Jenkinsfile +439 -0
  25. data/vendor/github.com/zeromq/czmq/LICENSE +373 -0
  26. data/vendor/github.com/zeromq/czmq/Makefile.am +70 -0
  27. data/vendor/github.com/zeromq/czmq/NEWS +823 -0
  28. data/vendor/github.com/zeromq/czmq/README.cygwin +23 -0
  29. data/vendor/github.com/zeromq/czmq/README.md +9345 -0
  30. data/vendor/github.com/zeromq/czmq/README.txt +512 -0
  31. data/vendor/github.com/zeromq/czmq/Vagrantfile +49 -0
  32. data/vendor/github.com/zeromq/czmq/acinclude.m4 +7 -0
  33. data/vendor/github.com/zeromq/czmq/api/zactor.api +77 -0
  34. data/vendor/github.com/zeromq/czmq/api/zargs.api +110 -0
  35. data/vendor/github.com/zeromq/czmq/api/zarmour.api +103 -0
  36. data/vendor/github.com/zeromq/czmq/api/zcert.api +128 -0
  37. data/vendor/github.com/zeromq/czmq/api/zcertstore.api +80 -0
  38. data/vendor/github.com/zeromq/czmq/api/zchunk.api +171 -0
  39. data/vendor/github.com/zeromq/czmq/api/zclock.api +43 -0
  40. data/vendor/github.com/zeromq/czmq/api/zconfig.api +205 -0
  41. data/vendor/github.com/zeromq/czmq/api/zdigest.api +45 -0
  42. data/vendor/github.com/zeromq/czmq/api/zdir.api +124 -0
  43. data/vendor/github.com/zeromq/czmq/api/zdir_patch.api +62 -0
  44. data/vendor/github.com/zeromq/czmq/api/zfile.api +157 -0
  45. data/vendor/github.com/zeromq/czmq/api/zframe.api +157 -0
  46. data/vendor/github.com/zeromq/czmq/api/zgossip_msg.api +104 -0
  47. data/vendor/github.com/zeromq/czmq/api/zhash.api +184 -0
  48. data/vendor/github.com/zeromq/czmq/api/zhashx.api +295 -0
  49. data/vendor/github.com/zeromq/czmq/api/ziflist.api +73 -0
  50. data/vendor/github.com/zeromq/czmq/api/zlist.api +158 -0
  51. data/vendor/github.com/zeromq/czmq/api/zlistx.api +220 -0
  52. data/vendor/github.com/zeromq/czmq/api/zloop.api +176 -0
  53. data/vendor/github.com/zeromq/czmq/api/zmsg.api +250 -0
  54. data/vendor/github.com/zeromq/czmq/api/zpoller.api +71 -0
  55. data/vendor/github.com/zeromq/czmq/api/zproc.api +247 -0
  56. data/vendor/github.com/zeromq/czmq/api/zsock.api +412 -0
  57. data/vendor/github.com/zeromq/czmq/api/zsock_option.api +847 -0
  58. data/vendor/github.com/zeromq/czmq/api/zstr.api +119 -0
  59. data/vendor/github.com/zeromq/czmq/api/zsys.api +490 -0
  60. data/vendor/github.com/zeromq/czmq/api/ztimerset.api +69 -0
  61. data/vendor/github.com/zeromq/czmq/api/ztrie.api +80 -0
  62. data/vendor/github.com/zeromq/czmq/api/zuuid.api +82 -0
  63. data/vendor/github.com/zeromq/czmq/appveyor.yml +73 -0
  64. data/vendor/github.com/zeromq/czmq/autogen.sh +52 -0
  65. data/vendor/github.com/zeromq/czmq/bindings/jni/.gitignore +8 -0
  66. data/vendor/github.com/zeromq/czmq/bindings/jni/CMakeLists.txt +79 -0
  67. data/vendor/github.com/zeromq/czmq/bindings/jni/Findczmq.cmake +47 -0
  68. data/vendor/github.com/zeromq/czmq/bindings/jni/README.md +130 -0
  69. data/vendor/github.com/zeromq/czmq/bindings/jni/android/CMakeLists.txt +79 -0
  70. data/vendor/github.com/zeromq/czmq/bindings/jni/android/android_toolchain.cmake +52 -0
  71. data/vendor/github.com/zeromq/czmq/bindings/jni/android/build.sh +68 -0
  72. data/vendor/github.com/zeromq/czmq/bindings/jni/build.gradle +151 -0
  73. data/vendor/github.com/zeromq/czmq/bindings/jni/ci_build.sh +96 -0
  74. data/vendor/github.com/zeromq/czmq/bindings/jni/gradle/wrapper/gradle-wrapper.jar +0 -0
  75. data/vendor/github.com/zeromq/czmq/bindings/jni/gradle/wrapper/gradle-wrapper.properties +6 -0
  76. data/vendor/github.com/zeromq/czmq/bindings/jni/gradlew +164 -0
  77. data/vendor/github.com/zeromq/czmq/bindings/jni/gradlew.bat +90 -0
  78. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/.gitignore +8 -0
  79. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/configure.bat +93 -0
  80. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/platform.h +1 -0
  81. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Common.props +21 -0
  82. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DLL.props +16 -0
  83. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Debug.props +29 -0
  84. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DebugDEXE.props +21 -0
  85. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DebugDLL.props +20 -0
  86. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DebugLEXE.props +20 -0
  87. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DebugLIB.props +21 -0
  88. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DebugLTCG.props +20 -0
  89. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/DebugSEXE.props +21 -0
  90. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/EXE.props +17 -0
  91. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/LIB.props +16 -0
  92. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/LTCG.props +13 -0
  93. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Link.props +21 -0
  94. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Messages.props +15 -0
  95. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Output.props +30 -0
  96. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Release.props +41 -0
  97. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/ReleaseDEXE.props +20 -0
  98. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/ReleaseDLL.props +19 -0
  99. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/ReleaseLEXE.props +20 -0
  100. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/ReleaseLIB.props +19 -0
  101. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/ReleaseLTCG.props +19 -0
  102. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/ReleaseSEXE.props +20 -0
  103. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/Win32.props +20 -0
  104. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/properties/x64.props +23 -0
  105. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/resource.h +14 -0
  106. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/resource.rc +94 -0
  107. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2010/build.bat +48 -0
  108. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2010/call_javah.bat +84 -0
  109. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2010/czmq.sln +25 -0
  110. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2010/libczmqjni/libczmqjni.props +69 -0
  111. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2010/libczmqjni/libczmqjni.vcxproj +165 -0
  112. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2010/libczmqjni/libczmqjni.vcxproj.filters +210 -0
  113. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2012/build.bat +48 -0
  114. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2012/call_javah.bat +84 -0
  115. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2012/czmq.sln +25 -0
  116. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2012/libczmqjni/libczmqjni.props +69 -0
  117. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2012/libczmqjni/libczmqjni.vcxproj +165 -0
  118. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2012/libczmqjni/libczmqjni.vcxproj.filters +210 -0
  119. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2013/build.bat +48 -0
  120. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2013/call_javah.bat +84 -0
  121. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2013/czmq.sln +25 -0
  122. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2013/libczmqjni/libczmqjni.props +69 -0
  123. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2013/libczmqjni/libczmqjni.vcxproj +165 -0
  124. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2013/libczmqjni/libczmqjni.vcxproj.filters +210 -0
  125. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2015/build.bat +48 -0
  126. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2015/call_javah.bat +84 -0
  127. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2015/czmq.sln +25 -0
  128. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2015/libczmqjni/libczmqjni.props +69 -0
  129. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2015/libczmqjni/libczmqjni.vcxproj +165 -0
  130. data/vendor/github.com/zeromq/czmq/bindings/jni/msvc/vs2015/libczmqjni/libczmqjni.vcxproj.filters +210 -0
  131. data/vendor/github.com/zeromq/czmq/bindings/jni/settings.gradle +1 -0
  132. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zarmour.c +132 -0
  133. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zcert.c +188 -0
  134. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zcertstore.c +69 -0
  135. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zchunk.c +191 -0
  136. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zclock.c +54 -0
  137. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zconfig.c +252 -0
  138. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zdigest.c +66 -0
  139. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zdir.c +116 -0
  140. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_ZdirPatch.c +88 -0
  141. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zfile.c +186 -0
  142. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zframe.c +199 -0
  143. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zhash.c +174 -0
  144. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zhashx.c +175 -0
  145. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Ziflist.c +112 -0
  146. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zlist.c +135 -0
  147. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zlistx.c +189 -0
  148. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zloop.c +95 -0
  149. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zmsg.c +261 -0
  150. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zpoller.c +74 -0
  151. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zproc.c +278 -0
  152. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zsock.c +1310 -0
  153. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zstr.c +108 -0
  154. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zsys.c +445 -0
  155. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Ztimerset.c +68 -0
  156. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Ztrie.c +86 -0
  157. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/c/org_zeromq_czmq_Zuuid.c +125 -0
  158. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zarmour.java +148 -0
  159. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zcert.java +178 -0
  160. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zcertstore.java +94 -0
  161. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zchunk.java +204 -0
  162. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zclock.java +67 -0
  163. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zconfig.java +253 -0
  164. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zdigest.java +78 -0
  165. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zdir.java +159 -0
  166. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/ZdirPatch.java +96 -0
  167. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zfile.java +217 -0
  168. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zframe.java +212 -0
  169. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zhash.java +223 -0
  170. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zhashx.java +248 -0
  171. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Ziflist.java +124 -0
  172. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zlist.java +171 -0
  173. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zlistx.java +247 -0
  174. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zloop.java +134 -0
  175. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zmsg.java +308 -0
  176. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zpoller.java +105 -0
  177. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zproc.java +331 -0
  178. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zsock.java +1556 -0
  179. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zstr.java +117 -0
  180. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java +534 -0
  181. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Ztimerset.java +87 -0
  182. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Ztrie.java +102 -0
  183. data/vendor/github.com/zeromq/czmq/bindings/jni/src/main/java/org/zeromq/czmq/Zuuid.java +127 -0
  184. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZarmourTest.java +25 -0
  185. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZcertTest.java +25 -0
  186. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZcertstoreTest.java +25 -0
  187. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZchunkTest.java +25 -0
  188. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZclockTest.java +25 -0
  189. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZconfigTest.java +25 -0
  190. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZdigestTest.java +25 -0
  191. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZdirPatchTest.java +25 -0
  192. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZdirTest.java +25 -0
  193. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZfileTest.java +25 -0
  194. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZframeTest.java +25 -0
  195. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZhashTest.java +25 -0
  196. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZhashxTest.java +25 -0
  197. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZiflistTest.java +25 -0
  198. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZlistTest.java +25 -0
  199. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZlistxTest.java +25 -0
  200. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZloopTest.java +25 -0
  201. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZmsgTest.java +25 -0
  202. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZpollerTest.java +25 -0
  203. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZprocTest.java +25 -0
  204. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZsockTest.java +25 -0
  205. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZstrTest.java +25 -0
  206. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZsysTest.java +25 -0
  207. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZtimersetTest.java +25 -0
  208. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZtrieTest.java +25 -0
  209. data/vendor/github.com/zeromq/czmq/bindings/jni/src/test/java/org/zeromq/czmq/ZuuidTest.java +25 -0
  210. data/vendor/github.com/zeromq/czmq/bindings/lua_ffi/czmq_ffi.lua +4079 -0
  211. data/vendor/github.com/zeromq/czmq/bindings/nodejs/.gitignore +10 -0
  212. data/vendor/github.com/zeromq/czmq/bindings/nodejs/.prebuildrc +2 -0
  213. data/vendor/github.com/zeromq/czmq/bindings/nodejs/README.md +4373 -0
  214. data/vendor/github.com/zeromq/czmq/bindings/nodejs/binding.cc +8324 -0
  215. data/vendor/github.com/zeromq/czmq/bindings/nodejs/binding.gyp +49 -0
  216. data/vendor/github.com/zeromq/czmq/bindings/nodejs/binding.h +952 -0
  217. data/vendor/github.com/zeromq/czmq/bindings/nodejs/build.sh +79 -0
  218. data/vendor/github.com/zeromq/czmq/bindings/nodejs/index.js +39 -0
  219. data/vendor/github.com/zeromq/czmq/bindings/nodejs/package.json +26 -0
  220. data/vendor/github.com/zeromq/czmq/bindings/nodejs/test_binding.js +32 -0
  221. data/vendor/github.com/zeromq/czmq/bindings/python/ci_build.sh +59 -0
  222. data/vendor/github.com/zeromq/czmq/bindings/python/czmq/__init__.py +3 -0
  223. data/vendor/github.com/zeromq/czmq/bindings/python/czmq/_czmq_ctypes.py +8344 -0
  224. data/vendor/github.com/zeromq/czmq/bindings/python/test.py +1078 -0
  225. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/README.md +28 -0
  226. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zactor.py +78 -0
  227. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zargs.py +133 -0
  228. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zarmour.py +124 -0
  229. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zcert.py +132 -0
  230. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zcertstore.py +84 -0
  231. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zchunk.py +192 -0
  232. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zclock.py +59 -0
  233. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zconfig.py +211 -0
  234. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zdigest.py +64 -0
  235. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zdir.py +144 -0
  236. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/ZdirPatch.py +79 -0
  237. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zfile.py +185 -0
  238. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zframe.py +160 -0
  239. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zhash.py +197 -0
  240. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zhashx.py +271 -0
  241. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Ziflist.py +103 -0
  242. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zlist.py +176 -0
  243. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zlistx.py +235 -0
  244. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zloop.py +171 -0
  245. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zmsg.py +250 -0
  246. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zpoller.py +89 -0
  247. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zproc.py +287 -0
  248. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zsock.py +1283 -0
  249. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zstr.py +123 -0
  250. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zsys.py +532 -0
  251. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Ztimerset.py +78 -0
  252. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Ztrie.py +93 -0
  253. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/Zuuid.py +100 -0
  254. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/__init__.py +33 -0
  255. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/_cdefs.inc +4081 -0
  256. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/build.py +345 -0
  257. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/cdefs.py +4086 -0
  258. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/dlopen.py +33 -0
  259. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/czmq_cffi/utils.py +50 -0
  260. data/vendor/github.com/zeromq/czmq/bindings/python_cffi/setup.py +23 -0
  261. data/vendor/github.com/zeromq/czmq/bindings/qml/.gitignore +1 -0
  262. data/vendor/github.com/zeromq/czmq/bindings/qml/README.md +157 -0
  263. data/vendor/github.com/zeromq/czmq/bindings/qml/Rakefile +34 -0
  264. data/vendor/github.com/zeromq/czmq/bindings/qml/qml_czmq_bindings.pro +136 -0
  265. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZactor.cpp +88 -0
  266. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZactor.h +86 -0
  267. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZargs.cpp +121 -0
  268. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZargs.h +105 -0
  269. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZarmour.cpp +135 -0
  270. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZarmour.h +108 -0
  271. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZcert.cpp +166 -0
  272. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZcert.h +122 -0
  273. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZcertstore.cpp +95 -0
  274. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZcertstore.h +93 -0
  275. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZchunk.cpp +214 -0
  276. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZchunk.h +149 -0
  277. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZclock.cpp +67 -0
  278. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZclock.h +77 -0
  279. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZconfig.cpp +255 -0
  280. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZconfig.h +165 -0
  281. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZdigest.cpp +70 -0
  282. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZdigest.h +78 -0
  283. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZdir.cpp +158 -0
  284. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZdir.h +134 -0
  285. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZdirPatch.cpp +89 -0
  286. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZdirPatch.h +84 -0
  287. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZfile.cpp +204 -0
  288. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZfile.h +152 -0
  289. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZframe.cpp +200 -0
  290. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZframe.h +143 -0
  291. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZhash.cpp +219 -0
  292. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZhash.h +174 -0
  293. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZhashx.cpp +308 -0
  294. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZhashx.h +225 -0
  295. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZiflist.cpp +111 -0
  296. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZiflist.h +96 -0
  297. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZlist.cpp +184 -0
  298. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZlist.h +148 -0
  299. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZlistx.cpp +244 -0
  300. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZlistx.h +184 -0
  301. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZloop.cpp +177 -0
  302. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZloop.h +149 -0
  303. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZmsg.cpp +313 -0
  304. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZmsg.h +209 -0
  305. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZpoller.cpp +95 -0
  306. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZpoller.h +97 -0
  307. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZproc.cpp +296 -0
  308. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZproc.h +211 -0
  309. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZsock.cpp +1471 -0
  310. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZsock.h +882 -0
  311. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZstr.cpp +137 -0
  312. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZstr.h +120 -0
  313. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZsys.cpp +541 -0
  314. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZsys.h +373 -0
  315. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZtimerset.cpp +84 -0
  316. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZtimerset.h +86 -0
  317. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZtrie.cpp +101 -0
  318. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZtrie.h +95 -0
  319. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZuuid.cpp +116 -0
  320. data/vendor/github.com/zeromq/czmq/bindings/qml/src/QmlZuuid.h +99 -0
  321. data/vendor/github.com/zeromq/czmq/bindings/qml/src/qml_czmq_plugin.h +174 -0
  322. data/vendor/github.com/zeromq/czmq/bindings/qml/src/qmldir +2 -0
  323. data/vendor/github.com/zeromq/czmq/bindings/qml/test/tst_QmlCZMQ.qml +16 -0
  324. data/vendor/github.com/zeromq/czmq/bindings/qt/README.md +87 -0
  325. data/vendor/github.com/zeromq/czmq/bindings/qt/buildlib/buildlib.pro +36 -0
  326. data/vendor/github.com/zeromq/czmq/bindings/qt/common.pri +20 -0
  327. data/vendor/github.com/zeromq/czmq/bindings/qt/config.pri +1 -0
  328. data/vendor/github.com/zeromq/czmq/bindings/qt/qczmq.pro +13 -0
  329. data/vendor/github.com/zeromq/czmq/bindings/qt/selftest/main.cpp +57 -0
  330. data/vendor/github.com/zeromq/czmq/bindings/qt/selftest/selftest.pro +19 -0
  331. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qczmq.h +96 -0
  332. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qczmq.pri +81 -0
  333. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzactor.cpp +98 -0
  334. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzactor.h +61 -0
  335. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzargs.cpp +130 -0
  336. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzargs.h +72 -0
  337. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzarmour.cpp +162 -0
  338. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzarmour.h +83 -0
  339. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzcert.cpp +191 -0
  340. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzcert.h +97 -0
  341. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzcertstore.cpp +105 -0
  342. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzcertstore.h +68 -0
  343. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzchunk.cpp +250 -0
  344. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzchunk.h +124 -0
  345. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzclock.cpp +78 -0
  346. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzclock.h +52 -0
  347. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzconfig.cpp +292 -0
  348. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzconfig.h +140 -0
  349. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzdigest.cpp +80 -0
  350. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzdigest.h +53 -0
  351. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzdir.cpp +176 -0
  352. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzdir.h +109 -0
  353. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzdirpatch.cpp +101 -0
  354. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzdirpatch.h +59 -0
  355. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzfile.cpp +243 -0
  356. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzfile.h +127 -0
  357. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzframe.cpp +231 -0
  358. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzframe.h +118 -0
  359. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzhash.cpp +250 -0
  360. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzhash.h +149 -0
  361. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzhashx.cpp +350 -0
  362. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzhashx.h +200 -0
  363. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qziflist.cpp +133 -0
  364. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qziflist.h +71 -0
  365. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzlist.cpp +220 -0
  366. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzlist.h +123 -0
  367. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzlistx.cpp +296 -0
  368. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzlistx.h +159 -0
  369. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzloop.cpp +211 -0
  370. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzloop.h +124 -0
  371. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzmsg.cpp +354 -0
  372. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzmsg.h +184 -0
  373. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzpoller.cpp +100 -0
  374. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzpoller.h +67 -0
  375. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzproc.cpp +365 -0
  376. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzproc.h +186 -0
  377. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzsock.cpp +1719 -0
  378. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzsock.h +815 -0
  379. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzstr.cpp +128 -0
  380. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzstr.h +78 -0
  381. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzsys.cpp +600 -0
  382. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzsys.h +321 -0
  383. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qztimerset.cpp +98 -0
  384. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qztimerset.h +61 -0
  385. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qztrie.cpp +117 -0
  386. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qztrie.h +70 -0
  387. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzuuid.cpp +135 -0
  388. data/vendor/github.com/zeromq/czmq/bindings/qt/src/qzuuid.h +74 -0
  389. data/vendor/github.com/zeromq/czmq/bindings/ruby/Rakefile +8 -0
  390. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi.rb +875 -0
  391. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/version.rb +15 -0
  392. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zactor.rb +219 -0
  393. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zargs.rb +259 -0
  394. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zarmour.rb +286 -0
  395. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zcert.rb +304 -0
  396. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zcertstore.rb +224 -0
  397. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zchunk.rb +388 -0
  398. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zclock.rb +140 -0
  399. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zconfig.rb +462 -0
  400. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zdigest.rb +156 -0
  401. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zdir.rb +283 -0
  402. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zdir_patch.rb +194 -0
  403. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zfile.rb +361 -0
  404. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zframe.rb +360 -0
  405. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zhash.rb +386 -0
  406. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zhashx.rb +617 -0
  407. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/ziflist.rb +219 -0
  408. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zlist.rb +365 -0
  409. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zlistx.rb +478 -0
  410. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zloop.rb +396 -0
  411. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zmsg.rb +515 -0
  412. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zpoller.rb +194 -0
  413. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zproc.rb +497 -0
  414. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zsock.rb +4673 -0
  415. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zstr.rb +242 -0
  416. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zsys.rb +836 -0
  417. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/ztimerset.rb +203 -0
  418. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/ztrie.rb +221 -0
  419. data/vendor/github.com/zeromq/czmq/bindings/ruby/lib/czmq/ffi/zuuid.rb +227 -0
  420. data/vendor/github.com/zeromq/czmq/bindings/ruby/spec/ffi_spec.rb +15 -0
  421. data/vendor/github.com/zeromq/czmq/bindings/ruby/spec/spec_helper.rb +8 -0
  422. data/vendor/github.com/zeromq/czmq/builds/android/android_build_helper.sh +298 -0
  423. data/vendor/github.com/zeromq/czmq/builds/android/build.sh +94 -0
  424. data/vendor/github.com/zeromq/czmq/builds/android/ci_build.sh +41 -0
  425. data/vendor/github.com/zeromq/czmq/builds/check_zproject/ci_build.sh +52 -0
  426. data/vendor/github.com/zeromq/czmq/builds/check_zproto/ci_build.sh +23 -0
  427. data/vendor/github.com/zeromq/czmq/builds/cmake/ci_build.sh +93 -0
  428. data/vendor/github.com/zeromq/czmq/builds/cygwin/Makefile.cygwin +32 -0
  429. data/vendor/github.com/zeromq/czmq/builds/docs/ci_build.sh +24 -0
  430. data/vendor/github.com/zeromq/czmq/builds/gyp/.gitignore +5 -0
  431. data/vendor/github.com/zeromq/czmq/builds/gyp/README.md +33 -0
  432. data/vendor/github.com/zeromq/czmq/builds/gyp/platform.h +46 -0
  433. data/vendor/github.com/zeromq/czmq/builds/gyp/project.gyp +195 -0
  434. data/vendor/github.com/zeromq/czmq/builds/mingw32/Makefile.mingw32 +33 -0
  435. data/vendor/github.com/zeromq/czmq/builds/mingw32/platform.h +0 -0
  436. data/vendor/github.com/zeromq/czmq/builds/msvc/.gitignore +8 -0
  437. data/vendor/github.com/zeromq/czmq/builds/msvc/configure.bat +93 -0
  438. data/vendor/github.com/zeromq/czmq/builds/msvc/nuget/package.bat +14 -0
  439. data/vendor/github.com/zeromq/czmq/builds/msvc/nuget/package.nuspec +92 -0
  440. data/vendor/github.com/zeromq/czmq/builds/msvc/nuget/package.targets +128 -0
  441. data/vendor/github.com/zeromq/czmq/builds/msvc/nuget/package.xml +29 -0
  442. data/vendor/github.com/zeromq/czmq/builds/msvc/platform.h +1 -0
  443. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Common.props +21 -0
  444. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DLL.props +16 -0
  445. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Debug.props +29 -0
  446. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DebugDEXE.props +21 -0
  447. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DebugDLL.props +20 -0
  448. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DebugLEXE.props +20 -0
  449. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DebugLIB.props +21 -0
  450. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DebugLTCG.props +20 -0
  451. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/DebugSEXE.props +21 -0
  452. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/EXE.props +17 -0
  453. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/LIB.props +16 -0
  454. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/LTCG.props +13 -0
  455. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Link.props +21 -0
  456. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Messages.props +15 -0
  457. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Output.props +30 -0
  458. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Release.props +41 -0
  459. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/ReleaseDEXE.props +20 -0
  460. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/ReleaseDLL.props +19 -0
  461. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/ReleaseLEXE.props +20 -0
  462. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/ReleaseLIB.props +19 -0
  463. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/ReleaseLTCG.props +19 -0
  464. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/ReleaseSEXE.props +20 -0
  465. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/Win32.props +20 -0
  466. data/vendor/github.com/zeromq/czmq/builds/msvc/properties/x64.props +23 -0
  467. data/vendor/github.com/zeromq/czmq/builds/msvc/resource.h +14 -0
  468. data/vendor/github.com/zeromq/czmq/builds/msvc/resource.rc +94 -0
  469. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2008/czmq/czmq.sln +65 -0
  470. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2008/czmq/czmq.vcproj +1411 -0
  471. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/.gitignore +1 -0
  472. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/build.bat +129 -0
  473. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/czmq.import.props +59 -0
  474. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/czmq.sln +81 -0
  475. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/czmq_selftest/czmq_selftest.props +75 -0
  476. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/czmq_selftest/czmq_selftest.vcxproj +146 -0
  477. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/libczmq/libczmq.import.xml +29 -0
  478. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/libczmq/libczmq.props +81 -0
  479. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/libczmq/libczmq.vcxproj +215 -0
  480. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/libczmq/libczmq.vcxproj.filters +203 -0
  481. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/test_randof/test_randof.props +75 -0
  482. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/test_randof/test_randof.vcxproj +146 -0
  483. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/zmakecert/zmakecert.props +75 -0
  484. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/zmakecert/zmakecert.vcxproj +146 -0
  485. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/zsp/zsp.props +75 -0
  486. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2010/zsp/zsp.vcxproj +146 -0
  487. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/.gitignore +1 -0
  488. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/build.bat +129 -0
  489. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/czmq.import.props +59 -0
  490. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/czmq.sln +81 -0
  491. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/czmq_selftest/czmq_selftest.props +75 -0
  492. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/czmq_selftest/czmq_selftest.vcxproj +146 -0
  493. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/libczmq/libczmq.import.xml +29 -0
  494. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/libczmq/libczmq.props +81 -0
  495. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/libczmq/libczmq.vcxproj +215 -0
  496. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/libczmq/libczmq.vcxproj.filters +203 -0
  497. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/test_randof/test_randof.props +75 -0
  498. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/test_randof/test_randof.vcxproj +146 -0
  499. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/zmakecert/zmakecert.props +75 -0
  500. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/zmakecert/zmakecert.vcxproj +146 -0
  501. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/zsp/zsp.props +75 -0
  502. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2012/zsp/zsp.vcxproj +146 -0
  503. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/build.bat +129 -0
  504. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/czmq.import.props +59 -0
  505. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/czmq.sln +81 -0
  506. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/czmq_selftest/czmq_selftest.props +75 -0
  507. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/czmq_selftest/czmq_selftest.vcxproj +146 -0
  508. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/libczmq/libczmq.import.xml +29 -0
  509. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/libczmq/libczmq.props +81 -0
  510. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/libczmq/libczmq.vcxproj +215 -0
  511. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/libczmq/libczmq.vcxproj.filters +203 -0
  512. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/test_randof/test_randof.props +75 -0
  513. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/test_randof/test_randof.vcxproj +146 -0
  514. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/zmakecert/zmakecert.props +75 -0
  515. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/zmakecert/zmakecert.vcxproj +146 -0
  516. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/zsp/zsp.props +75 -0
  517. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2013/zsp/zsp.vcxproj +146 -0
  518. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/build.bat +129 -0
  519. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/czmq.import.props +59 -0
  520. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/czmq.sln +81 -0
  521. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/czmq_selftest/czmq_selftest.props +75 -0
  522. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/czmq_selftest/czmq_selftest.vcxproj +146 -0
  523. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/libczmq/libczmq.import.xml +29 -0
  524. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/libczmq/libczmq.props +81 -0
  525. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/libczmq/libczmq.vcxproj +215 -0
  526. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/libczmq/libczmq.vcxproj.filters +203 -0
  527. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/test_randof/test_randof.props +75 -0
  528. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/test_randof/test_randof.vcxproj +146 -0
  529. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/zmakecert/zmakecert.props +75 -0
  530. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/zmakecert/zmakecert.vcxproj +146 -0
  531. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/zsp/zsp.props +75 -0
  532. data/vendor/github.com/zeromq/czmq/builds/msvc/vs2015/zsp/zsp.vcxproj +146 -0
  533. data/vendor/github.com/zeromq/czmq/builds/nuget/czmq.autobuild +49 -0
  534. data/vendor/github.com/zeromq/czmq/builds/nuget/readme.nuget +18 -0
  535. data/vendor/github.com/zeromq/czmq/builds/rpi/.gitignore +8 -0
  536. data/vendor/github.com/zeromq/czmq/builds/rpi/README.md +62 -0
  537. data/vendor/github.com/zeromq/czmq/builds/rpi/build.sh +142 -0
  538. data/vendor/github.com/zeromq/czmq/builds/rpi/build_image.sh +32 -0
  539. data/vendor/github.com/zeromq/czmq/builds/rpi/prepare_img.sh +111 -0
  540. data/vendor/github.com/zeromq/czmq/builds/stable_zmq/ci_build.sh +62 -0
  541. data/vendor/github.com/zeromq/czmq/builds/valgrind/ci_build.sh +43 -0
  542. data/vendor/github.com/zeromq/czmq/ci_build.sh +317 -0
  543. data/vendor/github.com/zeromq/czmq/ci_deploy.sh +29 -0
  544. data/vendor/github.com/zeromq/czmq/ci_deploy_obs.sh +23 -0
  545. data/vendor/github.com/zeromq/czmq/configure.ac +856 -0
  546. data/vendor/github.com/zeromq/czmq/doc/.gitignore +91 -0
  547. data/vendor/github.com/zeromq/czmq/doc/Makefile.am +222 -0
  548. data/vendor/github.com/zeromq/czmq/doc/asciidoc.conf +64 -0
  549. data/vendor/github.com/zeromq/czmq/doc/czmq.adoc +51 -0
  550. data/vendor/github.com/zeromq/czmq/doc/czmq.txt +380 -0
  551. data/vendor/github.com/zeromq/czmq/doc/mkman +217 -0
  552. data/vendor/github.com/zeromq/czmq/doc/mkmans +15 -0
  553. data/vendor/github.com/zeromq/czmq/doc/wdput +43 -0
  554. data/vendor/github.com/zeromq/czmq/examples/security/LICENSE +18 -0
  555. data/vendor/github.com/zeromq/czmq/examples/security/README.txt +9 -0
  556. data/vendor/github.com/zeromq/czmq/examples/security/grasslands.c +32 -0
  557. data/vendor/github.com/zeromq/czmq/examples/security/hello.c +13 -0
  558. data/vendor/github.com/zeromq/czmq/examples/security/ironhouse.c +64 -0
  559. data/vendor/github.com/zeromq/czmq/examples/security/ironhouse2.c +123 -0
  560. data/vendor/github.com/zeromq/czmq/examples/security/ironhouse2_v2.c +107 -0
  561. data/vendor/github.com/zeromq/czmq/examples/security/passwords +2 -0
  562. data/vendor/github.com/zeromq/czmq/examples/security/stonehouse.c +59 -0
  563. data/vendor/github.com/zeromq/czmq/examples/security/strawhouse.c +49 -0
  564. data/vendor/github.com/zeromq/czmq/examples/security/woodhouse.c +47 -0
  565. data/vendor/github.com/zeromq/czmq/images/README_1.png +0 -0
  566. data/vendor/github.com/zeromq/czmq/include/.gitignore +1 -0
  567. data/vendor/github.com/zeromq/czmq/include/czmq.h +39 -0
  568. data/vendor/github.com/zeromq/czmq/include/czmq_library.h +190 -0
  569. data/vendor/github.com/zeromq/czmq/include/czmq_prelude.h +735 -0
  570. data/vendor/github.com/zeromq/czmq/include/test_zgossip.h +44 -0
  571. data/vendor/github.com/zeromq/czmq/include/zactor.h +94 -0
  572. data/vendor/github.com/zeromq/czmq/include/zargs.h +134 -0
  573. data/vendor/github.com/zeromq/czmq/include/zarmour.h +114 -0
  574. data/vendor/github.com/zeromq/czmq/include/zauth.h +100 -0
  575. data/vendor/github.com/zeromq/czmq/include/zbeacon.h +86 -0
  576. data/vendor/github.com/zeromq/czmq/include/zcert.h +133 -0
  577. data/vendor/github.com/zeromq/czmq/include/zcertstore.h +101 -0
  578. data/vendor/github.com/zeromq/czmq/include/zchunk.h +163 -0
  579. data/vendor/github.com/zeromq/czmq/include/zclock.h +73 -0
  580. data/vendor/github.com/zeromq/czmq/include/zconfig.h +199 -0
  581. data/vendor/github.com/zeromq/czmq/include/zdigest.h +65 -0
  582. data/vendor/github.com/zeromq/czmq/include/zdir.h +149 -0
  583. data/vendor/github.com/zeromq/czmq/include/zdir_patch.h +82 -0
  584. data/vendor/github.com/zeromq/czmq/include/zfile.h +185 -0
  585. data/vendor/github.com/zeromq/czmq/include/zframe.h +177 -0
  586. data/vendor/github.com/zeromq/czmq/include/zgossip.h +95 -0
  587. data/vendor/github.com/zeromq/czmq/include/zhash.h +183 -0
  588. data/vendor/github.com/zeromq/czmq/include/zhashx.h +279 -0
  589. data/vendor/github.com/zeromq/czmq/include/ziflist.h +98 -0
  590. data/vendor/github.com/zeromq/czmq/include/zlist.h +158 -0
  591. data/vendor/github.com/zeromq/czmq/include/zlistx.h +205 -0
  592. data/vendor/github.com/zeromq/czmq/include/zloop.h +163 -0
  593. data/vendor/github.com/zeromq/czmq/include/zmonitor.h +73 -0
  594. data/vendor/github.com/zeromq/czmq/include/zmsg.h +280 -0
  595. data/vendor/github.com/zeromq/czmq/include/zpoller.h +87 -0
  596. data/vendor/github.com/zeromq/czmq/include/zproc.h +270 -0
  597. data/vendor/github.com/zeromq/czmq/include/zproxy.h +111 -0
  598. data/vendor/github.com/zeromq/czmq/include/zrex.h +82 -0
  599. data/vendor/github.com/zeromq/czmq/include/zsock.h +1209 -0
  600. data/vendor/github.com/zeromq/czmq/include/zstr.h +135 -0
  601. data/vendor/github.com/zeromq/czmq/include/zsys.h +439 -0
  602. data/vendor/github.com/zeromq/czmq/include/ztimerset.h +90 -0
  603. data/vendor/github.com/zeromq/czmq/include/ztrie.h +106 -0
  604. data/vendor/github.com/zeromq/czmq/include/zuuid.h +96 -0
  605. data/vendor/github.com/zeromq/czmq/issues/README.md +6 -0
  606. data/vendor/github.com/zeromq/czmq/issues/c +520 -0
  607. data/vendor/github.com/zeromq/czmq/issues/issue-407.c +146 -0
  608. data/vendor/github.com/zeromq/czmq/license.xml +9 -0
  609. data/vendor/github.com/zeromq/czmq/mkdoc +7 -0
  610. data/vendor/github.com/zeromq/czmq/model/chkopts.pl +47 -0
  611. data/vendor/github.com/zeromq/czmq/model/rename_class +42 -0
  612. data/vendor/github.com/zeromq/czmq/packaging/debian/changelog +5 -0
  613. data/vendor/github.com/zeromq/czmq/packaging/debian/compat +1 -0
  614. data/vendor/github.com/zeromq/czmq/packaging/debian/control +86 -0
  615. data/vendor/github.com/zeromq/czmq/packaging/debian/copyright +13 -0
  616. data/vendor/github.com/zeromq/czmq/packaging/debian/czmq.dsc.obs +20 -0
  617. data/vendor/github.com/zeromq/czmq/packaging/debian/czmq.install +2 -0
  618. data/vendor/github.com/zeromq/czmq/packaging/debian/czmq.manpages +1 -0
  619. data/vendor/github.com/zeromq/czmq/packaging/debian/format +1 -0
  620. data/vendor/github.com/zeromq/czmq/packaging/debian/libczmq-dev.install +4 -0
  621. data/vendor/github.com/zeromq/czmq/packaging/debian/libczmq-dev.manpages +2 -0
  622. data/vendor/github.com/zeromq/czmq/packaging/debian/libczmq4.install +1 -0
  623. data/vendor/github.com/zeromq/czmq/packaging/debian/rules +96 -0
  624. data/vendor/github.com/zeromq/czmq/packaging/dist/gitlog2changelog.py +125 -0
  625. data/vendor/github.com/zeromq/czmq/packaging/obs/_service +91 -0
  626. data/vendor/github.com/zeromq/czmq/packaging/redhat/czmq.spec +202 -0
  627. data/vendor/github.com/zeromq/czmq/project.gyp +121 -0
  628. data/vendor/github.com/zeromq/czmq/project.xml +99 -0
  629. data/vendor/github.com/zeromq/czmq/setup.py +9 -0
  630. data/vendor/github.com/zeromq/czmq/src/.gitignore +20 -0
  631. data/vendor/github.com/zeromq/czmq/src/.valgrind.supp +33 -0
  632. data/vendor/github.com/zeromq/czmq/src/CMakeLists-local.txt +22 -0
  633. data/vendor/github.com/zeromq/czmq/src/Makemodule-local.am +15 -0
  634. data/vendor/github.com/zeromq/czmq/src/Makemodule.am +353 -0
  635. data/vendor/github.com/zeromq/czmq/src/czmq_classes.h +388 -0
  636. data/vendor/github.com/zeromq/czmq/src/czmq_private_selftest.c +40 -0
  637. data/vendor/github.com/zeromq/czmq/src/czmq_selftest.c +220 -0
  638. data/vendor/github.com/zeromq/czmq/src/foreign/sha1/sha1.h +76 -0
  639. data/vendor/github.com/zeromq/czmq/src/foreign/sha1/sha1.inc_c +335 -0
  640. data/vendor/github.com/zeromq/czmq/src/foreign/slre/readme.txt +83 -0
  641. data/vendor/github.com/zeromq/czmq/src/foreign/slre/slre.h +92 -0
  642. data/vendor/github.com/zeromq/czmq/src/foreign/slre/slre.inc_c +660 -0
  643. data/vendor/github.com/zeromq/czmq/src/libczmq.pc.in +24 -0
  644. data/vendor/github.com/zeromq/czmq/src/python_cffi.inc +17 -0
  645. data/vendor/github.com/zeromq/czmq/src/selftest-ro/.gitkeep +0 -0
  646. data/vendor/github.com/zeromq/czmq/src/selftest.cfg +5 -0
  647. data/vendor/github.com/zeromq/czmq/src/sockopts.gsl +36 -0
  648. data/vendor/github.com/zeromq/czmq/src/sockopts.xml +193 -0
  649. data/vendor/github.com/zeromq/czmq/src/test_randof.c +182 -0
  650. data/vendor/github.com/zeromq/czmq/src/test_zgossip.c +188 -0
  651. data/vendor/github.com/zeromq/czmq/src/valgrind.supp +14 -0
  652. data/vendor/github.com/zeromq/czmq/src/zactor.c +338 -0
  653. data/vendor/github.com/zeromq/czmq/src/zargs.c +289 -0
  654. data/vendor/github.com/zeromq/czmq/src/zarmour.c +941 -0
  655. data/vendor/github.com/zeromq/czmq/src/zauth.c +821 -0
  656. data/vendor/github.com/zeromq/czmq/src/zbeacon.c +651 -0
  657. data/vendor/github.com/zeromq/czmq/src/zcert.c +557 -0
  658. data/vendor/github.com/zeromq/czmq/src/zcertstore.c +407 -0
  659. data/vendor/github.com/zeromq/czmq/src/zchunk.c +609 -0
  660. data/vendor/github.com/zeromq/czmq/src/zclock.c +237 -0
  661. data/vendor/github.com/zeromq/czmq/src/zconfig.c +1369 -0
  662. data/vendor/github.com/zeromq/czmq/src/zdigest.c +163 -0
  663. data/vendor/github.com/zeromq/czmq/src/zdir.c +1138 -0
  664. data/vendor/github.com/zeromq/czmq/src/zdir_patch.c +227 -0
  665. data/vendor/github.com/zeromq/czmq/src/zfile.c +920 -0
  666. data/vendor/github.com/zeromq/czmq/src/zframe.c +756 -0
  667. data/vendor/github.com/zeromq/czmq/src/zgossip.c +689 -0
  668. data/vendor/github.com/zeromq/czmq/src/zgossip.xml +57 -0
  669. data/vendor/github.com/zeromq/czmq/src/zgossip_engine.inc +1008 -0
  670. data/vendor/github.com/zeromq/czmq/src/zgossip_msg.bnf +43 -0
  671. data/vendor/github.com/zeromq/czmq/src/zgossip_msg.c +688 -0
  672. data/vendor/github.com/zeromq/czmq/src/zgossip_msg.h +127 -0
  673. data/vendor/github.com/zeromq/czmq/src/zgossip_msg.xml +46 -0
  674. data/vendor/github.com/zeromq/czmq/src/zhash.c +956 -0
  675. data/vendor/github.com/zeromq/czmq/src/zhash_primes.inc +329 -0
  676. data/vendor/github.com/zeromq/czmq/src/zhashx.c +1369 -0
  677. data/vendor/github.com/zeromq/czmq/src/ziflist.c +517 -0
  678. data/vendor/github.com/zeromq/czmq/src/zlist.c +634 -0
  679. data/vendor/github.com/zeromq/czmq/src/zlistx.c +753 -0
  680. data/vendor/github.com/zeromq/czmq/src/zloop.c +1000 -0
  681. data/vendor/github.com/zeromq/czmq/src/zmakecert.c +64 -0
  682. data/vendor/github.com/zeromq/czmq/src/zmonitor.c +447 -0
  683. data/vendor/github.com/zeromq/czmq/src/zmsg.c +1258 -0
  684. data/vendor/github.com/zeromq/czmq/src/zpoller.c +397 -0
  685. data/vendor/github.com/zeromq/czmq/src/zproc.c +1160 -0
  686. data/vendor/github.com/zeromq/czmq/src/zproxy.c +791 -0
  687. data/vendor/github.com/zeromq/czmq/src/zrex.c +310 -0
  688. data/vendor/github.com/zeromq/czmq/src/zsock.c +2207 -0
  689. data/vendor/github.com/zeromq/czmq/src/zsock_option.gsl +404 -0
  690. data/vendor/github.com/zeromq/czmq/src/zsock_option.inc +3946 -0
  691. data/vendor/github.com/zeromq/czmq/src/zsp.c +118 -0
  692. data/vendor/github.com/zeromq/czmq/src/zstr.c +548 -0
  693. data/vendor/github.com/zeromq/czmq/src/zsys.c +2225 -0
  694. data/vendor/github.com/zeromq/czmq/src/ztimerset.c +227 -0
  695. data/vendor/github.com/zeromq/czmq/src/ztrie.c +809 -0
  696. data/vendor/github.com/zeromq/czmq/src/zuuid.c +344 -0
  697. metadata +780 -0
@@ -0,0 +1,2225 @@
1
+ /* =========================================================================
2
+ zsys - system-level methods
3
+
4
+ Copyright (c) the Contributors as noted in the AUTHORS file.
5
+ This file is part of CZMQ, the high-level C binding for 0MQ:
6
+ http://czmq.zeromq.org.
7
+
8
+ This Source Code Form is subject to the terms of the Mozilla Public
9
+ License, v. 2.0. If a copy of the MPL was not distributed with this
10
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
+ =========================================================================
12
+ */
13
+
14
+ /*
15
+ @header
16
+ The zsys class provides a portable wrapper for system calls. We collect
17
+ them here to reduce the number of weird #ifdefs in other classes. As far
18
+ as possible, the bulk of CZMQ classes are fully portable.
19
+ @discuss
20
+ @end
21
+ */
22
+
23
+ #include "czmq_classes.h"
24
+
25
+ // For getcwd() variants
26
+ #if (defined (WIN32))
27
+ # include <direct.h>
28
+ #else
29
+ # include <unistd.h>
30
+ #endif
31
+
32
+ // --------------------------------------------------------------------------
33
+ // Signal handling
34
+
35
+ // These are global variables accessible to CZMQ application code
36
+ volatile int zsys_interrupted = 0; // Current name
37
+ volatile int zctx_interrupted = 0; // Deprecated name
38
+
39
+ static void s_signal_handler (int signal_value);
40
+
41
+ // We use these variables for signal handling
42
+ static bool s_first_time = true;
43
+ static bool handle_signals = true;
44
+ #if defined (__UNIX__)
45
+ static struct sigaction sigint_default;
46
+ static struct sigaction sigterm_default;
47
+
48
+ #elif defined (__WINDOWS__)
49
+ static zsys_handler_fn *installed_handler_fn;
50
+ static BOOL WINAPI
51
+ s_handler_fn_shim (DWORD ctrltype)
52
+ {
53
+ // Return TRUE for events that we handle
54
+ if (ctrltype == CTRL_C_EVENT && installed_handler_fn != NULL) {
55
+ installed_handler_fn (ctrltype);
56
+ return TRUE;
57
+ }
58
+ if (ctrltype == CTRL_CLOSE_EVENT && installed_handler_fn != NULL) {
59
+ installed_handler_fn (ctrltype);
60
+ return TRUE;
61
+ }
62
+ return FALSE;
63
+ }
64
+ #endif
65
+
66
+ // --------------------------------------------------------------------------
67
+ // Global context handling
68
+
69
+ // ZeroMQ context for this process
70
+ static void *s_process_ctx = NULL;
71
+ static bool s_initialized = false;
72
+
73
+ #ifndef S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC
74
+ // This is a private tunable that is likely to be replaced or tweaked later
75
+ // per comment block at s_zsys_file_stable() implementation, to reflect
76
+ // the best stat data granularity available on host OS *and* used by czmq.
77
+ #define S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC 5000
78
+ #endif
79
+
80
+ // Default globals for new sockets and other joys; these can all be set
81
+ // from the environment, or via the zsys_set_xxx API.
82
+ static size_t s_io_threads = 1; // ZSYS_IO_THREADS=1
83
+ static int s_thread_sched_policy = -1; // ZSYS_THREAD_SCHED_POLICY=-1
84
+ static int s_thread_priority = -1; // ZSYS_THREAD_PRIORITY=-1
85
+ static size_t s_max_sockets = 1024; // ZSYS_MAX_SOCKETS=1024
86
+ static int s_max_msgsz = INT_MAX; // ZSYS_MAX_MSGSZ=INT_MAX
87
+ static int64_t s_file_stable_age_msec = S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC;
88
+ // ZSYS_FILE_STABLE_AGE_MSEC=5000
89
+ static size_t s_linger = 0; // ZSYS_LINGER=0
90
+ static size_t s_sndhwm = 1000; // ZSYS_SNDHWM=1000
91
+ static size_t s_rcvhwm = 1000; // ZSYS_RCVHWM=1000
92
+ static size_t s_pipehwm = 1000; // ZSYS_PIPEHWM=1000
93
+ static int s_ipv6 = 0; // ZSYS_IPV6=0
94
+ static char *s_interface = NULL; // ZSYS_INTERFACE=
95
+ static char *s_ipv6_address = NULL; // ZSYS_IPV6_ADDRESS=
96
+ static char *s_ipv6_mcast_address = NULL; // ZSYS_IPV6_MCAST_ADDRESS=
97
+ static int s_auto_use_fd = 0; // ZSYS_AUTO_USE_FD=0
98
+ static char *s_logident = NULL; // ZSYS_LOGIDENT=
99
+ static FILE *s_logstream = NULL; // ZSYS_LOGSTREAM=stdout/stderr
100
+ static bool s_logsystem = false; // ZSYS_LOGSYSTEM=true/false
101
+ static zsock_t *s_logsender = NULL; // ZSYS_LOGSENDER=
102
+
103
+ // Track number of open sockets so we can zmq_term() safely
104
+ static size_t s_open_sockets = 0;
105
+
106
+ // We keep a list of open sockets to report leaks to developers
107
+ static zlist_t *s_sockref_list = NULL;
108
+
109
+ // This defines a single zsock_new() caller instance
110
+ typedef struct {
111
+ void *handle;
112
+ int type;
113
+ const char *filename;
114
+ size_t line_nbr;
115
+ } s_sockref_t;
116
+
117
+ // Mutex macros
118
+ #if defined (__UNIX__)
119
+ typedef pthread_mutex_t zsys_mutex_t;
120
+ # define ZMUTEX_INIT(m) pthread_mutex_init (&m, NULL);
121
+ # define ZMUTEX_LOCK(m) pthread_mutex_lock (&m);
122
+ # define ZMUTEX_UNLOCK(m) pthread_mutex_unlock (&m);
123
+ # define ZMUTEX_DESTROY(m) pthread_mutex_destroy (&m);
124
+ #elif defined (__WINDOWS__)
125
+ typedef CRITICAL_SECTION zsys_mutex_t;
126
+ # define ZMUTEX_INIT(m) InitializeCriticalSection (&m);
127
+ # define ZMUTEX_LOCK(m) EnterCriticalSection (&m);
128
+ # define ZMUTEX_UNLOCK(m) LeaveCriticalSection (&m);
129
+ # define ZMUTEX_DESTROY(m) DeleteCriticalSection (&m);
130
+ #endif
131
+
132
+ // Mutex to guard socket counter
133
+ static zsys_mutex_t s_mutex;
134
+
135
+
136
+ // --------------------------------------------------------------------------
137
+ // Initialize CZMQ zsys layer; this happens automatically when you create
138
+ // a socket or an actor; however this call lets you force initialization
139
+ // earlier, so e.g. logging is properly set-up before you start working.
140
+ // Not threadsafe, so call only from main thread. Safe to call multiple
141
+ // times. Returns global CZMQ context.
142
+
143
+ void *
144
+ zsys_init (void)
145
+ {
146
+ if (s_initialized) {
147
+ assert (s_process_ctx);
148
+ return s_process_ctx;
149
+ }
150
+ // Pull process defaults from environment
151
+ if (getenv ("ZSYS_IO_THREADS"))
152
+ s_io_threads = atoi (getenv ("ZSYS_IO_THREADS"));
153
+
154
+ if (getenv ("ZSYS_MAX_SOCKETS"))
155
+ s_max_sockets = atoi (getenv ("ZSYS_MAX_SOCKETS"));
156
+
157
+ if (getenv ("ZSYS_MAX_MSGSZ"))
158
+ s_max_msgsz = atoi (getenv ("ZSYS_MAX_MSGSZ"));
159
+
160
+ if (getenv ("ZSYS_FILE_STABLE_AGE_MSEC"))
161
+ s_file_stable_age_msec = atoi (getenv ("ZSYS_FILE_STABLE_AGE_MSEC"));
162
+
163
+ if (getenv ("ZSYS_LINGER"))
164
+ s_linger = atoi (getenv ("ZSYS_LINGER"));
165
+
166
+ if (getenv ("ZSYS_SNDHWM"))
167
+ s_sndhwm = atoi (getenv ("ZSYS_SNDHWM"));
168
+
169
+ if (getenv ("ZSYS_RCVHWM"))
170
+ s_rcvhwm = atoi (getenv ("ZSYS_RCVHWM"));
171
+
172
+ if (getenv ("ZSYS_PIPEHWM"))
173
+ s_pipehwm = atoi (getenv ("ZSYS_PIPEHWM"));
174
+
175
+ if (getenv ("ZSYS_IPV6"))
176
+ s_ipv6 = atoi (getenv ("ZSYS_IPV6"));
177
+
178
+ if (getenv ("ZSYS_LOGSTREAM")) {
179
+ if (streq (getenv ("ZSYS_LOGSTREAM"), "stdout"))
180
+ s_logstream = stdout;
181
+ else
182
+ if (streq (getenv ("ZSYS_LOGSTREAM"), "stderr"))
183
+ s_logstream = stderr;
184
+ }
185
+ else
186
+ s_logstream = stdout;
187
+
188
+ if (getenv ("ZSYS_LOGSYSTEM")) {
189
+ if (streq (getenv ("ZSYS_LOGSYSTEM"), "true"))
190
+ s_logsystem = true;
191
+ else
192
+ if (streq (getenv ("ZSYS_LOGSYSTEM"), "false"))
193
+ s_logsystem = false;
194
+ }
195
+
196
+ if (getenv ("ZSYS_AUTO_USE_FD"))
197
+ s_auto_use_fd = atoi (getenv ("ZSYS_AUTO_USE_FD"));
198
+
199
+ zsys_catch_interrupts ();
200
+
201
+ ZMUTEX_INIT (s_mutex);
202
+ s_sockref_list = zlist_new ();
203
+ if (!s_sockref_list) {
204
+ zsys_shutdown ();
205
+ return NULL;
206
+ }
207
+ srandom ((unsigned) time (NULL));
208
+ atexit (zsys_shutdown);
209
+
210
+ assert (!s_process_ctx);
211
+ // We use zmq_init/zmq_term to keep compatibility back to ZMQ v2
212
+ s_process_ctx = zmq_init ((int) s_io_threads);
213
+ #if defined (ZMQ_MAX_SOCKETS)
214
+ zmq_ctx_set (s_process_ctx, ZMQ_MAX_SOCKETS, (int) s_max_sockets);
215
+ #endif
216
+ s_initialized = true;
217
+
218
+ // The following functions call zsys_init(), so they MUST be called after
219
+ // s_initialized is set in order to avoid an infinite recursion
220
+ if (getenv ("ZSYS_INTERFACE"))
221
+ zsys_set_interface (getenv ("ZSYS_INTERFACE"));
222
+
223
+ if (getenv ("ZSYS_IPV6_ADDRESS"))
224
+ zsys_set_ipv6_address (getenv ("ZSYS_IPV6_ADDRESS"));
225
+
226
+ if (getenv ("ZSYS_IPV6_MCAST_ADDRESS"))
227
+ zsys_set_ipv6_mcast_address (getenv ("ZSYS_IPV6_MCAST_ADDRESS"));
228
+ else
229
+ zsys_set_ipv6_mcast_address ("ff02:0:0:0:0:0:0:1");
230
+
231
+
232
+ if (getenv ("ZSYS_LOGIDENT"))
233
+ zsys_set_logident (getenv ("ZSYS_LOGIDENT"));
234
+
235
+ if (getenv ("ZSYS_LOGSENDER"))
236
+ zsys_set_logsender (getenv ("ZSYS_LOGSENDER"));
237
+
238
+ zsys_set_max_msgsz (s_max_msgsz);
239
+
240
+ zsys_set_file_stable_age_msec (s_file_stable_age_msec);
241
+
242
+ if (getenv ("ZSYS_THREAD_PRIORITY"))
243
+ zsys_set_thread_priority (atoi (getenv ("ZSYS_THREAD_PRIORITY")));
244
+ else
245
+ zsys_set_thread_priority (s_thread_priority);
246
+
247
+ if (getenv ("ZSYS_THREAD_SCHED_POLICY"))
248
+ zsys_set_thread_sched_policy (atoi (getenv ("ZSYS_THREAD_SCHED_POLICY")));
249
+ else
250
+ zsys_set_thread_sched_policy (s_thread_sched_policy);
251
+
252
+ return s_process_ctx;
253
+ }
254
+
255
+ // atexit or manual termination for the process
256
+ void
257
+ zsys_shutdown (void)
258
+ {
259
+ if (!s_initialized)
260
+ return;
261
+
262
+ s_initialized = false;
263
+
264
+ // The atexit handler is called when the main function exits;
265
+ // however we may have zactor threads shutting down and still
266
+ // trying to close their sockets. So if we suspect there are
267
+ // actors busy (s_open_sockets > 0), then we sleep for a few
268
+ // hundred milliseconds to allow the actors, if any, to get in
269
+ // and close their sockets.
270
+ ZMUTEX_LOCK (s_mutex);
271
+ size_t busy = s_open_sockets;
272
+ ZMUTEX_UNLOCK (s_mutex);
273
+ if (busy)
274
+ zclock_sleep (200);
275
+
276
+ // Close logsender socket if opened (don't do this in critical section)
277
+ if (s_logsender)
278
+ zsock_destroy (&s_logsender);
279
+
280
+ // No matter, we are now going to shut down
281
+ // Print the source reference for any sockets the app did not
282
+ // destroy properly.
283
+ ZMUTEX_LOCK (s_mutex);
284
+ s_sockref_t *sockref = (s_sockref_t *) zlist_pop (s_sockref_list);
285
+ while (sockref) {
286
+ assert (sockref->filename);
287
+ zsys_error ("[%d]dangling '%s' socket created at %s:%d",
288
+ getpid (),
289
+ zsys_sockname (sockref->type),
290
+ sockref->filename, (int) sockref->line_nbr);
291
+ zmq_close (sockref->handle);
292
+ freen (sockref);
293
+ sockref = (s_sockref_t *) zlist_pop (s_sockref_list);
294
+ --s_open_sockets;
295
+ }
296
+ zlist_destroy (&s_sockref_list);
297
+ ZMUTEX_UNLOCK (s_mutex);
298
+
299
+ if (s_open_sockets == 0)
300
+ {
301
+ zmq_term(s_process_ctx);
302
+ s_process_ctx = NULL;
303
+ s_io_threads = 1;
304
+ s_thread_sched_policy = -1;
305
+ s_thread_priority = -1;
306
+ s_max_sockets = 1024;
307
+ s_max_msgsz = INT_MAX;
308
+ s_file_stable_age_msec = S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC;
309
+ s_linger = 0;
310
+ s_sndhwm = 1000;
311
+ s_rcvhwm = 1000;
312
+ s_pipehwm = 1000;
313
+ s_ipv6 = 0;
314
+ s_auto_use_fd = 0;
315
+ s_logstream = NULL;
316
+ s_logsystem = false;
317
+ }
318
+ else
319
+ zsys_error ("dangling sockets: cannot terminate ZMQ safely");
320
+
321
+ ZMUTEX_DESTROY (s_mutex);
322
+
323
+ // Free dynamically allocated properties
324
+ freen (s_interface);
325
+ freen (s_ipv6_address);
326
+ freen (s_ipv6_mcast_address);
327
+ freen (s_logident);
328
+
329
+ zsys_interrupted = 0;
330
+ zctx_interrupted = 0;
331
+
332
+ zsys_handler_reset ();
333
+
334
+ #if defined (__UNIX__)
335
+ closelog (); // Just to be pedantic
336
+ #endif
337
+ }
338
+
339
+
340
+ // --------------------------------------------------------------------------
341
+ // Get a new ZMQ socket, automagically creating a ZMQ context if this is
342
+ // the first time. Caller is responsible for destroying the ZMQ socket
343
+ // before process exits, to avoid a ZMQ deadlock. Note: you should not use
344
+ // this method in CZMQ apps, use zsock_new() instead. This is for system
345
+ // use only, really.
346
+
347
+ void *
348
+ zsys_socket (int type, const char *filename, size_t line_nbr)
349
+ {
350
+ // First time initialization; if the application is mixing
351
+ // its own threading calls with zsock, this may fail if two
352
+ // threads try to create sockets at the same time. In such
353
+ // apps, they MUST create a socket in the main program before
354
+ // starting any threads. If the app uses zactor for its threads
355
+ // then we can guarantee this to always be safe.
356
+ zsys_init ();
357
+ ZMUTEX_LOCK (s_mutex);
358
+ void *handle = zmq_socket (s_process_ctx, type);
359
+ if (handle) {
360
+ // Configure socket with process defaults
361
+ zsock_set_linger (handle, (int) s_linger);
362
+ #if (ZMQ_VERSION_MAJOR == 2)
363
+ // TODO: v2/v3 socket api in zsock_option.inc are not public (not
364
+ // added to include/zsock.h) so we have to use zmq_setsockopt directly
365
+ // This should be fixed and zsock_set_hwm should be used instead
366
+ # if defined (ZMQ_HWM)
367
+ uint64_t value = s_sndhwm;
368
+ int rc = zmq_setsockopt (handle, ZMQ_HWM, &value, sizeof (uint64_t));
369
+ assert (rc == 0 || zmq_errno () == ETERM);
370
+ # endif
371
+ #else
372
+ // For later versions we use separate SNDHWM and RCVHWM
373
+ zsock_set_sndhwm (handle, (int) s_sndhwm);
374
+ zsock_set_rcvhwm (handle, (int) s_rcvhwm);
375
+ # if defined (ZMQ_IPV6)
376
+ zsock_set_ipv6 (handle, s_ipv6);
377
+ # else
378
+ zsock_set_ipv4only (handle, s_ipv6? 0: 1);
379
+ # endif
380
+ #endif
381
+ // Add socket to reference tracker so we can report leaks; this is
382
+ // done only when the caller passes a filename/line_nbr
383
+ if (filename) {
384
+ s_sockref_t *sockref = (s_sockref_t *) zmalloc (sizeof (s_sockref_t));
385
+ if (sockref) {
386
+ sockref->handle = handle;
387
+ sockref->type = type;
388
+ sockref->filename = filename;
389
+ sockref->line_nbr = line_nbr;
390
+ zlist_append (s_sockref_list, sockref);
391
+ }
392
+ else {
393
+ zmq_close (handle);
394
+ ZMUTEX_UNLOCK (s_mutex);
395
+ return NULL;
396
+ }
397
+ }
398
+ s_open_sockets++;
399
+ }
400
+ ZMUTEX_UNLOCK (s_mutex);
401
+ return handle;
402
+ }
403
+
404
+ // --------------------------------------------------------------------------
405
+ // Destroy/close a ZMQ socket. You should call this for every socket you
406
+ // create using zsys_socket().
407
+
408
+ int
409
+ zsys_close (void *handle, const char *filename, size_t line_nbr)
410
+ {
411
+ ZMUTEX_LOCK (s_mutex);
412
+ // It's possible atexit() has already happened if we're running under
413
+ // a debugger that redirects the main thread exit.
414
+ if (s_sockref_list) {
415
+ s_sockref_t *sockref = (s_sockref_t *) zlist_first (s_sockref_list);
416
+ while (sockref) {
417
+ if (sockref->handle == handle) {
418
+ zlist_remove (s_sockref_list, sockref);
419
+ freen (sockref);
420
+ break;
421
+ }
422
+ sockref = (s_sockref_t *) zlist_next (s_sockref_list);
423
+ }
424
+ }
425
+ s_open_sockets--;
426
+ zmq_close (handle);
427
+ ZMUTEX_UNLOCK (s_mutex);
428
+ return 0;
429
+ }
430
+
431
+
432
+ // --------------------------------------------------------------------------
433
+ // Return ZMQ socket name for socket type
434
+
435
+ char *
436
+ zsys_sockname (int socktype)
437
+ {
438
+ char *type_names [] = {
439
+ "PAIR", "PUB", "SUB", "REQ", "REP",
440
+ "DEALER", "ROUTER", "PULL", "PUSH",
441
+ "XPUB", "XSUB", "STREAM",
442
+ "SERVER", "CLIENT",
443
+ "RADIO", "DISH",
444
+ "SCATTER", "GATHER"
445
+ };
446
+ // This array matches ZMQ_XXX type definitions
447
+ assert (ZMQ_PAIR == 0);
448
+ #if defined (ZMQ_SCATTER)
449
+ assert (socktype >= 0 && socktype <= ZMQ_SCATTER);
450
+ #elif defined (ZMQ_DISH)
451
+ assert (socktype >= 0 && socktype <= ZMQ_DISH);
452
+ #elif defined (ZMQ_CLIENT)
453
+ assert (socktype >= 0 && socktype <= ZMQ_CLIENT);
454
+ #elif defined (ZMQ_STREAM)
455
+ assert (socktype >= 0 && socktype <= ZMQ_STREAM);
456
+ #else
457
+ assert (socktype >= 0 && socktype <= ZMQ_XSUB);
458
+ #endif
459
+ return type_names [socktype];
460
+ }
461
+
462
+
463
+ // --------------------------------------------------------------------------
464
+ // Create a pipe, which consists of two PAIR sockets connected over inproc.
465
+ // The pipe is configured to use the zsys_pipehwm setting. Returns the
466
+ // frontend socket successful, NULL if failed.
467
+
468
+ zsock_t *
469
+ zsys_create_pipe (zsock_t **backend_p)
470
+ {
471
+ zsock_t *frontend = zsock_new (ZMQ_PAIR);
472
+ zsock_t *backend = zsock_new (ZMQ_PAIR);
473
+ assert (frontend);
474
+ assert (backend);
475
+
476
+ #if (ZMQ_VERSION_MAJOR == 2)
477
+ // TODO: v2/v3 socket api in zsock_option.inc are not public (not
478
+ // added to include/zsock.h) so we have to use zmq_setsockopt directly
479
+ // This should be fixed and zsock_set_hwm should be used instead
480
+ # if defined (ZMQ_HWM)
481
+ uint64_t value = zsys_pipehwm ();
482
+ int ret = zmq_setsockopt (zsock_resolve (frontend), ZMQ_HWM, &value,
483
+ sizeof (uint64_t));
484
+ assert (ret == 0 || zmq_errno () == ETERM);
485
+ value = zsys_pipehwm ();
486
+ ret = zmq_setsockopt (zsock_resolve (backend), ZMQ_HWM, &value,
487
+ sizeof (uint64_t));
488
+ assert (ret == 0 || zmq_errno () == ETERM);
489
+ # endif
490
+ #else
491
+ zsock_set_sndhwm (frontend, (int) zsys_pipehwm ());
492
+ zsock_set_sndhwm (backend, (int) zsys_pipehwm ());
493
+ #endif
494
+ // Now bind and connect pipe ends
495
+ char endpoint [32];
496
+ while (true) {
497
+ sprintf (endpoint, "inproc://pipe-%04x-%04x",
498
+ randof (0x10000), randof (0x10000));
499
+ if (zsock_bind (frontend, "%s", endpoint) == 0)
500
+ break;
501
+ }
502
+ int rc = zsock_connect (backend, "%s", endpoint);
503
+ assert (rc != -1); // Connect cannot fail
504
+
505
+ // Return frontend and backend sockets
506
+ *backend_p = backend;
507
+ return frontend;
508
+ }
509
+
510
+
511
+ // --------------------------------------------------------------------------
512
+ // Set interrupt handler; this saves the default handlers so that a
513
+ // zsys_handler_reset () can restore them. If you call this multiple times
514
+ // then the last handler will take affect. If handler_fn is NULL, disables
515
+ // default SIGINT/SIGTERM handling in CZMQ.
516
+
517
+ void
518
+ zsys_handler_set (zsys_handler_fn *handler_fn)
519
+ {
520
+ if (!handler_fn) {
521
+ // Disable existing or future signal handling
522
+ zsys_handler_reset ();
523
+ handle_signals = false;
524
+ }
525
+ else {
526
+ handle_signals = true;
527
+ #if defined (__UNIX__)
528
+ if (s_first_time) {
529
+ // If first time, save default handlers
530
+ sigaction (SIGINT, NULL, &sigint_default);
531
+ sigaction (SIGTERM, NULL, &sigterm_default);
532
+ s_first_time = false;
533
+ }
534
+ // Install signal handler for SIGINT and SIGTERM
535
+ struct sigaction action;
536
+ action.sa_handler = handler_fn;
537
+ action.sa_flags = 0;
538
+ sigemptyset (&action.sa_mask);
539
+ sigaction (SIGINT, &action, NULL);
540
+ sigaction (SIGTERM, &action, NULL);
541
+ #elif defined (__WINDOWS__)
542
+ installed_handler_fn = handler_fn;
543
+ if (s_first_time) {
544
+ SetConsoleCtrlHandler (s_handler_fn_shim, TRUE);
545
+ s_first_time = false;
546
+ }
547
+ #else
548
+ # error "No signal handling defined for this platform"
549
+ #endif
550
+ }
551
+ }
552
+
553
+
554
+ // --------------------------------------------------------------------------
555
+ // Reset interrupt handler, call this at exit if needed
556
+ // Idempotent; safe to call multiple times
557
+
558
+ void
559
+ zsys_handler_reset (void)
560
+ {
561
+ #if defined (__UNIX__)
562
+ // Restore default handlers if not already done
563
+ if (handle_signals && !s_first_time) {
564
+ sigaction (SIGINT, &sigint_default, NULL);
565
+ sigaction (SIGTERM, &sigterm_default, NULL);
566
+ sigint_default.sa_handler = NULL;
567
+ sigterm_default.sa_handler = NULL;
568
+ s_first_time = true;
569
+ }
570
+ #elif defined (__WINDOWS__)
571
+ if (handle_signals && !s_first_time) {
572
+ SetConsoleCtrlHandler (s_handler_fn_shim, FALSE);
573
+ installed_handler_fn = NULL;
574
+ s_first_time = true;
575
+ }
576
+ #endif
577
+ }
578
+
579
+
580
+ // --------------------------------------------------------------------------
581
+ // Set default interrupt handler, so Ctrl-C or SIGTERM will set
582
+ // zsys_interrupted. Idempotent; safe to call multiple times.
583
+
584
+ void
585
+ zsys_catch_interrupts (void)
586
+ {
587
+ // Catch SIGINT and SIGTERM unless ZSYS_SIGHANDLER=false
588
+ if ((getenv ("ZSYS_SIGHANDLER") == NULL
589
+ || strneq (getenv ("ZSYS_SIGHANDLER"), "false"))
590
+ && handle_signals)
591
+ zsys_handler_set (s_signal_handler);
592
+ }
593
+
594
+ // Default internal signal handler
595
+ static void
596
+ s_signal_handler (int signal_value)
597
+ {
598
+ zctx_interrupted = 1;
599
+ zsys_interrupted = 1;
600
+ }
601
+
602
+
603
+ // --------------------------------------------------------------------------
604
+ // Return true if file exists, else zero
605
+
606
+ bool
607
+ zsys_file_exists (const char *filename)
608
+ {
609
+ assert (filename);
610
+ return zsys_file_mode (filename) != -1;
611
+ }
612
+
613
+
614
+ // --------------------------------------------------------------------------
615
+ // Return size of file, or -1 if not found
616
+
617
+ ssize_t
618
+ zsys_file_size (const char *filename)
619
+ {
620
+ struct stat
621
+ stat_buf;
622
+
623
+ assert (filename);
624
+ if (stat ((char *) filename, &stat_buf) == 0)
625
+ return stat_buf.st_size;
626
+ else
627
+ return -1;
628
+ }
629
+
630
+
631
+ // --------------------------------------------------------------------------
632
+ // Return file modification time (accounted in seconds usually since
633
+ // UNIX Epoch, with granularity dependent on underlying filesystem,
634
+ // and starting point dependent on host OS and maybe its bitness).
635
+ // Per https://msdn.microsoft.com/en-us/library/w4ddyt9h(vs.71).aspx :
636
+ // Note In all versions of Microsoft C/C++ except Microsoft C/C++
637
+ // version 7.0, and in all versions of Microsoft Visual C++, the time
638
+ // function returns the current time as the number of seconds elapsed
639
+ // since midnight on January 1, 1970. In Microsoft C/C++ version 7.0,
640
+ // time() returned the current time as the number of seconds elapsed
641
+ // since midnight on December 31, 1899.
642
+ // This value is "arithmetic" with no big guarantees in the standards, and
643
+ // normally it should be manipulated with host's datetime suite of routines,
644
+ // including difftime(), or converted to "struct tm" for any predictable use.
645
+ // Returns 0 if the file does not exist.
646
+
647
+ time_t
648
+ zsys_file_modified (const char *filename)
649
+ {
650
+ struct stat stat_buf;
651
+ if (stat (filename, &stat_buf) == 0)
652
+ return stat_buf.st_mtime;
653
+ else
654
+ return 0;
655
+ }
656
+
657
+
658
+ // --------------------------------------------------------------------------
659
+ // Return file mode; provides at least support for the POSIX S_ISREG(m)
660
+ // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes.
661
+ // Returns a mode_t cast to int, or -1 in case of error.
662
+
663
+ int
664
+ zsys_file_mode (const char *filename)
665
+ {
666
+ #if (defined (__WINDOWS__))
667
+ DWORD dwfa = GetFileAttributesA (filename);
668
+ if (dwfa == 0xffffffff)
669
+ return -1;
670
+
671
+ dbyte mode = 0;
672
+ if (dwfa & FILE_ATTRIBUTE_DIRECTORY)
673
+ mode |= S_IFDIR;
674
+ else
675
+ mode |= S_IFREG;
676
+
677
+ if (!(dwfa & FILE_ATTRIBUTE_HIDDEN))
678
+ mode |= S_IRUSR;
679
+ if (!(dwfa & FILE_ATTRIBUTE_READONLY))
680
+ mode |= S_IWUSR;
681
+
682
+ return mode;
683
+ #else
684
+ struct stat stat_buf;
685
+ if (stat ((char *) filename, &stat_buf) == 0)
686
+ return stat_buf.st_mode;
687
+ else
688
+ return -1;
689
+ #endif
690
+ }
691
+
692
+
693
+ // --------------------------------------------------------------------------
694
+ // Delete file, return 0 if OK, -1 if not possible.
695
+
696
+ int
697
+ zsys_file_delete (const char *filename)
698
+ {
699
+ assert (filename);
700
+ #if (defined (__WINDOWS__))
701
+ return DeleteFileA (filename)? 0: -1;
702
+ #else
703
+ return unlink (filename);
704
+ #endif
705
+ }
706
+
707
+
708
+ // --------------------------------------------------------------------------
709
+ // Check if file is 'stable'
710
+
711
+ // Internal implementation rigged with debugs and called from selftest
712
+ static bool
713
+ s_zsys_file_stable (const char *filename, bool verbose)
714
+ {
715
+ struct stat stat_buf;
716
+ if (stat (filename, &stat_buf) == 0) {
717
+ // File is 'stable' if older (per filesystem stats) than a threshold.
718
+ // This used to mean more than 1 second old, counted in microseconds
719
+ // after inflating the st_mtime data - but this way of calculation
720
+ // has a caveat: if we created the file at Nsec.999msec, or rather
721
+ // the FS metadata was updated at that point, the st_mtime will be
722
+ // (after inflation) N.000. So a few milliseconds later, at (N+1)sec,
723
+ // we find the age difference seems over 1000 so the file is 1 sec
724
+ // old - even though it has barely been created. Compounding the
725
+ // issue, some filesystems have worse timestamp precision - e.g. the
726
+ // FAT filesystem variants are widespread (per SD standards) on
727
+ // removable media, and only account even seconds in stat data.
728
+ // Solutions are two-fold: when using stat fields that are precise
729
+ // to a second (or inpredictably two), we should actually check for
730
+ // (age > 3000+) in rounded-microsecond accounting. Also, for some
731
+ // systems we can have `configure`-time checks on presence of more
732
+ // precise (and less standardized) stat timestamp fields, where we
733
+ // can presumably avoid rounding to thousands and use (age > 2000).
734
+ // It might also help to define a zsys_file_modified_msec() whose
735
+ // actual granularity will be OS-dependent (rounded to 1000 or not).
736
+ // These are TODO ideas for subsequent work.
737
+
738
+ #if (defined (WIN32))
739
+ # define EPOCH_DIFFERENCE 11644473600LL
740
+ long age = (long) (zclock_time () - EPOCH_DIFFERENCE * 1000 - (stat_buf.st_mtime * 1000));
741
+ if (verbose)
742
+ zsys_debug ("zsys_file_stable@WIN32: file '%s' age is %ld msec "
743
+ "at timestamp %" PRIi64 " where st_mtime was %jd adjusted by %jd",
744
+ filename, age, zclock_time (), (intmax_t)(stat_buf.st_mtime * 1000),
745
+ (intmax_t)(EPOCH_DIFFERENCE * 1000) );
746
+ #else
747
+ long age = (long) (zclock_time () - (stat_buf.st_mtime * 1000));
748
+ if (verbose)
749
+ zsys_debug ("zsys_file_stable@non-WIN32: file '%s' age is %ld msec "
750
+ "at timestamp %" PRIi64 " where st_mtime was %jd",
751
+ filename, age, zclock_time (), (intmax_t)(stat_buf.st_mtime * 1000) );
752
+ #endif
753
+ return (age > s_file_stable_age_msec);
754
+ }
755
+ else {
756
+ if (verbose)
757
+ zsys_debug ("zsys_file_stable: could not stat file '%s'", filename);
758
+ return false; // File doesn't exist, so not stable
759
+ }
760
+ }
761
+
762
+ // Public implementation does not do debugs
763
+ bool
764
+ zsys_file_stable (const char *filename)
765
+ {
766
+ return s_zsys_file_stable(filename, false);
767
+ }
768
+
769
+ // --------------------------------------------------------------------------
770
+ // Create a file path if it doesn't exist. The file path is treated as a
771
+ // printf format.
772
+
773
+ int
774
+ zsys_dir_create (const char *pathname, ...)
775
+ {
776
+ va_list argptr;
777
+ va_start (argptr, pathname);
778
+ char *formatted = zsys_vprintf (pathname, argptr);
779
+ va_end (argptr);
780
+ if (!formatted)
781
+ return -1;
782
+
783
+ // Create parent directory levels if needed
784
+ char *slash = strchr (formatted + 1, '/');
785
+ while (true) {
786
+ if (slash)
787
+ *slash = 0; // Cut at slash
788
+ int mode = zsys_file_mode (formatted);
789
+ if (mode == -1) {
790
+ // Does not exist, try to create it
791
+ #if (defined (__WINDOWS__))
792
+ if (!CreateDirectoryA (formatted, NULL)) {
793
+ #else
794
+ if (mkdir (formatted, 0775)) {
795
+ #endif
796
+ freen (formatted);
797
+ return -1; // Failed
798
+ }
799
+ }
800
+ else
801
+ if ((mode & S_IFDIR) == 0) {
802
+ // Not a directory, abort
803
+ }
804
+ if (!slash) // End if last segment
805
+ break;
806
+ *slash = '/';
807
+ slash = strchr (slash + 1, '/');
808
+ }
809
+ zstr_free (&formatted);
810
+ return 0;
811
+ }
812
+
813
+
814
+ // --------------------------------------------------------------------------
815
+ // Remove a file path if empty; the pathname is treated as printf format.
816
+
817
+ int
818
+ zsys_dir_delete (const char *pathname, ...)
819
+ {
820
+ va_list argptr;
821
+ va_start (argptr, pathname);
822
+ char *formatted = zsys_vprintf (pathname, argptr);
823
+ va_end (argptr);
824
+ if (!formatted)
825
+ return -1;
826
+
827
+ #if (defined (__WINDOWS__))
828
+ int rc = RemoveDirectoryA (formatted)? 0: -1;
829
+ #else
830
+ int rc = rmdir (formatted);
831
+ #endif
832
+ zstr_free (&formatted);
833
+ return rc;
834
+ }
835
+
836
+
837
+ // --------------------------------------------------------------------------
838
+ // Move to a specified working directory. Returns 0 if OK, -1 if this failed.
839
+
840
+ int
841
+ zsys_dir_change (const char *pathname)
842
+ {
843
+ assert (pathname);
844
+ #if (defined (__UNIX__))
845
+ return chdir (pathname);
846
+ #elif (defined (__WINDOWS__))
847
+ return !SetCurrentDirectoryA (pathname);
848
+ #endif
849
+ return -1; // Not implemented
850
+ }
851
+
852
+
853
+ // --------------------------------------------------------------------------
854
+ // Set private file creation mode; all files created from here will be
855
+ // readable/writable by the owner only.
856
+
857
+ #if !defined (__WINDOWS__)
858
+ static mode_t s_old_mask = 0;
859
+ #endif
860
+
861
+ void
862
+ zsys_file_mode_private (void)
863
+ {
864
+ #if !defined (__WINDOWS__)
865
+ s_old_mask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH);
866
+ #endif
867
+ }
868
+
869
+
870
+ // --------------------------------------------------------------------------
871
+ // Reset default file creation mode; all files created from here will use
872
+ // process file mode defaults.
873
+
874
+ void
875
+ zsys_file_mode_default (void)
876
+ {
877
+ // Reset process file create mask
878
+ #if !defined (__WINDOWS__)
879
+ if (s_old_mask)
880
+ umask (s_old_mask);
881
+ #endif
882
+ }
883
+
884
+
885
+ // --------------------------------------------------------------------------
886
+ // Return the CZMQ version for run-time API detection; returns version
887
+ // number into provided fields, providing reference isn't null in each case.
888
+
889
+ void
890
+ zsys_version (int *major, int *minor, int *patch)
891
+ {
892
+ if (major)
893
+ *major = CZMQ_VERSION_MAJOR;
894
+ if (minor)
895
+ *minor = CZMQ_VERSION_MINOR;
896
+ if (patch)
897
+ *patch = CZMQ_VERSION_PATCH;
898
+ }
899
+
900
+
901
+ // --------------------------------------------------------------------------
902
+ // Format a string using printf formatting, returning a freshly allocated
903
+ // buffer. If there was insufficient memory, returns NULL. Free the returned
904
+ // string using zstr_free().
905
+
906
+ char *
907
+ zsys_sprintf (const char *format, ...)
908
+ {
909
+ va_list argptr;
910
+ va_start (argptr, format);
911
+ char *string = zsys_vprintf (format, argptr);
912
+ va_end (argptr);
913
+ return (string);
914
+ }
915
+
916
+
917
+ // --------------------------------------------------------------------------
918
+ // Format a string with variable arguments, returning a freshly allocated
919
+ // buffer. If there was insufficient memory, returns NULL. Free the returned
920
+ // string using zstr_free().
921
+
922
+ char *
923
+ zsys_vprintf (const char *format, va_list argptr)
924
+ {
925
+ int size = 256;
926
+ char *string = (char *) malloc (size);
927
+ if (!string)
928
+ return NULL;
929
+
930
+ // Using argptr is destructive, so we take a copy each time we need it
931
+ // We define va_copy for Windows in czmq_prelude.h
932
+ va_list my_argptr;
933
+ va_copy (my_argptr, argptr);
934
+ int required = vsnprintf (string, size, format, my_argptr);
935
+ va_end (my_argptr);
936
+ #ifdef __WINDOWS__
937
+ if (required < 0 || required >= size) {
938
+ va_copy (my_argptr, argptr);
939
+ #ifdef _MSC_VER
940
+ required = _vscprintf (format, argptr);
941
+ #else
942
+ required = vsnprintf (NULL, 0, format, argptr);
943
+ #endif
944
+ va_end (my_argptr);
945
+ }
946
+ #endif
947
+ // If formatted string cannot fit into small string, reallocate a
948
+ // larger buffer for it.
949
+ if (required >= size) {
950
+ size = required + 1;
951
+ freen (string);
952
+ string = (char *) malloc (size);
953
+ if (string) {
954
+ va_copy (my_argptr, argptr);
955
+ vsnprintf (string, size, format, my_argptr);
956
+ va_end (my_argptr);
957
+ }
958
+ }
959
+ return string;
960
+ }
961
+
962
+
963
+ // --------------------------------------------------------------------------
964
+ // Create a UDP beacon socket; if the routable option is true, uses
965
+ // multicast (not yet implemented), else uses broadcast. This method
966
+ // and related ones might _eventually_ be moved to a zudp class.
967
+
968
+ SOCKET
969
+ zsys_udp_new (bool routable)
970
+ {
971
+ // We haven't implemented multicast yet
972
+ assert (!routable);
973
+ SOCKET udpsock;
974
+ if (zsys_ipv6 ())
975
+ udpsock = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
976
+ else
977
+ udpsock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
978
+ if (udpsock == INVALID_SOCKET) {
979
+ zsys_socket_error ("socket");
980
+ return INVALID_SOCKET;
981
+ }
982
+ // Ask operating system for broadcast permissions on socket
983
+ int on = 1;
984
+ if (setsockopt (udpsock, SOL_SOCKET, SO_BROADCAST,
985
+ (char *) &on, sizeof (on)) == SOCKET_ERROR)
986
+ zsys_socket_error ("setsockopt (SO_BROADCAST)");
987
+
988
+ // Allow multiple owners to bind to socket; incoming
989
+ // messages will replicate to each owner
990
+ if (setsockopt (udpsock, SOL_SOCKET, SO_REUSEADDR,
991
+ (char *) &on, sizeof (on)) == SOCKET_ERROR)
992
+ zsys_socket_error ("setsockopt (SO_REUSEADDR)");
993
+
994
+ #if defined (SO_REUSEPORT)
995
+ // On some platforms we have to ask to reuse the port
996
+ if (setsockopt (udpsock, SOL_SOCKET, SO_REUSEPORT,
997
+ (char *) &on, sizeof (on)) == SOCKET_ERROR)
998
+ zsys_socket_error ("setsockopt (SO_REUSEPORT)");
999
+ #endif
1000
+ return udpsock;
1001
+ }
1002
+
1003
+
1004
+ // --------------------------------------------------------------------------
1005
+ // Close a UDP socket
1006
+
1007
+ int
1008
+ zsys_udp_close (SOCKET handle)
1009
+ {
1010
+ #if (defined (__WINDOWS__))
1011
+ return closesocket (handle);
1012
+ #else
1013
+ return close (handle);
1014
+ #endif
1015
+ }
1016
+
1017
+
1018
+ // --------------------------------------------------------------------------
1019
+ // Send zframe to UDP socket, return -1 if sending failed due to
1020
+ // interface having disappeared (happens easily with WiFi)
1021
+
1022
+ int
1023
+ zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen)
1024
+ {
1025
+ assert (frame);
1026
+ assert (address);
1027
+
1028
+ if (sendto (udpsock,
1029
+ (char *) zframe_data (frame), (int) zframe_size (frame),
1030
+ 0, // Flags
1031
+ (struct sockaddr *) address, addrlen) == -1) {
1032
+ zsys_debug ("zsys_udp_send: failed, reason=%s", strerror (errno));
1033
+ return -1; // UDP broadcast not possible
1034
+ }
1035
+ else
1036
+ return 0;
1037
+ }
1038
+
1039
+
1040
+ // --------------------------------------------------------------------------
1041
+ // Receive zframe from UDP socket, and set address of peer that sent it
1042
+ // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or
1043
+ // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address.
1044
+
1045
+ zframe_t *
1046
+ zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen)
1047
+ {
1048
+ char buffer [UDP_FRAME_MAX];
1049
+ in6addr_t address6;
1050
+ socklen_t address_len = sizeof (in6addr_t);
1051
+ ssize_t size = recvfrom (
1052
+ udpsock,
1053
+ buffer, UDP_FRAME_MAX,
1054
+ 0, // Flags
1055
+ (struct sockaddr *) &address6, &address_len);
1056
+
1057
+ if (size == SOCKET_ERROR)
1058
+ zsys_socket_error ("recvfrom");
1059
+
1060
+ // Get sender address as printable string
1061
+ int rc = getnameinfo ((struct sockaddr *) &address6, address_len,
1062
+ peername, peerlen, NULL, 0, NI_NUMERICHOST);
1063
+
1064
+ if (rc) {
1065
+ zsys_warning ("zsys_udp_recv: getnameinfo failed, reason=%s",
1066
+ gai_strerror (rc));
1067
+ return NULL;
1068
+ }
1069
+
1070
+ // Some platform's getnameinfo, like Solaris, appear not to append the
1071
+ // interface name when parsing a link-local IPv6 address. These addresses
1072
+ // cannot be used without the interface, so we must append it manually.
1073
+ // On Windows, if_indextoname is only available from Vista.
1074
+ #if !defined (__WINDOWS__) || (_WIN32_WINNT >= 0x0600)
1075
+ if (address6.sin6_family == AF_INET6 &&
1076
+ IN6_IS_ADDR_LINKLOCAL (&address6.sin6_addr) &&
1077
+ !strchr (peername, '%')) {
1078
+ char ifname [IF_NAMESIZE] = {0};
1079
+ if_indextoname (address6.sin6_scope_id, ifname);
1080
+ strcat (peername, "%");
1081
+ strcat (peername, ifname);
1082
+ }
1083
+ #endif
1084
+
1085
+ return zframe_new (buffer, size);
1086
+ }
1087
+
1088
+
1089
+ // --------------------------------------------------------------------------
1090
+ // Handle an I/O error on some socket operation; will report and die on
1091
+ // fatal errors, and continue silently on "try again" errors.
1092
+
1093
+ void
1094
+ zsys_socket_error (const char *reason)
1095
+ {
1096
+ bool check_errno;
1097
+
1098
+ #if defined (__WINDOWS__)
1099
+ switch (WSAGetLastError ()) {
1100
+ case WSAEINTR: errno = EINTR; break;
1101
+ case WSAEBADF: errno = EBADF; break;
1102
+ case WSAEWOULDBLOCK: errno = EAGAIN; break;
1103
+ case WSAEINPROGRESS: errno = EAGAIN; break;
1104
+ case WSAENETDOWN: errno = ENETDOWN; break;
1105
+ case WSAECONNRESET: errno = ECONNRESET; break;
1106
+ case WSAECONNABORTED: errno = EPIPE; break;
1107
+ case WSAESHUTDOWN: errno = ECONNRESET; break;
1108
+ case WSAEINVAL: errno = EPIPE; break;
1109
+ case WSAEADDRNOTAVAIL: errno = EADDRNOTAVAIL; break;
1110
+ case WSAEADDRINUSE: errno = EADDRINUSE; break;
1111
+ default: errno = GetLastError ();
1112
+ }
1113
+ #endif
1114
+
1115
+ check_errno = (errno == EAGAIN
1116
+ || errno == ENETDOWN
1117
+ || errno == EHOSTUNREACH
1118
+ || errno == ENETUNREACH
1119
+ || errno == EINTR
1120
+ || errno == EPIPE
1121
+ || errno == ECONNRESET);
1122
+ #if defined (ENOPROTOOPT)
1123
+ check_errno = (check_errno || errno == ENOPROTOOPT);
1124
+ #endif
1125
+ #if defined (EHOSTDOWN)
1126
+ check_errno = (check_errno || errno == EHOSTDOWN);
1127
+ #endif
1128
+ #if defined (EOPNOTSUPP)
1129
+ check_errno = (check_errno || errno == EOPNOTSUPP);
1130
+ #endif
1131
+ #if defined (EWOULDBLOCK)
1132
+ check_errno = (check_errno || errno == EWOULDBLOCK);
1133
+ #endif
1134
+ #if defined (EPROTO)
1135
+ check_errno = (check_errno || errno == EPROTO);
1136
+ #endif
1137
+ #if defined (ENONET)
1138
+ check_errno = (check_errno || errno == ENONET);
1139
+ #endif
1140
+
1141
+ if (check_errno)
1142
+ return; // Ignore error and try again
1143
+ else {
1144
+ zsys_error ("(UDP) error '%s' on %s", strerror (errno), reason);
1145
+ assert (false);
1146
+ }
1147
+ }
1148
+
1149
+
1150
+ // --------------------------------------------------------------------------
1151
+ // Return current host name, for use in public tcp:// endpoints. Caller gets
1152
+ // a freshly allocated string, should free it using zstr_free(). If the host
1153
+ // name is not resolvable, returns NULL.
1154
+
1155
+ char *
1156
+ zsys_hostname (void)
1157
+ {
1158
+ char hostname [NI_MAXHOST];
1159
+ gethostname (hostname, NI_MAXHOST);
1160
+ hostname [NI_MAXHOST - 1] = 0;
1161
+ struct hostent *host = gethostbyname (hostname);
1162
+
1163
+ if (host && host->h_name)
1164
+ return strdup (host->h_name);
1165
+ else
1166
+ return NULL;
1167
+ }
1168
+
1169
+
1170
+ // --------------------------------------------------------------------------
1171
+ // Move the current process into the background. The precise effect depends
1172
+ // on the operating system. On POSIX boxes, moves to a specified working
1173
+ // directory (if specified), closes all file handles, reopens stdin, stdout,
1174
+ // and stderr to the null device, and sets the process to ignore SIGHUP. On
1175
+ // Windows, does nothing. Returns 0 if OK, -1 if there was an error.
1176
+
1177
+ int
1178
+ zsys_daemonize (const char *workdir)
1179
+ {
1180
+ #if (defined (__UNIX__))
1181
+ // Defines umask for new files this process will create
1182
+ mode_t file_mask = 027; // Complement of 0750
1183
+
1184
+ // Recreate our process as a child of init
1185
+ int fork_result = fork ();
1186
+ if (fork_result < 0) // < 0 is an error
1187
+ return -1; // Could not fork
1188
+ else
1189
+ if (fork_result > 0) // > 0 is the parent process
1190
+ exit (0); // End parent process
1191
+
1192
+ // Move to a safe and known directory, which is supplied as an
1193
+ // argument to this function (or not, if workdir is NULL or empty).
1194
+ if (workdir && zsys_dir_change (workdir)) {
1195
+ zsys_error ("cannot chdir to '%s'", workdir);
1196
+ return -1;
1197
+ }
1198
+ // Close all open file descriptors inherited from the parent
1199
+ // process, to reduce the resources we use
1200
+ int file_handle = sysconf (_SC_OPEN_MAX);
1201
+ while (file_handle)
1202
+ close (file_handle--); // Ignore any errors
1203
+
1204
+ // Set the umask for new files we might create
1205
+ umask (file_mask);
1206
+
1207
+ // Set standard input and output to the null device so that any
1208
+ // code that assumes that these files are open will work
1209
+ file_handle = open ("/dev/null", O_RDWR);
1210
+ int fh_stdout = dup (file_handle);
1211
+ int fh_stderr = dup (file_handle);
1212
+ assert (fh_stdout);
1213
+ assert (fh_stderr);
1214
+
1215
+ // Ignore any hangup signal from the controlling console
1216
+ signal (SIGHUP, SIG_IGN);
1217
+ #endif
1218
+ return 0;
1219
+ }
1220
+
1221
+
1222
+ // --------------------------------------------------------------------------
1223
+ // Drop the process ID into the lockfile, with exclusive lock, and switch
1224
+ // the process to the specified group and/or user. Any of the arguments
1225
+ // may be null, indicating a no-op. Returns 0 on success, -1 on failure.
1226
+ // Note if you combine this with zsys_daemonize, run after, not before
1227
+ // that method, or the lockfile will hold the wrong process ID.
1228
+
1229
+ int
1230
+ zsys_run_as (const char *lockfile, const char *group, const char *user)
1231
+ {
1232
+ #if (defined (__UNIX__))
1233
+ // Switch to effective user ID (who owns executable); for
1234
+ // system services this should be root, so that we can write
1235
+ // the PID file into e.g. /var/run/
1236
+ if (seteuid (geteuid ())) {
1237
+ zsys_error ("cannot set effective user id: %s", strerror (errno));
1238
+ return -1;
1239
+ }
1240
+ if (lockfile) {
1241
+ // We enforce a lock on the lockfile, if specified, so that
1242
+ // only one copy of the process can run at once.
1243
+ int handle = open (lockfile, O_RDWR | O_CREAT, 0640);
1244
+ if (handle < 0) {
1245
+ zsys_error ("cannot open lockfile '%s': %s", lockfile, strerror (errno));
1246
+ return -1;
1247
+ }
1248
+ else {
1249
+ struct flock filelock;
1250
+ filelock.l_type = F_WRLCK; // F_RDLCK, F_WRLCK, F_UNLCK
1251
+ filelock.l_whence = SEEK_SET; // SEEK_SET, SEEK_CUR, SEEK_END
1252
+ filelock.l_start = 0; // Offset from l_whence
1253
+ filelock.l_len = 0; // length, 0 = to EOF
1254
+ filelock.l_pid = getpid ();
1255
+ if (fcntl (handle, F_SETLK, &filelock)) {
1256
+ zsys_error ("cannot get lock: %s", strerror (errno));
1257
+ return -1;
1258
+ }
1259
+ }
1260
+ // We record the current process id in the lock file
1261
+ char pid_buffer [32];
1262
+ snprintf (pid_buffer, sizeof (pid_buffer), "%6" PRIi64 "\n", (int64_t)getpid ());
1263
+ if ((size_t) write (handle, pid_buffer, strlen (pid_buffer)) != strlen (pid_buffer)) {
1264
+ zsys_error ("cannot write to lockfile: %s", strerror (errno));
1265
+ close (handle);
1266
+ return -1;
1267
+ }
1268
+ }
1269
+ if (group) {
1270
+ zsys_info ("running under group '%s'", group);
1271
+ struct group *grpbuf = NULL;
1272
+ grpbuf = getgrnam (group);
1273
+ if (grpbuf == NULL || setgid (grpbuf->gr_gid)) {
1274
+ zsys_error ("could not switch group: %s", strerror (errno));
1275
+ return -1;
1276
+ }
1277
+ }
1278
+ if (user) {
1279
+ zsys_info ("running under user '%s'", user);
1280
+ struct passwd *pwdbuf = NULL;
1281
+ pwdbuf = getpwnam (user);
1282
+ if (pwdbuf == NULL || setuid (pwdbuf->pw_uid)) {
1283
+ zsys_error ("could not switch user: %s", strerror (errno));
1284
+ return -1;
1285
+ }
1286
+ }
1287
+ else {
1288
+ // Switch back to real user ID (who started process)
1289
+ if (setuid (getuid ())) {
1290
+ zsys_error ("cannot set real user id: %s", strerror (errno));
1291
+ return -1;
1292
+ }
1293
+ }
1294
+ return 0;
1295
+ #else
1296
+ // This is not yet ported to Windows and should not succeed there.
1297
+ return -1;
1298
+ #endif
1299
+ }
1300
+
1301
+
1302
+ // --------------------------------------------------------------------------
1303
+ // Returns true if the underlying libzmq supports CURVE security.
1304
+ // Uses a heuristic probe according to the version of libzmq being used.
1305
+
1306
+ bool
1307
+ zsys_has_curve (void)
1308
+ {
1309
+ #if defined (ZMQ_CURVE_SERVER)
1310
+ # if defined (ZMQ_HAS_CAPABILITIES)
1311
+ // This is the most modern way of probing libzmq capabilities
1312
+ return zmq_has ("curve") != 0;
1313
+ # else
1314
+ // However trying the zmq_setsockopt will also work
1315
+ int rc = -1; // assume we fail
1316
+ void *ctx = zmq_ctx_new ();
1317
+ if (ctx) {
1318
+ void *pub = zmq_socket (ctx, ZMQ_PUB);
1319
+ if (pub) {
1320
+ int as_server = 1;
1321
+ rc = zmq_setsockopt (pub, ZMQ_CURVE_SERVER, &as_server, sizeof (int));
1322
+ zmq_close (pub);
1323
+ }
1324
+ zmq_term (ctx);
1325
+ }
1326
+ return rc != -1;
1327
+ # endif
1328
+ #else
1329
+ return false;
1330
+ #endif
1331
+ }
1332
+
1333
+
1334
+ // --------------------------------------------------------------------------
1335
+ // Configure the number of I/O threads that ZeroMQ will use. A good
1336
+ // rule of thumb is one thread per gigabit of traffic in or out. The
1337
+ // default is 1, sufficient for most applications. If the environment
1338
+ // variable ZSYS_IO_THREADS is defined, that provides the default.
1339
+ // Note that this method is valid only before any socket is created.
1340
+
1341
+ void
1342
+ zsys_set_io_threads (size_t io_threads)
1343
+ {
1344
+ zsys_init ();
1345
+ ZMUTEX_LOCK (s_mutex);
1346
+ if (s_open_sockets)
1347
+ zsys_error ("zsys_io_threads() is not valid after creating sockets");
1348
+ assert (s_open_sockets == 0);
1349
+
1350
+ s_io_threads = io_threads;
1351
+ #if ZMQ_VERSION < ZMQ_MAKE_VERSION(3, 2, 0)
1352
+ zmq_term (s_process_ctx);
1353
+ s_process_ctx = zmq_init ((int) s_io_threads);
1354
+ #else
1355
+ # if defined (ZMQ_IO_THREADS)
1356
+ zmq_ctx_set (s_process_ctx, ZMQ_IO_THREADS, s_io_threads);
1357
+ # endif
1358
+ #endif
1359
+ ZMUTEX_UNLOCK (s_mutex);
1360
+
1361
+ #if ZMQ_VERSION < ZMQ_MAKE_VERSION(3, 2, 0)
1362
+ // Reinitialised outside of the lock to avoid recursive lock
1363
+ zsys_set_max_msgsz (s_max_msgsz);
1364
+ zsys_set_max_sockets (s_max_sockets);
1365
+ #endif
1366
+ }
1367
+
1368
+
1369
+ // --------------------------------------------------------------------------
1370
+ // Configure the scheduling policy of the ZMQ context thread pool.
1371
+ // Not available on Windows. See the sched_setscheduler man page or sched.h
1372
+ // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY
1373
+ // is defined, that provides the default.
1374
+ // Note that this method is valid only before any socket is created.
1375
+
1376
+ void
1377
+ zsys_set_thread_sched_policy (int policy)
1378
+ {
1379
+ if (policy < 0)
1380
+ return;
1381
+
1382
+ zsys_init ();
1383
+ ZMUTEX_LOCK (s_mutex);
1384
+ // If the app is misusing this method, burn it with fire
1385
+ if (s_open_sockets)
1386
+ zsys_error ("zsys_set_thread_sched_policy() is not valid after"
1387
+ " creating sockets");
1388
+ assert (s_open_sockets == 0);
1389
+ s_thread_sched_policy = policy;
1390
+ #if defined (ZMQ_THREAD_SCHED_POLICY)
1391
+ zmq_ctx_set (s_process_ctx, ZMQ_THREAD_SCHED_POLICY, s_thread_sched_policy);
1392
+ #endif
1393
+ ZMUTEX_UNLOCK (s_mutex);
1394
+ }
1395
+
1396
+
1397
+ // --------------------------------------------------------------------------
1398
+ // Configure the scheduling priority of the ZMQ context thread pool.
1399
+ // Not available on Windows. See the sched_setscheduler man page or sched.h
1400
+ // for more information. If the environment variable ZSYS_THREAD_PRIORITY is
1401
+ // defined, that provides the default.
1402
+ // Note that this method is valid only before any socket is created.
1403
+
1404
+ void
1405
+ zsys_set_thread_priority (int priority)
1406
+ {
1407
+ if (priority < 0)
1408
+ return;
1409
+
1410
+ zsys_init ();
1411
+ ZMUTEX_LOCK (s_mutex);
1412
+ // If the app is misusing this method, burn it with fire
1413
+ if (s_open_sockets)
1414
+ zsys_error ("zsys_set_thread_priority() is not valid after"
1415
+ " creating sockets");
1416
+ assert (s_open_sockets == 0);
1417
+ s_thread_priority = priority;
1418
+ #if defined (ZMQ_THREAD_PRIORITY)
1419
+ zmq_ctx_set (s_process_ctx, ZMQ_THREAD_PRIORITY, s_thread_priority);
1420
+ #endif
1421
+ ZMUTEX_UNLOCK (s_mutex);
1422
+ }
1423
+
1424
+
1425
+ // --------------------------------------------------------------------------
1426
+ // Configure the number of sockets that ZeroMQ will allow. The default
1427
+ // is 1024. The actual limit depends on the system, and you can query it
1428
+ // by using zsys_socket_limit (). A value of zero means "maximum".
1429
+ // Note that this method is valid only before any socket is created.
1430
+
1431
+ void
1432
+ zsys_set_max_sockets (size_t max_sockets)
1433
+ {
1434
+ zsys_init ();
1435
+ ZMUTEX_LOCK (s_mutex);
1436
+ // If the app is misusing this method, burn it with fire
1437
+ if (s_open_sockets)
1438
+ zsys_error ("zsys_max_sockets() is not valid after creating sockets");
1439
+ assert (s_open_sockets == 0);
1440
+ s_max_sockets = max_sockets? max_sockets: zsys_socket_limit ();
1441
+ #if defined (ZMQ_MAX_SOCKETS)
1442
+ zmq_ctx_set (s_process_ctx, ZMQ_MAX_SOCKETS, (int) s_max_sockets);
1443
+ #endif
1444
+ ZMUTEX_UNLOCK (s_mutex);
1445
+ }
1446
+
1447
+
1448
+ // --------------------------------------------------------------------------
1449
+ // Return maximum number of ZeroMQ sockets that the system will support.
1450
+
1451
+ size_t
1452
+ zsys_socket_limit (void)
1453
+ {
1454
+ size_t socket_limit;
1455
+ #if defined (ZMQ_SOCKET_LIMIT)
1456
+ if (s_process_ctx)
1457
+ socket_limit = (size_t) zmq_ctx_get (s_process_ctx, ZMQ_SOCKET_LIMIT);
1458
+ else {
1459
+ void *ctx = zmq_init (1);
1460
+ socket_limit = (size_t) zmq_ctx_get (ctx, ZMQ_SOCKET_LIMIT);
1461
+ zmq_term (ctx);
1462
+ }
1463
+ // ZeroMQ used to report a nonsense value (2^31) which if used would
1464
+ // on zmq_ctx_set (ZMQ_MAX_SOCKETS) cause an out-of-memory error. So
1465
+ // if we're running on an older library, enforce a sane limit.
1466
+ if (socket_limit > 65535)
1467
+ socket_limit = 65535;
1468
+ #else
1469
+ socket_limit = 1024;
1470
+ #endif
1471
+ return socket_limit;
1472
+ }
1473
+
1474
+
1475
+ // --------------------------------------------------------------------------
1476
+ // Configure the maximum allowed size of a message sent.
1477
+ // The default is INT_MAX.
1478
+
1479
+ void
1480
+ zsys_set_max_msgsz (int max_msgsz)
1481
+ {
1482
+ if (max_msgsz < 0)
1483
+ return;
1484
+
1485
+ zsys_init ();
1486
+ ZMUTEX_LOCK (s_mutex);
1487
+ s_max_msgsz = max_msgsz;
1488
+ #if defined (ZMQ_MAX_MSGSZ)
1489
+ zmq_ctx_set (s_process_ctx, ZMQ_MAX_MSGSZ, (int) s_max_msgsz);
1490
+ #endif
1491
+ ZMUTEX_UNLOCK (s_mutex);
1492
+ }
1493
+
1494
+
1495
+ // --------------------------------------------------------------------------
1496
+ // Return maximum message size.
1497
+
1498
+ int
1499
+ zsys_max_msgsz (void)
1500
+ {
1501
+ zsys_init ();
1502
+ ZMUTEX_LOCK (s_mutex);
1503
+ #if defined (ZMQ_MAX_MSGSZ)
1504
+ s_max_msgsz = zmq_ctx_get (s_process_ctx, ZMQ_MAX_MSGSZ);
1505
+ #endif
1506
+ ZMUTEX_UNLOCK (s_mutex);
1507
+ return s_max_msgsz;
1508
+ }
1509
+
1510
+
1511
+ // --------------------------------------------------------------------------
1512
+ // Configure the threshold value of filesystem object age per st_mtime
1513
+ // that should elapse until we consider that object "stable" at the
1514
+ // current zclock_time() moment.
1515
+ // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
1516
+ // which generally depends on host OS, with fallback value of 5000.
1517
+
1518
+ void
1519
+ zsys_set_file_stable_age_msec (int64_t file_stable_age_msec)
1520
+ {
1521
+ if (file_stable_age_msec < 1)
1522
+ return;
1523
+
1524
+ zsys_init ();
1525
+ ZMUTEX_LOCK (s_mutex);
1526
+ s_file_stable_age_msec = file_stable_age_msec;
1527
+ ZMUTEX_UNLOCK (s_mutex);
1528
+ }
1529
+
1530
+
1531
+ // --------------------------------------------------------------------------
1532
+ // Return current threshold value of file stable age in msec.
1533
+ // This can be used in code that chooses to wait for this timeout
1534
+ // before testing if a filesystem object is "stable" or not.
1535
+
1536
+ // Note that the OS timer quantization can bite you, so it may be
1537
+ // reasonably safe to sleep/wait/poll for a larger timeout before
1538
+ // assuming a fault, e.g. the default timer resolution on Windows
1539
+ // is 15.6 ms (per timer interrupt 64 times a second), graphed here:
1540
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx
1541
+ // and Unix/Linux OSes also have different-resolution timers.
1542
+
1543
+ int64_t
1544
+ zsys_file_stable_age_msec (void)
1545
+ {
1546
+ zsys_init ();
1547
+ return s_file_stable_age_msec;
1548
+ }
1549
+
1550
+
1551
+ // --------------------------------------------------------------------------
1552
+ // Configure the default linger timeout in msecs for new zsock instances.
1553
+ // You can also set this separately on each zsock_t instance. The default
1554
+ // linger time is zero, i.e. any pending messages will be dropped. If the
1555
+ // environment variable ZSYS_LINGER is defined, that provides the default.
1556
+ // Note that process exit will typically be delayed by the linger time.
1557
+
1558
+ void
1559
+ zsys_set_linger (size_t linger)
1560
+ {
1561
+ zsys_init ();
1562
+ ZMUTEX_LOCK (s_mutex);
1563
+ s_linger = linger;
1564
+ ZMUTEX_UNLOCK (s_mutex);
1565
+ }
1566
+
1567
+
1568
+ // --------------------------------------------------------------------------
1569
+ // Configure the default outgoing pipe limit (HWM) for new zsock instances.
1570
+ // You can also set this separately on each zsock_t instance. The default
1571
+ // HWM is 1,000, on all versions of ZeroMQ. If the environment variable
1572
+ // ZSYS_SNDHWM is defined, that provides the default. Note that a value of
1573
+ // zero means no limit, i.e. infinite memory consumption.
1574
+
1575
+ void
1576
+ zsys_set_sndhwm (size_t sndhwm)
1577
+ {
1578
+ zsys_init ();
1579
+ ZMUTEX_LOCK (s_mutex);
1580
+ s_sndhwm = sndhwm;
1581
+ ZMUTEX_UNLOCK (s_mutex);
1582
+ }
1583
+
1584
+
1585
+ // --------------------------------------------------------------------------
1586
+ // Configure the default incoming pipe limit (HWM) for new zsock instances.
1587
+ // You can also set this separately on each zsock_t instance. The default
1588
+ // HWM is 1,000, on all versions of ZeroMQ. If the environment variable
1589
+ // ZSYS_RCVHWM is defined, that provides the default. Note that a value of
1590
+ // zero means no limit, i.e. infinite memory consumption.
1591
+
1592
+ void
1593
+ zsys_set_rcvhwm (size_t rcvhwm)
1594
+ {
1595
+ zsys_init ();
1596
+ ZMUTEX_LOCK (s_mutex);
1597
+ s_rcvhwm = rcvhwm;
1598
+ ZMUTEX_UNLOCK (s_mutex);
1599
+ }
1600
+
1601
+
1602
+ // --------------------------------------------------------------------------
1603
+ // Configure the default HWM for zactor internal pipes; this is set on both
1604
+ // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is
1605
+ // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is
1606
+ // defined, that provides the default. Note that a value of zero means no
1607
+ // limit, i.e. infinite memory consumption.
1608
+
1609
+ void
1610
+ zsys_set_pipehwm (size_t pipehwm)
1611
+ {
1612
+ zsys_init ();
1613
+ ZMUTEX_LOCK (s_mutex);
1614
+ s_pipehwm = pipehwm;
1615
+ ZMUTEX_UNLOCK (s_mutex);
1616
+ }
1617
+
1618
+
1619
+ // --------------------------------------------------------------------------
1620
+ // Return the HWM for zactor internal pipes.
1621
+
1622
+ size_t
1623
+ zsys_pipehwm (void)
1624
+ {
1625
+ return s_pipehwm;
1626
+ }
1627
+
1628
+
1629
+ // --------------------------------------------------------------------------
1630
+ // Configure use of IPv6 for new zsock instances. By default sockets accept
1631
+ // and make only IPv4 connections. When you enable IPv6, sockets will accept
1632
+ // and connect to both IPv4 and IPv6 peers. You can override the setting on
1633
+ // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the
1634
+ // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the
1635
+ // default. Note: has no effect on ZMQ v2.
1636
+
1637
+ void
1638
+ zsys_set_ipv6 (int ipv6)
1639
+ {
1640
+ zsys_init ();
1641
+ ZMUTEX_LOCK (s_mutex);
1642
+ s_ipv6 = ipv6;
1643
+ ZMUTEX_UNLOCK (s_mutex);
1644
+ }
1645
+
1646
+
1647
+ // --------------------------------------------------------------------------
1648
+ // Return use of IPv6 for zsock instances.
1649
+
1650
+ int
1651
+ zsys_ipv6 (void)
1652
+ {
1653
+ return s_ipv6;
1654
+ }
1655
+
1656
+
1657
+ // --------------------------------------------------------------------------
1658
+ // Set network interface name to use for broadcasts, particularly zbeacon.
1659
+ // This lets the interface be configured for test environments where required.
1660
+ // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
1661
+ // the default when there is no specified interface. If the environment
1662
+ // variable ZSYS_INTERFACE is set, use that as the default interface name.
1663
+ // Setting the interface to "*" means "use all interfaces".
1664
+
1665
+ void
1666
+ zsys_set_interface (const char *value)
1667
+ {
1668
+ zsys_init ();
1669
+ freen (s_interface);
1670
+ s_interface = strdup (value);
1671
+ assert (s_interface);
1672
+ }
1673
+
1674
+
1675
+ // --------------------------------------------------------------------------
1676
+ // Return network interface to use for broadcasts, or "" if none was set.
1677
+
1678
+ const char *
1679
+ zsys_interface (void)
1680
+ {
1681
+ return s_interface? s_interface: "";
1682
+ }
1683
+
1684
+
1685
+ // --------------------------------------------------------------------------
1686
+ // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon.
1687
+ // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses
1688
+ // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set,
1689
+ // use that as the default IPv6 address.
1690
+
1691
+ void
1692
+ zsys_set_ipv6_address (const char *value)
1693
+ {
1694
+ zsys_init ();
1695
+ freen (s_ipv6_address);
1696
+ s_ipv6_address = strdup (value);
1697
+ assert (s_ipv6_address);
1698
+ }
1699
+
1700
+
1701
+ // --------------------------------------------------------------------------
1702
+ // Return IPv6 address to use for zbeacon reception, or "" if none was set.
1703
+
1704
+ const char *
1705
+ zsys_ipv6_address (void)
1706
+ {
1707
+ return s_ipv6_address? s_ipv6_address: "";
1708
+ }
1709
+
1710
+
1711
+ // --------------------------------------------------------------------------
1712
+ // Set IPv6 multicast address to use for sending zbeacon messages. The default
1713
+ // is fe02::1 (link-local all-node). If the environment variable
1714
+ // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast
1715
+ // address.
1716
+
1717
+ void
1718
+ zsys_set_ipv6_mcast_address (const char *value)
1719
+ {
1720
+ zsys_init ();
1721
+ freen (s_ipv6_mcast_address);
1722
+ s_ipv6_mcast_address = strdup (value);
1723
+ assert (s_ipv6_mcast_address);
1724
+ }
1725
+
1726
+
1727
+ // --------------------------------------------------------------------------
1728
+ // Return IPv6 multicast address to use for sending zbeacon, or
1729
+ // "ff02:0:0:0:0:0:0:1" if none was set.
1730
+
1731
+ const char *
1732
+ zsys_ipv6_mcast_address (void)
1733
+ {
1734
+ return s_ipv6_mcast_address ? s_ipv6_mcast_address : "ff02:0:0:0:0:0:0:1";
1735
+ }
1736
+
1737
+
1738
+ // --------------------------------------------------------------------------
1739
+ // Configure the automatic use of pre-allocated FDs when creating new sockets.
1740
+ // If 0 (default), nothing will happen. Else, when a new socket is bound, the
1741
+ // system API will be used to check if an existing pre-allocated FD with a
1742
+ // matching port (if TCP) or path (if IPC) exists, and if it does it will be
1743
+ // set via the ZMQ_USE_FD socket option so that the library will use it
1744
+ // instead of creating a new socket.
1745
+
1746
+
1747
+ void
1748
+ zsys_set_auto_use_fd (int auto_use_fd)
1749
+ {
1750
+ zsys_init ();
1751
+ ZMUTEX_LOCK (s_mutex);
1752
+ s_auto_use_fd = auto_use_fd;
1753
+ ZMUTEX_UNLOCK (s_mutex);
1754
+ }
1755
+
1756
+
1757
+ // --------------------------------------------------------------------------
1758
+ // Return use of automatic pre-allocated FDs for zsock instances.
1759
+
1760
+ int
1761
+ zsys_auto_use_fd (void)
1762
+ {
1763
+ return s_auto_use_fd;
1764
+ }
1765
+
1766
+
1767
+ // --------------------------------------------------------------------------
1768
+ // Set log identity, which is a string that prefixes all log messages sent
1769
+ // by this process. The log identity defaults to the environment variable
1770
+ // ZSYS_LOGIDENT, if that is set.
1771
+
1772
+ void
1773
+ zsys_set_logident (const char *value)
1774
+ {
1775
+ zsys_init ();
1776
+ freen (s_logident);
1777
+ s_logident = strdup (value);
1778
+ #if defined (__UNIX__)
1779
+ if (s_logsystem)
1780
+ openlog (s_logident, LOG_PID, LOG_USER);
1781
+ #elif defined (__WINDOWS__)
1782
+ // TODO: hook in Windows event log for Windows
1783
+ #endif
1784
+ assert (s_logident);
1785
+ }
1786
+
1787
+
1788
+ // --------------------------------------------------------------------------
1789
+ // Set stream to receive log traffic. By default, log traffic is sent to
1790
+ // stdout. If you set the stream to NULL, no stream will receive the log
1791
+ // traffic (it may still be sent to the system facility).
1792
+
1793
+ void
1794
+ zsys_set_logstream (FILE *stream)
1795
+ {
1796
+ zsys_init ();
1797
+ s_logstream = stream;
1798
+ }
1799
+
1800
+
1801
+ // --------------------------------------------------------------------------
1802
+ // Sends log output to a PUB socket bound to the specified endpoint. To
1803
+ // collect such log output, create a SUB socket, subscribe to the traffic
1804
+ // you care about, and connect to the endpoint. Log traffic is sent as a
1805
+ // single string frame, in the same format as when sent to stdout. The
1806
+ // log system supports a single sender; multiple calls to this method will
1807
+ // bind the same sender to multiple endpoints. To disable the sender, call
1808
+ // this method with a null argument.
1809
+
1810
+ void
1811
+ zsys_set_logsender (const char *endpoint)
1812
+ {
1813
+ zsys_init ();
1814
+ if (endpoint) {
1815
+ // Create log sender if needed
1816
+ if (!s_logsender) {
1817
+ s_logsender = zsock_new_pub(NULL);
1818
+ assert (s_logsender);
1819
+ }
1820
+ // Bind/connect to specified endpoint(s) using zsock_attach() syntax
1821
+ int rc = zsock_attach (s_logsender, endpoint, true);
1822
+ assert (rc == 0);
1823
+ }
1824
+ else
1825
+ if (s_logsender) {
1826
+ zsock_destroy (&s_logsender);
1827
+ }
1828
+ }
1829
+
1830
+
1831
+ // --------------------------------------------------------------------------
1832
+ // Enable or disable logging to the system facility (syslog on POSIX boxes,
1833
+ // event log on Windows). By default this is disabled.
1834
+
1835
+ void
1836
+ zsys_set_logsystem (bool logsystem)
1837
+ {
1838
+ zsys_init ();
1839
+ s_logsystem = logsystem;
1840
+ #if defined (__UNIX__)
1841
+ if (s_logsystem)
1842
+ openlog (s_logident, LOG_PID, LOG_USER);
1843
+ #elif defined (__WINDOWS__)
1844
+ // TODO: hook into Windows event log
1845
+ #endif
1846
+ }
1847
+
1848
+
1849
+ static void
1850
+ s_log (char loglevel, char *string)
1851
+ {
1852
+ #if defined (__UNIX__)
1853
+ # if defined (__UTYPE_ANDROID)
1854
+ int priority = ANDROID_LOG_INFO;
1855
+ if (loglevel == 'E')
1856
+ priority = ANDROID_LOG_ERROR;
1857
+ else
1858
+ if (loglevel == 'W')
1859
+ priority = ANDROID_LOG_WARN;
1860
+ else
1861
+ if (loglevel == 'N')
1862
+ priority = ANDROID_LOG_INFO;
1863
+ else
1864
+ if (loglevel == 'I')
1865
+ priority = ANDROID_LOG_INFO;
1866
+ else
1867
+ if (loglevel == 'D')
1868
+ priority = ANDROID_LOG_DEBUG;
1869
+
1870
+ __android_log_print(priority, "zsys", "%s", string);
1871
+ # else
1872
+ if (s_logsystem) {
1873
+ int priority = LOG_INFO;
1874
+ if (loglevel == 'E')
1875
+ priority = LOG_ERR;
1876
+ else
1877
+ if (loglevel == 'W')
1878
+ priority = LOG_WARNING;
1879
+ else
1880
+ if (loglevel == 'N')
1881
+ priority = LOG_NOTICE;
1882
+ else
1883
+ if (loglevel == 'I')
1884
+ priority = LOG_INFO;
1885
+ else
1886
+ if (loglevel == 'D')
1887
+ priority = LOG_DEBUG;
1888
+
1889
+ syslog (priority, "%s", string);
1890
+ }
1891
+ else
1892
+ # endif
1893
+ #endif
1894
+ if (s_logstream || s_logsender) {
1895
+ time_t curtime = time (NULL);
1896
+ struct tm *loctime = localtime (&curtime);
1897
+ char date [20];
1898
+ strftime (date, 20, "%y-%m-%d %H:%M:%S", loctime);
1899
+ char log_text [1024];
1900
+ if (s_logident)
1901
+ snprintf (log_text, 1024, "%c: (%s) %s %s", loglevel, s_logident, date, string);
1902
+ else
1903
+ snprintf (log_text, 1024, "%c: %s %s", loglevel, date, string);
1904
+
1905
+ if (s_logstream) {
1906
+ fprintf (s_logstream, "%s\n", log_text);
1907
+ fflush (s_logstream);
1908
+ }
1909
+ if (s_logsender)
1910
+ zstr_send (s_logsender, log_text);
1911
+ }
1912
+ }
1913
+
1914
+
1915
+ // --------------------------------------------------------------------------
1916
+ // Log error condition - highest priority
1917
+
1918
+ void
1919
+ zsys_error (const char *format, ...)
1920
+ {
1921
+ va_list argptr;
1922
+ va_start (argptr, format);
1923
+ char *string = zsys_vprintf (format, argptr);
1924
+ va_end (argptr);
1925
+ s_log ('E', string);
1926
+ zstr_free (&string);
1927
+ }
1928
+
1929
+
1930
+ // --------------------------------------------------------------------------
1931
+ // Log warning condition - high priority
1932
+
1933
+ void
1934
+ zsys_warning (const char *format, ...)
1935
+ {
1936
+ va_list argptr;
1937
+ va_start (argptr, format);
1938
+ char *string = zsys_vprintf (format, argptr);
1939
+ va_end (argptr);
1940
+ s_log ('W', string);
1941
+ zstr_free (&string);
1942
+ }
1943
+
1944
+
1945
+ // --------------------------------------------------------------------------
1946
+ // Log normal, but significant, condition - normal priority
1947
+
1948
+ void
1949
+ zsys_notice (const char *format, ...)
1950
+ {
1951
+ va_list argptr;
1952
+ va_start (argptr, format);
1953
+ char *string = zsys_vprintf (format, argptr);
1954
+ va_end (argptr);
1955
+ s_log ('N', string);
1956
+ zstr_free (&string);
1957
+ }
1958
+
1959
+
1960
+ // --------------------------------------------------------------------------
1961
+ // Log informational message - low priority
1962
+
1963
+ void
1964
+ zsys_info (const char *format, ...)
1965
+ {
1966
+ va_list argptr;
1967
+ va_start (argptr, format);
1968
+ char *string = zsys_vprintf (format, argptr);
1969
+ va_end (argptr);
1970
+ s_log ('I', string);
1971
+ zstr_free (&string);
1972
+ }
1973
+
1974
+
1975
+ // --------------------------------------------------------------------------
1976
+ // Log debug-level message - lowest priority
1977
+
1978
+ void
1979
+ zsys_debug (const char *format, ...)
1980
+ {
1981
+ va_list argptr;
1982
+ va_start (argptr, format);
1983
+ char *string = zsys_vprintf (format, argptr);
1984
+ va_end (argptr);
1985
+ s_log ('D', string);
1986
+ zstr_free (&string);
1987
+ }
1988
+
1989
+
1990
+ // --------------------------------------------------------------------------
1991
+ // Selftest
1992
+
1993
+ void
1994
+ zsys_test (bool verbose)
1995
+ {
1996
+ printf (" * zsys: ");
1997
+ if (verbose)
1998
+ printf ("\n");
1999
+
2000
+ // check that we can stop/restart the environnemnt
2001
+ zsys_shutdown();
2002
+ zsys_init();
2003
+ zsys_shutdown();
2004
+ zsys_init();
2005
+
2006
+
2007
+ // @selftest
2008
+ zsys_catch_interrupts ();
2009
+
2010
+ // Check capabilities without using the return value
2011
+ int rc = zsys_has_curve ();
2012
+
2013
+ const char *SELFTEST_DIR_RW = "src/selftest-rw";
2014
+
2015
+ if (verbose) {
2016
+ char *hostname = zsys_hostname ();
2017
+ zsys_info ("host name is %s", hostname);
2018
+ freen (hostname);
2019
+ zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ());
2020
+ }
2021
+ zsys_set_file_stable_age_msec (5123);
2022
+ assert (zsys_file_stable_age_msec() == 5123);
2023
+ zsys_set_file_stable_age_msec (-1);
2024
+ assert (zsys_file_stable_age_msec() == 5123);
2025
+ zsys_set_linger (0);
2026
+ zsys_set_sndhwm (1000);
2027
+ zsys_set_rcvhwm (1000);
2028
+ zsys_set_pipehwm (2500);
2029
+ assert (zsys_pipehwm () == 2500);
2030
+ zsys_set_ipv6 (0);
2031
+ zsys_set_thread_priority (-1);
2032
+ zsys_set_thread_sched_policy (-1);
2033
+
2034
+ // Test pipe creation
2035
+ zsock_t *pipe_back;
2036
+ zsock_t *pipe_front = zsys_create_pipe (&pipe_back);
2037
+ zstr_send (pipe_front, "Hello");
2038
+ char *string = zstr_recv (pipe_back);
2039
+ assert (streq (string, "Hello"));
2040
+ freen (string);
2041
+ zsock_destroy (&pipe_back);
2042
+ zsock_destroy (&pipe_front);
2043
+
2044
+ // Test file manipulation
2045
+
2046
+ // Don't let anyone fool our workspace
2047
+ if (zsys_file_exists ("nosuchfile")) {
2048
+ zsys_warning ("zsys_test() had to remove 'nosuchfile' which was not expected here at all");
2049
+ zsys_file_delete ("nosuchfile");
2050
+ }
2051
+
2052
+ rc = zsys_file_delete ("nosuchfile");
2053
+ assert (rc == -1);
2054
+
2055
+ bool rc_bool = zsys_file_exists ("nosuchfile");
2056
+ assert (rc_bool != true);
2057
+
2058
+ rc = (int) zsys_file_size ("nosuchfile");
2059
+ assert (rc == -1);
2060
+
2061
+ time_t when = zsys_file_modified (".");
2062
+ assert (when > 0);
2063
+
2064
+ int mode = zsys_file_mode (".");
2065
+ assert (S_ISDIR (mode));
2066
+ assert (mode & S_IRUSR);
2067
+ assert (mode & S_IWUSR);
2068
+
2069
+ const char *testbasedir = ".testsys";
2070
+ const char *testsubdir = "subdir";
2071
+ char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW
2072
+ char *dirpath = NULL; // subdir in a test, under basedirpath
2073
+ char *relsubdir = NULL; // relative short "path" of subdir under testbasedir
2074
+
2075
+ basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir);
2076
+ assert (basedirpath);
2077
+ dirpath = zsys_sprintf ("%s/%s", basedirpath, testsubdir);
2078
+ assert (dirpath);
2079
+ relsubdir = zsys_sprintf ("%s/%s", testbasedir, testsubdir);
2080
+ assert (relsubdir);
2081
+
2082
+ // Normally tests clean up in the end, but if a selftest run dies
2083
+ // e.g. on assert(), workspace remains dirty. Better clean it up.
2084
+ // We do not really care about results here - we clean up a possible
2085
+ // dirty exit of an older build. If there are permission errors etc.
2086
+ // the actual tests below would explode.
2087
+ if (zsys_file_exists(dirpath)) {
2088
+ if (verbose)
2089
+ zsys_debug ("zsys_test() has to remove ./%s that should not have been here", dirpath);
2090
+ zsys_dir_delete (dirpath);
2091
+ }
2092
+ if (zsys_file_exists (basedirpath)) {
2093
+ if (verbose)
2094
+ zsys_debug ("zsys_test() has to remove ./%s that should not have been here", basedirpath);
2095
+ zsys_dir_delete (basedirpath);
2096
+ }
2097
+
2098
+ // Added tracing because this file-age check fails on some systems
2099
+ // presumably due to congestion in a mass-build and valgrind on top
2100
+ zsys_file_mode_private ();
2101
+ if (verbose)
2102
+ printf ("zsys_test() at timestamp %" PRIi64 ": "
2103
+ "Creating %s\n",
2104
+ zclock_time(), relsubdir );
2105
+ rc = zsys_dir_create ("%s/%s", SELFTEST_DIR_RW, relsubdir);
2106
+ if (verbose)
2107
+ printf ("zsys_test() at timestamp %" PRIi64 ": "
2108
+ "Finished creating %s with return-code %d\n",
2109
+ zclock_time(), relsubdir, rc );
2110
+ assert (rc == 0);
2111
+ when = zsys_file_modified (dirpath);
2112
+ if (verbose)
2113
+ printf ("zsys_test() at timestamp %" PRIi64 ": "
2114
+ "Finished calling zsys_file_modified(), got age %jd\n",
2115
+ zclock_time(), (intmax_t)when );
2116
+ assert (when > 0);
2117
+ if (verbose)
2118
+ printf ("zsys_test() at timestamp %" PRIi64 ": "
2119
+ "Checking if file is NOT stable (is younger than 1 sec)\n",
2120
+ zclock_time() );
2121
+ assert (!s_zsys_file_stable (dirpath, verbose));
2122
+ if (verbose)
2123
+ printf ("zsys_test() at timestamp %" PRIi64 ": "
2124
+ "Passed the test, file is not stable - as expected\n",
2125
+ zclock_time() );
2126
+ rc = zsys_dir_delete ("%s/%s", SELFTEST_DIR_RW, relsubdir);
2127
+ assert (rc == 0);
2128
+ rc = zsys_dir_delete ("%s/%s", SELFTEST_DIR_RW, testbasedir);
2129
+ assert (rc == 0);
2130
+ zsys_file_mode_default ();
2131
+
2132
+ #if (defined (PATH_MAX))
2133
+ char cwd[PATH_MAX];
2134
+ #else
2135
+ # if (defined (_MAX_PATH))
2136
+ char cwd[_MAX_PATH];
2137
+ # else
2138
+ char cwd[1024];
2139
+ # endif
2140
+ #endif
2141
+ memset (cwd, 0, sizeof(cwd));
2142
+ #if (defined (WIN32))
2143
+ if (_getcwd(cwd, sizeof(cwd)) != NULL) {
2144
+ #else
2145
+ if (getcwd(cwd, sizeof(cwd)) != NULL) {
2146
+ #endif
2147
+ if (verbose)
2148
+ printf ("zsys_test() at timestamp %" PRIi64 ": "
2149
+ "current working directory is %s\n",
2150
+ zclock_time(), cwd);
2151
+ assert (zsys_dir_change (SELFTEST_DIR_RW) == 0);
2152
+ assert (zsys_dir_change (cwd) == 0);
2153
+ }
2154
+ else {
2155
+ zsys_warning ("zsys_test() : got getcwd() error... "
2156
+ "testing zsys_dir_change() anyway, but it can confuse "
2157
+ "subsequent tests in this process");
2158
+ assert (zsys_dir_change (SELFTEST_DIR_RW) == 0);
2159
+ }
2160
+
2161
+ zstr_free (&basedirpath);
2162
+ zstr_free (&dirpath);
2163
+ zstr_free (&relsubdir);
2164
+
2165
+ // Other subtests
2166
+ int major, minor, patch;
2167
+ zsys_version (&major, &minor, &patch);
2168
+ assert (major == CZMQ_VERSION_MAJOR);
2169
+ assert (minor == CZMQ_VERSION_MINOR);
2170
+ assert (patch == CZMQ_VERSION_PATCH);
2171
+
2172
+ string = zsys_sprintf ("%s %02x", "Hello", 16);
2173
+ assert (streq (string, "Hello 10"));
2174
+ freen (string);
2175
+
2176
+ char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,.";
2177
+ int num10 = 1234567890;
2178
+ string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10);
2179
+ assert (strlen (string) == (4 * 64 + 10));
2180
+ freen (string);
2181
+
2182
+ // Test logging system
2183
+ zsys_set_logident ("czmq_selftest");
2184
+ zsys_set_logsender ("inproc://logging");
2185
+ void *logger = zsys_socket (ZMQ_SUB, NULL, 0);
2186
+ assert (logger);
2187
+ rc = zmq_connect (logger, "inproc://logging");
2188
+ assert (rc == 0);
2189
+ rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0);
2190
+ assert (rc == 0);
2191
+
2192
+ if (verbose) {
2193
+ zsys_error ("This is an %s message", "error");
2194
+ zsys_warning ("This is a %s message", "warning");
2195
+ zsys_notice ("This is a %s message", "notice");
2196
+ zsys_info ("This is a %s message", "info");
2197
+ zsys_debug ("This is a %s message", "debug");
2198
+ zsys_set_logident ("hello, world");
2199
+ zsys_info ("This is a %s message", "info");
2200
+ zsys_debug ("This is a %s message", "debug");
2201
+
2202
+ // Check that logsender functionality is working
2203
+ char *received = zstr_recv (logger);
2204
+ assert (received);
2205
+ zstr_free (&received);
2206
+ }
2207
+ zsys_close (logger, NULL, 0);
2208
+ // @end
2209
+
2210
+ zsys_set_auto_use_fd (1);
2211
+ assert (zsys_auto_use_fd () == 1);
2212
+
2213
+ assert (zsys_max_msgsz () == INT_MAX);
2214
+ zsys_set_max_msgsz (2000);
2215
+ assert (zsys_max_msgsz () == 2000);
2216
+ zsys_set_max_msgsz (-1);
2217
+ assert (zsys_max_msgsz () == 2000);
2218
+
2219
+
2220
+ #if defined (__WINDOWS__)
2221
+ zsys_shutdown();
2222
+ #endif
2223
+
2224
+ printf ("OK\n");
2225
+ }