From 191fe27d2a9739840ef151fda913fd44dce40b09 Mon Sep 17 00:00:00 2001 From: Kevin Sapper Date: Fri, 24 May 2019 14:30:31 +0200 Subject: [PATCH] Problem: Zyre out of sync with zproject Solution: Re-generate it! --- CMakeLists.txt | 10 +- Dockerfile | 2 +- Findlibzmq.cmake | 70 ++++- bindings/delphi/libzyre.pas | 114 ++++---- bindings/jni/build.gradle | 13 +- .../src/main/java/org/zeromq/zyre/Zyre.java | 13 + .../main/java/org/zeromq/zyre/ZyreEvent.java | 13 + bindings/python/_project.py | 17 ++ bindings/python_cffi/zyre_cffi/Zyre.py | 34 +-- bindings/python_cffi/zyre_cffi/ZyreEvent.py | 1 + bindings/python_cffi/zyre_cffi/cdefs.py | 256 ++++++++++++++++-- bindings/qt/src/qzframe.cpp | 4 +- bindings/qt/src/qzframe.h | 2 +- ci_deploy_obs.sh | 7 +- configure.ac | 32 ++- src/zyre_classes.h | 4 +- 16 files changed, 462 insertions(+), 130 deletions(-) create mode 100644 bindings/python/_project.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 020b529bb..e3101e2a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,9 @@ if (NOT HAVE_NET_IF_H) CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H) endif() -file(WRITE "${SOURCE_DIR}/src/platform.h.in" " +file(REMOVE "${SOURCE_DIR}/src/platform.h") + +file(WRITE "${CMAKE_BINARY_DIR}/platform.h.in" " #cmakedefine HAVE_LINUX_WIRELESS_H #cmakedefine HAVE_NET_IF_H #cmakedefine HAVE_NET_IF_MEDIA_H @@ -80,7 +82,7 @@ file(WRITE "${SOURCE_DIR}/src/platform.h.in" " #cmakedefine HAVE_FREEIFADDRS ") -configure_file("${SOURCE_DIR}/src/platform.h.in" "${SOURCE_DIR}/src/platform.h") +configure_file("${CMAKE_BINARY_DIR}/platform.h.in" "${CMAKE_BINARY_DIR}/platform.h") #The MSVC C compiler is too out of date, #so the sources have to be compiled as c++ @@ -181,7 +183,7 @@ install(FILES ${zyre_headers} DESTINATION include) ######################################################################## -include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include") +include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include" "${CMAKE_BINARY_DIR}") set (zyre_sources src/zyre.c src/zyre_event.c @@ -556,7 +558,7 @@ set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt ${CMAKE_BINARY_DIR}/DartConfiguration.tcl ${CMAKE_BINARY_DIR}/Testing ${CMAKE_BINARY_DIR}/compile_commands.json - ${CMAKE_BINARY_DIR}/src/platform.h + ${CMAKE_BINARY_DIR}/platform.h ${CMAKE_BINARY_DIR}/src/libzyre.pc ${CMAKE_BINARY_DIR}/src/libzyre.so ${CMAKE_BINARY_DIR}/src/zyre_selftest diff --git a/Dockerfile b/Dockerfile index 89c227a85..f4e397af2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN sudo make install RUN sudo ldconfig WORKDIR /home/zmq -RUN git clone --quiet git://github.com/zeromq/zyre.git zyre +RUN git clone --quiet https://github.com/zeromq/zyre zyre WORKDIR /home/zmq/zyre RUN ./autogen.sh 2> /dev/null RUN ./configure --quiet --without-docs diff --git a/Findlibzmq.cmake b/Findlibzmq.cmake index 0a563dd86..b8d16d1d2 100644 --- a/Findlibzmq.cmake +++ b/Findlibzmq.cmake @@ -23,11 +23,71 @@ find_path ( HINTS ${PC_LIBZMQ_INCLUDE_HINTS} ) -find_library ( - LIBZMQ_LIBRARIES - NAMES zmq - HINTS ${PC_LIBZMQ_LIBRARY_HINTS} -) +if (MSVC) + # libzmq dll/lib built with MSVC is named using the Boost convention. + # https://github.com/zeromq/czmq/issues/577 + # https://github.com/zeromq/czmq/issues/1972 + if (MSVC_IDE) + set(MSVC_TOOLSET "-${CMAKE_VS_PLATFORM_TOOLSET}") + else () + set(MSVC_TOOLSET "") + endif () + + # Retrieve ZeroMQ version number from zmq.h + file(STRINGS "${LIBZMQ_INCLUDE_DIRS}/zmq.h" zmq_version_defines + REGEX "#define ZMQ_VERSION_(MAJOR|MINOR|PATCH)") + foreach(ver ${zmq_version_defines}) + if(ver MATCHES "#define ZMQ_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$") + set(ZMQ_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") + endif() + endforeach() + + set(_zmq_version ${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}) + + set(_zmq_debug_names) + set(_zmq_release_names) + + set(_zmq_debug_names + "libzmq${MSVC_TOOLSET}-mt-gd-${_zmq_version}" # Debug, BUILD_SHARED + "libzmq${MSVC_TOOLSET}-mt-sgd-${_zmq_version}" # Debug, BUILD_STATIC + "libzmq-mt-gd-${_zmq_version}" # Debug, BUILD_SHARED + "libzmq-mt-sgd-${_zmq_version}" # Debug, BUILD_STATIC + ) + + set(_zmq_release_names + "libzmq${MSVC_TOOLSET}-mt-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_SHARED + "libzmq${MSVC_TOOLSET}-mt-s-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_STATIC + "libzmq-mt-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_SHARED + "libzmq-mt-s-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_STATIC + ) + + find_library (ZeroMQ_LIBRARY_DEBUG + NAMES ${_zmq_debug_names} + ) + + find_library (ZeroMQ_LIBRARY_RELEASE + NAMES ${_zmq_release_names} + ) + + if (ZeroMQ_LIBRARY_RELEASE AND ZeroMQ_LIBRARY_DEBUG) + set(LIBZMQ_LIBRARIES + debug ${ZeroMQ_LIBRARY_DEBUG} + optimized ${ZeroMQ_LIBRARY_RELEASE} + ) + elseif (ZeroMQ_LIBRARY_RELEASE) + set(LIBZMQ_LIBRARIES ${ZeroMQ_LIBRARY_RELEASE}) + elseif (ZeroMQ_LIBRARY_DEBUG) + set(LIBZMQ_LIBRARIES ${ZeroMQ_LIBRARY_DEBUG}) + endif () +endif () + +if (NOT LIBZMQ_LIBRARIES) + find_library ( + LIBZMQ_LIBRARIES + NAMES zmq libzmq + HINTS ${PC_LIBZMQ_LIBRARY_HINTS} + ) +endif () include(FindPackageHandleStandardArgs) diff --git a/bindings/delphi/libzyre.pas b/bindings/delphi/libzyre.pas index 69466f92a..e6d2857d8 100644 --- a/bindings/delphi/libzyre.pas +++ b/bindings/delphi/libzyre.pas @@ -9,6 +9,10 @@ unit libzyre; +{$if defined(MSWINDOWS)} + {$warn SYMBOL_PLATFORM off} +{$ifend} + interface uses @@ -34,62 +38,62 @@ interface // node it is silent and invisible to other nodes on the network. // The node name is provided to other nodes during discovery. If you // specify NULL, Zyre generates a randomized node name from the UUID. - function zyre_new(Name: PAnsiChar): PZyre; cdecl; external lib_zyre; + function zyre_new(Name: PAnsiChar): PZyre; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Destructor, destroys a Zyre node. When you destroy a node, any // messages it is sending or receiving will be discarded. - procedure zyre_destroy(var self: PZyre); cdecl; external lib_zyre; + procedure zyre_destroy(var self: PZyre); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return our node UUID string, after successful initialization - function zyre_uuid(self: PZyre): PAnsiChar; cdecl; external lib_zyre; + function zyre_uuid(self: PZyre): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return our node name, after successful initialization. First 6 // characters of UUID by default. - function zyre_name(self: PZyre): PAnsiChar; cdecl; external lib_zyre; + function zyre_name(self: PZyre): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set the public name of this node overriding the default. The name is // provide during discovery and come in each ENTER message. - procedure zyre_set_name(self: PZyre; Name: PAnsiChar); cdecl; external lib_zyre; + procedure zyre_set_name(self: PZyre; Name: PAnsiChar); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set node header; these are provided to other nodes during discovery // and come in each ENTER message. - procedure zyre_set_header(self: PZyre; Name: PAnsiChar; Format: PAnsiChar); cdecl; varargs; external lib_zyre; + procedure zyre_set_header(self: PZyre; Name: PAnsiChar; Format: PAnsiChar); cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set verbose mode; this tells the node to log all traffic as well as // all major events. - procedure zyre_set_verbose(self: PZyre); cdecl; external lib_zyre; + procedure zyre_set_verbose(self: PZyre); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set UDP beacon discovery port; defaults to 5670, this call overrides // that so you can create independent clusters on the same network, for // e.g. development vs. production. Has no effect after zyre_start(). - procedure zyre_set_port(self: PZyre; PortNbr: Integer); cdecl; external lib_zyre; + procedure zyre_set_port(self: PZyre; PortNbr: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set the TCP port bound by the ROUTER peer-to-peer socket (beacon mode). // Defaults to * (the port is randomly assigned by the system). // This call overrides this, to bypass some firewall issues when ports are // random. Has no effect after zyre_start(). - procedure zyre_set_beacon_peer_port(self: PZyre; PortNbr: Integer); cdecl; external lib_zyre; + procedure zyre_set_beacon_peer_port(self: PZyre; PortNbr: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set the peer evasiveness timeout, in milliseconds. Default is 5000. // This can be tuned in order to deal with expected network conditions // and the response time expected by the application. This is tied to // the beacon interval and rate of messages received. - procedure zyre_set_evasive_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre; + procedure zyre_set_evasive_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set the peer expiration timeout, in milliseconds. Default is 30000. // This can be tuned in order to deal with expected network conditions // and the response time expected by the application. This is tied to // the beacon interval and rate of messages received. - procedure zyre_set_expired_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre; + procedure zyre_set_expired_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set UDP beacon discovery interval, in milliseconds. Default is instant // beacon exploration followed by pinging every 1,000 msecs. - procedure zyre_set_interval(self: PZyre; Interval: NativeUInt); cdecl; external lib_zyre; + procedure zyre_set_interval(self: PZyre; Interval: NativeUInt); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set network interface for UDP beacons. If you do not set this, CZMQ will // choose an interface for you. On boxes with several interfaces you should // specify which one you want to use, or strange things can happen. - procedure zyre_set_interface(self: PZyre; Value: PAnsiChar); cdecl; external lib_zyre; + procedure zyre_set_interface(self: PZyre; Value: PAnsiChar); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // By default, Zyre binds to an ephemeral TCP port and broadcasts the local // host name using UDP beaconing. When you call this method, Zyre will use @@ -99,113 +103,113 @@ interface // inproc://, ipc://, or tcp:// transports (for tcp://, use an IP address // that is meaningful to remote as well as local nodes). Returns 0 if // the bind was successful, else -1. - function zyre_set_endpoint(self: PZyre; Format: PAnsiChar): Integer; cdecl; varargs; external lib_zyre; + function zyre_set_endpoint(self: PZyre; Format: PAnsiChar): Integer; cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // This options enables a peer to actively contest for leadership in the // given group. If this option is not set the peer will still participate in // elections but never gets elected. This ensures that a consent for a leader // is reached within a group even though not every peer is contesting for // leadership. - procedure zyre_set_contest_in_group(self: PZyre; Group: PAnsiChar); cdecl; external lib_zyre; + procedure zyre_set_contest_in_group(self: PZyre; Group: PAnsiChar); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set an alternative endpoint value when using GOSSIP ONLY. This is useful // if you're advertising an endpoint behind a NAT. - procedure zyre_set_advertised_endpoint(self: PZyre; Value: PAnsiChar); cdecl; external lib_zyre; + procedure zyre_set_advertised_endpoint(self: PZyre; Value: PAnsiChar); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Apply a azcert to a Zyre node. - procedure zyre_set_zcert(self: PZyre; Zcert: PZcert); cdecl; external lib_zyre; + procedure zyre_set_zcert(self: PZyre; Zcert: PZcert); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Specify the ZAP domain (for use with CURVE). - procedure zyre_set_zap_domain(self: PZyre; Domain: PAnsiChar); cdecl; external lib_zyre; + procedure zyre_set_zap_domain(self: PZyre; Domain: PAnsiChar); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set-up gossip discovery of other nodes. At least one node in the cluster // must bind to a well-known gossip endpoint, so other nodes can connect to // it. Note that gossip endpoints are completely distinct from Zyre node // endpoints, and should not overlap (they can use the same transport). - procedure zyre_gossip_bind(self: PZyre; Format: PAnsiChar); cdecl; varargs; external lib_zyre; + procedure zyre_gossip_bind(self: PZyre; Format: PAnsiChar); cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set-up gossip discovery of other nodes. A node may connect to multiple // other nodes, for redundancy paths. For details of the gossip network // design, see the CZMQ zgossip class. - procedure zyre_gossip_connect(self: PZyre; Format: PAnsiChar); cdecl; varargs; external lib_zyre; + procedure zyre_gossip_connect(self: PZyre; Format: PAnsiChar); cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Set-up gossip discovery with CURVE enabled. - procedure zyre_gossip_connect_curve(self: PZyre; PublicKey: PAnsiChar; Format: PAnsiChar); cdecl; varargs; external lib_zyre; + procedure zyre_gossip_connect_curve(self: PZyre; PublicKey: PAnsiChar; Format: PAnsiChar); cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Unpublish a GOSSIP node from local list, useful in removing nodes from list when they EXIT - procedure zyre_gossip_unpublish(self: PZyre; Node: PAnsiChar); cdecl; external lib_zyre; + procedure zyre_gossip_unpublish(self: PZyre; Node: PAnsiChar); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Start node, after setting header values. When you start a node it // begins discovery and connection. Returns 0 if OK, -1 if it wasn't // possible to start the node. - function zyre_start(self: PZyre): Integer; cdecl; external lib_zyre; + function zyre_start(self: PZyre): Integer; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Stop node; this signals to other peers that this node will go away. // This is polite; however you can also just destroy the node without // stopping it. - procedure zyre_stop(self: PZyre); cdecl; external lib_zyre; + procedure zyre_stop(self: PZyre); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Join a named group; after joining a group you can send messages to // the group and all Zyre nodes in that group will receive them. - function zyre_join(self: PZyre; Group: PAnsiChar): Integer; cdecl; external lib_zyre; + function zyre_join(self: PZyre; Group: PAnsiChar): Integer; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Leave a group - function zyre_leave(self: PZyre; Group: PAnsiChar): Integer; cdecl; external lib_zyre; + function zyre_leave(self: PZyre; Group: PAnsiChar): Integer; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Receive next message from network; the message may be a control // message (ENTER, EXIT, JOIN, LEAVE) or data (WHISPER, SHOUT). // Returns zmsg_t object, or NULL if interrupted - function zyre_recv(self: PZyre): PZmsg; cdecl; external lib_zyre; + function zyre_recv(self: PZyre): PZmsg; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Send message to single peer, specified as a UUID string // Destroys message after sending - function zyre_whisper(self: PZyre; Peer: PAnsiChar; var MsgP: PZmsg): Integer; cdecl; external lib_zyre; + function zyre_whisper(self: PZyre; Peer: PAnsiChar; var MsgP: PZmsg): Integer; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Send message to a named group // Destroys message after sending - function zyre_shout(self: PZyre; Group: PAnsiChar; var MsgP: PZmsg): Integer; cdecl; external lib_zyre; + function zyre_shout(self: PZyre; Group: PAnsiChar; var MsgP: PZmsg): Integer; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Send formatted string to a single peer specified as UUID string - function zyre_whispers(self: PZyre; Peer: PAnsiChar; Format: PAnsiChar): Integer; cdecl; varargs; external lib_zyre; + function zyre_whispers(self: PZyre; Peer: PAnsiChar; Format: PAnsiChar): Integer; cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Send formatted string to a named group - function zyre_shouts(self: PZyre; Group: PAnsiChar; Format: PAnsiChar): Integer; cdecl; varargs; external lib_zyre; + function zyre_shouts(self: PZyre; Group: PAnsiChar; Format: PAnsiChar): Integer; cdecl; varargs; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return zlist of current peer ids. - function zyre_peers(self: PZyre): PZlist; cdecl; external lib_zyre; + function zyre_peers(self: PZyre): PZlist; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return zlist of current peers of this group. - function zyre_peers_by_group(self: PZyre; Name: PAnsiChar): PZlist; cdecl; external lib_zyre; + function zyre_peers_by_group(self: PZyre; Name: PAnsiChar): PZlist; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return zlist of currently joined groups. - function zyre_own_groups(self: PZyre): PZlist; cdecl; external lib_zyre; + function zyre_own_groups(self: PZyre): PZlist; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return zlist of groups known through connected peers. - function zyre_peer_groups(self: PZyre): PZlist; cdecl; external lib_zyre; + function zyre_peer_groups(self: PZyre): PZlist; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return the endpoint of a connected peer. // Returns empty string if peer does not exist. - function zyre_peer_address(self: PZyre; Peer: PAnsiChar): PAnsiChar; cdecl; external lib_zyre; + function zyre_peer_address(self: PZyre; Peer: PAnsiChar): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return the value of a header of a conected peer. // Returns null if peer or key doesn't exits. - function zyre_peer_header_value(self: PZyre; Peer: PAnsiChar; Name: PAnsiChar): PAnsiChar; cdecl; external lib_zyre; + function zyre_peer_header_value(self: PZyre; Peer: PAnsiChar; Name: PAnsiChar): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Explicitly connect to a peer - function zyre_require_peer(self: PZyre; Uuid: PAnsiChar; Endpoint: PAnsiChar; PublicKey: PAnsiChar): Integer; cdecl; external lib_zyre; + function zyre_require_peer(self: PZyre; Uuid: PAnsiChar; Endpoint: PAnsiChar; PublicKey: PAnsiChar): Integer; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return socket for talking to the Zyre node, for polling - function zyre_socket(self: PZyre): PZsock; cdecl; external lib_zyre; + function zyre_socket(self: PZyre): PZsock; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Print zyre node information to stdout - procedure zyre_print(self: PZyre); cdecl; external lib_zyre; + procedure zyre_print(self: PZyre); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return the Zyre version for run-time API detection; returns // major * 10000 + minor * 100 + patch, as a single integer. - function zyre_version: UInt64; cdecl; external lib_zyre; + function zyre_version: UInt64; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Self test of this class. - procedure zyre_test(Verbose: Boolean); cdecl; external lib_zyre; + procedure zyre_test(Verbose: Boolean); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; (* ZyreEvent *) (* Parsing Zyre messages *) @@ -213,48 +217,48 @@ interface // Constructor: receive an event from the zyre node, wraps zyre_recv. // The event may be a control message (ENTER, EXIT, JOIN, LEAVE) or // data (WHISPER, SHOUT). - function zyre_event_new(Node: PZyre): PZyreEvent; cdecl; external lib_zyre; + function zyre_event_new(Node: PZyre): PZyreEvent; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Destructor; destroys an event instance - procedure zyre_event_destroy(var self: PZyreEvent); cdecl; external lib_zyre; + procedure zyre_event_destroy(var self: PZyreEvent); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Returns event type, as printable uppercase string. Choices are: // "ENTER", "EXIT", "JOIN", "LEAVE", "EVASIVE", "WHISPER" and "SHOUT" // and for the local node: "STOP" - function zyre_event_type(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre; + function zyre_event_type(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return the sending peer's uuid as a string - function zyre_event_peer_uuid(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre; + function zyre_event_peer_uuid(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return the sending peer's public name as a string - function zyre_event_peer_name(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre; + function zyre_event_peer_name(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Return the sending peer's ipaddress as a string - function zyre_event_peer_addr(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre; + function zyre_event_peer_addr(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Returns the event headers, or NULL if there are none - function zyre_event_headers(self: PZyreEvent): PZhash; cdecl; external lib_zyre; + function zyre_event_headers(self: PZyreEvent): PZhash; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Returns value of a header from the message headers // obtained by ENTER. Return NULL if no value was found. - function zyre_event_header(self: PZyreEvent; Name: PAnsiChar): PAnsiChar; cdecl; external lib_zyre; + function zyre_event_header(self: PZyreEvent; Name: PAnsiChar): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Returns the group name that a SHOUT event was sent to - function zyre_event_group(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre; + function zyre_event_group(self: PZyreEvent): PAnsiChar; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Returns the incoming message payload; the caller can modify the // message but does not own it and should not destroy it. - function zyre_event_msg(self: PZyreEvent): PZmsg; cdecl; external lib_zyre; + function zyre_event_msg(self: PZyreEvent): PZmsg; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Returns the incoming message payload, and pass ownership to the // caller. The caller must destroy the message when finished with it. // After called on the given event, further calls will return NULL. - function zyre_event_get_msg(self: PZyreEvent): PZmsg; cdecl; external lib_zyre; + function zyre_event_get_msg(self: PZyreEvent): PZmsg; cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Print event to zsys log - procedure zyre_event_print(self: PZyreEvent); cdecl; external lib_zyre; + procedure zyre_event_print(self: PZyreEvent); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; // Self test of this class. - procedure zyre_event_test(Verbose: Boolean); cdecl; external lib_zyre; + procedure zyre_event_test(Verbose: Boolean); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; implementation end. diff --git a/bindings/jni/build.gradle b/bindings/jni/build.gradle index cfa0563db..0024c42df 100644 --- a/bindings/jni/build.gradle +++ b/bindings/jni/build.gradle @@ -31,7 +31,7 @@ dependencies { testCompile 'org.hamcrest:hamcrest-all:1.3' } -wrapper.gradleVersion = '5.0' +wrapper.gradleVersion = '5.4.1' // ------------------------------------------------------------------ // Build section @@ -55,7 +55,16 @@ task initCMake(type: Exec, dependsOn: 'generateJniHeaders') { task buildNative(type: Exec, dependsOn: 'initCMake') { commandLine "make" } + +task copyLibs(type: Copy) { + from "/usr/lib/libzyre.so", "/usr/local/lib/libzyre.so", "/tmp/lib/libzyre.so", + "/usr/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/tmp/lib/libzmq.so", + "/usr/lib/libczmq.so", "/usr/local/lib/libczmq.so", "/tmp/lib/libczmq.so" + into "." +} + jar.dependsOn buildNative +jar.dependsOn copyLibs test.dependsOn buildNative jar { @@ -133,5 +142,5 @@ bintray { clean.doFirst { delete "${rootDir}/CMakeCache.txt" - delete "${rootDir}/libczmqjni.so" + delete fileTree("${rootDir}") { include "*.so" } } diff --git a/bindings/jni/src/main/java/org/zeromq/zyre/Zyre.java b/bindings/jni/src/main/java/org/zeromq/zyre/Zyre.java index 1e709156b..bd2502291 100644 --- a/bindings/jni/src/main/java/org/zeromq/zyre/Zyre.java +++ b/bindings/jni/src/main/java/org/zeromq/zyre/Zyre.java @@ -6,6 +6,7 @@ */ package org.zeromq.zyre; +import java.util.stream.Stream; import org.scijava.nativelib.NativeLoader; import org.zeromq.czmq.*; @@ -14,6 +15,18 @@ public class Zyre implements AutoCloseable{ if (System.getProperty("java.vm.vendor").contains("Android")) { System.loadLibrary("zyrejni"); } else { + Stream.of( + "zmq", + "czmq", + "zyre" + ) + .forEach(lib -> { + try { + NativeLoader.loadLibrary(lib); + } catch (Exception e) { + System.err.println("[WARN] " + e.getMessage() +" from jar. Assuming it is installed on the system."); + } + }); try { NativeLoader.loadLibrary("zyrejni"); } catch (Exception e) { diff --git a/bindings/jni/src/main/java/org/zeromq/zyre/ZyreEvent.java b/bindings/jni/src/main/java/org/zeromq/zyre/ZyreEvent.java index b16c57abe..847ef0a9e 100644 --- a/bindings/jni/src/main/java/org/zeromq/zyre/ZyreEvent.java +++ b/bindings/jni/src/main/java/org/zeromq/zyre/ZyreEvent.java @@ -6,6 +6,7 @@ */ package org.zeromq.zyre; +import java.util.stream.Stream; import org.scijava.nativelib.NativeLoader; import org.zeromq.czmq.*; @@ -14,6 +15,18 @@ public class ZyreEvent implements AutoCloseable{ if (System.getProperty("java.vm.vendor").contains("Android")) { System.loadLibrary("zyrejni"); } else { + Stream.of( + "zmq", + "czmq", + "zyre" + ) + .forEach(lib -> { + try { + NativeLoader.loadLibrary(lib); + } catch (Exception e) { + System.err.println("[WARN] " + e.getMessage() +" from jar. Assuming it is installed on the system."); + } + }); try { NativeLoader.loadLibrary("zyrejni"); } catch (Exception e) { diff --git a/bindings/python/_project.py b/bindings/python/_project.py new file mode 100644 index 000000000..70cb00794 --- /dev/null +++ b/bindings/python/_project.py @@ -0,0 +1,17 @@ +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ +NAME = "zyre" +VERSION = "2.0.1" +LICENSE = "mplv2" +DESCRIPTION = """Python bindings of: an open-source framework for proximity-based p2p apps""" +URL = "https://github.com/zeromq/zyre" +PACKAGES = ["zyre"] +REQUIRES = [ + "czmq", +] +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ diff --git a/bindings/python_cffi/zyre_cffi/Zyre.py b/bindings/python_cffi/zyre_cffi/Zyre.py index a285b8d02..d66f416f7 100644 --- a/bindings/python_cffi/zyre_cffi/Zyre.py +++ b/bindings/python_cffi/zyre_cffi/Zyre.py @@ -47,12 +47,12 @@ def set_name(self, name): """ utils.lib.zyre_set_name(self._p, utils.to_bytes(name)) - def set_header(self, name, format, ): + def set_header(self, name, format, *format_args): """ Set node header; these are provided to other nodes during discovery and come in each ENTER message. """ - utils.lib.zyre_set_header(self._p, utils.to_bytes(name), format, ) + utils.lib.zyre_set_header(self._p, utils.to_bytes(name), format, *format_args) def set_verbose(self): """ @@ -111,7 +111,7 @@ def set_interface(self, value): """ utils.lib.zyre_set_interface(self._p, utils.to_bytes(value)) - def set_endpoint(self, format, ): + def set_endpoint(self, format, *format_args): """ By default, Zyre binds to an ephemeral TCP port and broadcasts the local host name using UDP beaconing. When you call this method, Zyre will use @@ -122,7 +122,7 @@ def set_endpoint(self, format, ): that is meaningful to remote as well as local nodes). Returns 0 if the bind was successful, else -1. """ - return utils.lib.zyre_set_endpoint(self._p, format, ) + return utils.lib.zyre_set_endpoint(self._p, format, *format_args) def set_contest_in_group(self, group): """ @@ -153,28 +153,28 @@ def set_zap_domain(self, domain): """ utils.lib.zyre_set_zap_domain(self._p, utils.to_bytes(domain)) - def gossip_bind(self, format, ): + def gossip_bind(self, format, *format_args): """ Set-up gossip discovery of other nodes. At least one node in the cluster must bind to a well-known gossip endpoint, so other nodes can connect to it. Note that gossip endpoints are completely distinct from Zyre node endpoints, and should not overlap (they can use the same transport). """ - utils.lib.zyre_gossip_bind(self._p, format, ) + utils.lib.zyre_gossip_bind(self._p, format, *format_args) - def gossip_connect(self, format, ): + def gossip_connect(self, format, *format_args): """ Set-up gossip discovery of other nodes. A node may connect to multiple other nodes, for redundancy paths. For details of the gossip network design, see the CZMQ zgossip class. """ - utils.lib.zyre_gossip_connect(self._p, format, ) + utils.lib.zyre_gossip_connect(self._p, format, *format_args) - def gossip_connect_curve(self, public_key, format, ): + def gossip_connect_curve(self, public_key, format, *format_args): """ Set-up gossip discovery with CURVE enabled. """ - utils.lib.zyre_gossip_connect_curve(self._p, utils.to_bytes(public_key), format, ) + utils.lib.zyre_gossip_connect_curve(self._p, utils.to_bytes(public_key), format, *format_args) def gossip_unpublish(self, node): """ @@ -224,26 +224,26 @@ def whisper(self, peer, msg_p): Send message to single peer, specified as a UUID string Destroys message after sending """ - return utils.lib.zyre_whisper(self._p, utils.to_bytes(peer), msg_p._p) + return utils.lib.zyre_whisper(self._p, utils.to_bytes(peer), utils.ffi.new("zmsg_t **", msg_p._p)) def shout(self, group, msg_p): """ Send message to a named group Destroys message after sending """ - return utils.lib.zyre_shout(self._p, utils.to_bytes(group), msg_p._p) + return utils.lib.zyre_shout(self._p, utils.to_bytes(group), utils.ffi.new("zmsg_t **", msg_p._p)) - def whispers(self, peer, format, ): + def whispers(self, peer, format, *format_args): """ Send formatted string to a single peer specified as UUID string """ - return utils.lib.zyre_whispers(self._p, utils.to_bytes(peer), format, ) + return utils.lib.zyre_whispers(self._p, utils.to_bytes(peer), format, *format_args) - def shouts(self, group, format, ): + def shouts(self, group, format, *format_args): """ Send formatted string to a named group """ - return utils.lib.zyre_shouts(self._p, utils.to_bytes(group), format, ) + return utils.lib.zyre_shouts(self._p, utils.to_bytes(group), format, *format_args) def peers(self): """ @@ -301,6 +301,7 @@ def print_py(self): """ utils.lib.zyre_print(self._p) + @staticmethod def version(): """ Return the Zyre version for run-time API detection; returns @@ -308,6 +309,7 @@ def version(): """ return utils.lib.zyre_version() + @staticmethod def test(verbose): """ Self test of this class. diff --git a/bindings/python_cffi/zyre_cffi/ZyreEvent.py b/bindings/python_cffi/zyre_cffi/ZyreEvent.py index 636e7daca..f54b388aa 100644 --- a/bindings/python_cffi/zyre_cffi/ZyreEvent.py +++ b/bindings/python_cffi/zyre_cffi/ZyreEvent.py @@ -92,6 +92,7 @@ def print_py(self): """ utils.lib.zyre_event_print(self._p) + @staticmethod def test(verbose): """ Self test of this class. diff --git a/bindings/python_cffi/zyre_cffi/cdefs.py b/bindings/python_cffi/zyre_cffi/cdefs.py index eb79a254f..cdecef108 100644 --- a/bindings/python_cffi/zyre_cffi/cdefs.py +++ b/bindings/python_cffi/zyre_cffi/cdefs.py @@ -69,6 +69,10 @@ typedef struct _ztrie_t ztrie_t; typedef struct _zuuid_t zuuid_t; typedef struct _zhttp_client_t zhttp_client_t; +typedef struct _zhttp_server_options_t zhttp_server_options_t; +typedef struct _zhttp_server_t zhttp_server_t; +typedef struct _zhttp_request_t zhttp_request_t; +typedef struct _zhttp_response_t zhttp_response_t; // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); @@ -92,7 +96,7 @@ // Destroy an item typedef void (zchunk_destructor_fn) ( - void *hint, byte **item); + void **hint); // typedef int (zconfig_fct) ( @@ -100,7 +104,7 @@ // Destroy an item typedef void (zframe_destructor_fn) ( - void *hint, byte **item); + void **hint); // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( @@ -180,10 +184,6 @@ typedef void (ztrie_destroy_data_fn) ( void **data); -// Callback function for http response. -typedef void (zhttp_client_fn) ( - void *arg, int response_code, zchunk_t *data); - // CLASS: zactor // Create a new actor passing arbitrary arguments reference. zactor_t * @@ -514,7 +514,7 @@ // Create a new chunk from memory. Take ownership of the memory and calling the destructor // on destroy. zchunk_t * - zchunk_frommem (byte **data_p, size_t size, zchunk_destructor_fn destructor, void *hint); + zchunk_frommem (void *data, size_t size, zchunk_destructor_fn destructor, void *hint); // Destroy a chunk void @@ -1138,7 +1138,7 @@ // Create a new frame from memory. Take ownership of the memory and calling the destructor // on destroy. zframe_t * - zframe_frommem (byte **data_p, size_t size, zframe_destructor_fn destructor, void *hint); + zframe_frommem (void *data, size_t size, zframe_destructor_fn destructor, void *hint); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use @@ -3710,6 +3710,14 @@ void zsys_version (int *major, int *minor, int *patch); +// Format a string using printf formatting, returning a freshly allocated +// buffer. If there was insufficient memory, returns NULL. Free the returned +// string using zstr_free(). The hinted version allows to optimize by using +// a larger starting buffer size (known to/assumed by the developer) and so +// avoid reallocations. +char * + zsys_sprintf_hint (int hint, const char *format, ...); + // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). @@ -4220,36 +4228,232 @@ void zhttp_client_destroy (zhttp_client_t **self_p); -// Send a get request to the url, headers is optional. -// Use arg to identify response when making multiple requests simultaneously. -// Timeout is in milliseconds, use -1 or 0 to wait indefinitely. +// Self test of this class. +void + zhttp_client_test (bool verbose); + +// CLASS: zhttp_server +// Create a new http server +zhttp_server_t * + zhttp_server_new (zhttp_server_options_t *options); + +// Destroy an http server +void + zhttp_server_destroy (zhttp_server_t **self_p); + +// Return the port the server is listening on. int - zhttp_client_get (zhttp_client_t *self, const char *url, zlistx_t *headers, int timeout, zhttp_client_fn handler, void *arg); + zhttp_server_port (zhttp_server_t *self); -// Send a post request to the url, headers is optional. -// Use arg to identify response when making multiple requests simultaneously. -// Timeout is in milliseconds, use -1 or 0 to wait indefinitely. +// Self test of this class. +void + zhttp_server_test (bool verbose); + +// CLASS: zhttp_server_options +// Create a new zhttp_server_options. +zhttp_server_options_t * + zhttp_server_options_new (void); + +// Create options from config tree. +zhttp_server_options_t * + zhttp_server_options_from_config (zconfig_t *config); + +// Destroy the zhttp_server_options. +void + zhttp_server_options_destroy (zhttp_server_options_t **self_p); + +// Get the server listening port. int - zhttp_client_post (zhttp_client_t *self, const char *url, zlistx_t *headers, zchunk_t *body, int timeout, zhttp_client_fn handler, void *arg); + zhttp_server_options_port (zhttp_server_options_t *self); -// Invoke callback function for received responses. -// Should be call after zpoller wait method. -// Returns 0 if OK, -1 on failure. +// Set the server listening port +void + zhttp_server_options_set_port (zhttp_server_options_t *self, int port); + +// Get the address sockets should connect to in order to receive requests. +const char * + zhttp_server_options_backend_address (zhttp_server_options_t *self); + +// Set the address sockets should connect to in order to receive requests. +void + zhttp_server_options_set_backend_address (zhttp_server_options_t *self, const char *address); + +// Self test of this class. +void + zhttp_server_options_test (bool verbose); + +// CLASS: zhttp_request +// Create a new http request. +zhttp_request_t * + zhttp_request_new (void); + +// Destroy an http request. +void + zhttp_request_destroy (zhttp_request_t **self_p); + +// Receive a new request from zhttp_server. +// Return the underlying connection if successful, to be used when calling zhttp_response_send. +void * + zhttp_request_recv (zhttp_request_t *self, zsock_t *sock); + +// Send a request to zhttp_client. +// Url and the request path will be concatenated. +// This behavior is useful for url rewrite and reverse proxy. +// +// Send also allow two user provided arguments which will be returned with the response. +// The reason for two, is to be able to pass around the server connection when forwarding requests or both a callback function and an arg. int - zhttp_client_execute (zhttp_client_t *self); + zhttp_request_send (zhttp_request_t *self, zhttp_client_t *client, int timeout, void *arg, void *arg2); + +// Get the request method +const char * + zhttp_request_method (zhttp_request_t *self); + +// Set the request method +void + zhttp_request_set_method (zhttp_request_t *self, const char *method); + +// Get the request url. +// When receiving a request from http server this is only the path part of the url. +const char * + zhttp_request_url (zhttp_request_t *self); + +// Set the request url +// When sending a request to http client this should be full url. +void + zhttp_request_set_url (zhttp_request_t *self, const char *url); + +// Get the request content type +const char * + zhttp_request_content_type (zhttp_request_t *self); + +// Set the request content type +void + zhttp_request_set_content_type (zhttp_request_t *self, const char *content_type); + +// Get the content length of the request +size_t + zhttp_request_content_length (zhttp_request_t *self); + +// Get the headers of the request +zhash_t * + zhttp_request_headers (zhttp_request_t *self); + +// Get the content of the request. +const char * + zhttp_request_content (zhttp_request_t *self); + +// Get the content of the request. +char * + zhttp_request_get_content (zhttp_request_t *self); + +// Set the content of the request. +// Content must by dynamically allocated string. +// Takes ownership of the content. +void + zhttp_request_set_content (zhttp_request_t *self, char **content); + +// Set the content of the request.. +// The content is assumed to be constant-memory and will therefore not be copied or deallocated in any way. +void + zhttp_request_set_content_const (zhttp_request_t *self, const char *content); + +// Set the content to NULL +void + zhttp_request_reset_content (zhttp_request_t *self); -// Wait until a response is ready to be consumed. -// Use when you need a synchronize response. +// Match the path of the request. +// Support wildcards with '%s' symbol inside the match string. +// Matching wildcards until the next '/', '?' or '\0'. +// On successful match the variadic arguments will be filled with the matching strings. +// On successful match the method is modifying the url field and break it into substrings. +// If you need to use the url, do it before matching or take a copy. // -// The timeout should be zero or greater, or -1 to wait indefinitely. +// User must not free the variadic arguments as they are part of the url. +// +// To use the percent symbol, just double it, e.g "%%something". // -// Returns 0 if a response is ready, -1 and otherwise. errno will be set to EAGAIN if no response is ready. +// Example: +// if (zhttp_request_match (request, "POST", "/send/%s/%s", &name, &id)) +bool + zhttp_request_match (zhttp_request_t *self, const char *method, const char *path, ...); + +// Self test of this class. +void + zhttp_request_test (bool verbose); + +// CLASS: zhttp_response +// Create a new zhttp_response. +zhttp_response_t * + zhttp_response_new (void); + +// Destroy the zhttp_response. +void + zhttp_response_destroy (zhttp_response_t **self_p); + +// Send a response to a request. +// Returns 0 if successful and -1 otherwise. int - zhttp_client_wait (zhttp_client_t *self, int timeout); + zhttp_response_send (zhttp_response_t *self, zsock_t *sock, void **connection); + +// Receive a response from zhttp_client. +// On success return 0, -1 otherwise. +// +// Recv returns the two user arguments which was provided with the request. +// The reason for two, is to be able to pass around the server connection when forwarding requests or both a callback function and an argument. +int + zhttp_response_recv (zhttp_response_t *self, zhttp_client_t *client, void **arg, void **arg2); + +// Get the response content type +const char * + zhttp_response_content_type (zhttp_response_t *self); + +// Set the content type of the response. +void + zhttp_response_set_content_type (zhttp_response_t *self, const char *value); + +// Get the status code of the response. +uint32_t + zhttp_response_status_code (zhttp_response_t *self); + +// Set the status code of the response. +void + zhttp_response_set_status_code (zhttp_response_t *self, uint32_t status_code); + +// Get the headers of the response. +zhash_t * + zhttp_response_headers (zhttp_response_t *self); + +// Get the content length of the response +size_t + zhttp_response_content_length (zhttp_response_t *self); + +// Get the content of the response. +const char * + zhttp_response_content (zhttp_response_t *self); + +// Get the content of the response. +char * + zhttp_response_get_content (zhttp_response_t *self); + +// Set the content of the response. +// Content must by dynamically allocated string. +// Takes ownership of the content. +void + zhttp_response_set_content (zhttp_response_t *self, char **content); + +// Set the content of the response. +// The content is assumed to be constant-memory and will therefore not be copied or deallocated in any way. +void + zhttp_response_set_content_const (zhttp_response_t *self, const char *content); + +// Set the content to NULL +void + zhttp_response_reset_content (zhttp_response_t *self); // Self test of this class. void - zhttp_client_test (bool verbose); + zhttp_response_test (bool verbose); ''') diff --git a/bindings/qt/src/qzframe.cpp b/bindings/qt/src/qzframe.cpp index a4af38e89..26d5a91c6 100644 --- a/bindings/qt/src/qzframe.cpp +++ b/bindings/qt/src/qzframe.cpp @@ -41,9 +41,9 @@ QZframe* QZframe::from (const QString &string, QObject *qObjParent) /// // Create a new frame from memory. Take ownership of the memory and calling the destructor // on destroy. -QZframe* QZframe::frommem (byte **dataP, size_t size, zframe_destructor_fn destructor, void *hint, QObject *qObjParent) +QZframe* QZframe::frommem (void *data, size_t size, zframe_destructor_fn destructor, void *hint, QObject *qObjParent) { - return new QZframe (zframe_frommem (dataP, size, destructor, hint), qObjParent); + return new QZframe (zframe_frommem (data, size, destructor, hint), qObjParent); } /// diff --git a/bindings/qt/src/qzframe.h b/bindings/qt/src/qzframe.h index 378e00383..a0fd20cb4 100644 --- a/bindings/qt/src/qzframe.h +++ b/bindings/qt/src/qzframe.h @@ -30,7 +30,7 @@ class QT_ZYRE_EXPORT QZframe : public QObject // Create a new frame from memory. Take ownership of the memory and calling the destructor // on destroy. - static QZframe* frommem (byte **dataP, size_t size, zframe_destructor_fn destructor, void *hint, QObject *qObjParent = 0); + static QZframe* frommem (void *data, size_t size, zframe_destructor_fn destructor, void *hint, QObject *qObjParent = 0); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use diff --git a/ci_deploy_obs.sh b/ci_deploy_obs.sh index b79e46758..c3f2e3ab6 100755 --- a/ci_deploy_obs.sh +++ b/ci_deploy_obs.sh @@ -14,10 +14,9 @@ if [ "$BUILD_TYPE" == "default" -a -n "${GH_TOKEN}" -a -n "${OBS_STABLE_TOKEN}" # not possible to edit files on OBS with secure tokens, and it is not # possible to dynamically fetch the latest git tag either. TAG_SHA=$(curl -s -H "Authorization: token ${GH_TOKEN}" -X GET https://api.github.com/repos/zeromq/zyre/git/refs/tags/${TRAVIS_TAG} | grep -o -P '(?<=sha":\s).*(?=,)') - curl -H "Authorization: token ${GH_TOKEN}" -X POST --data "{\"ref\":\"refs/heads/tmp_obs_release_branch\",\"sha\":${TAG_SHA}}" https://api.github.com/repos/zeromq/zyre/git/refs + curl -H "Authorization: token ${GH_TOKEN}" -X DELETE https://api.github.com/repos/zeromq/zyre/git/refs/heads/latest_release + curl -H "Authorization: token ${GH_TOKEN}" -X POST --data "{\"ref\":\"refs/heads/latest_release\",\"sha\":${TAG_SHA}}" https://api.github.com/repos/zeromq/zyre/git/refs + sleep 2 # try to avoid races if Github is slow curl -H "Authorization: Token ${OBS_STABLE_TOKEN}" -X POST https://api.opensuse.org/trigger/runservice curl -H "Authorization: Token ${OBS_DRAFT_TOKEN}" -X POST https://api.opensuse.org/trigger/runservice - # give some time for the git clone to happen before deleting the temp branch - sleep 60 - curl -H "Authorization: token ${GH_TOKEN}" -X DELETE https://api.github.com/repos/zeromq/zyre/git/refs/heads/tmp_obs_release_branch fi diff --git a/configure.ac b/configure.ac index 32c772904..34e83576e 100644 --- a/configure.ac +++ b/configure.ac @@ -635,22 +635,30 @@ AS_IF([test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"], [AS_IF([test -n "$CC"],[AS_IF([$CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null && test "x$GCC" = "xyes"], [AC_MSG_NOTICE([Enabling pedantic errors for GNU C]) CFLAGS="$CFLAGS -pedantic -Wall -Werror -Werror=format-security"], - [AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)]) - AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C: $CC])]) - ])]) + [AS_IF([$CC --version 2>&1 | grep 'clang version' > /dev/null], + [AC_MSG_NOTICE([Enabling pedantic errors for clang C]) + CFLAGS="$CFLAGS -pedantic -Wall -Werror -Werror=format-security"], + [AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU or clang C)]) + AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C: $CC])]) + ])])]) AS_IF([test -n "$CXX"],[AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null && test "x$GCC" = "xyes"], [AC_MSG_NOTICE([Enabling pedantic errors for GNU C++]) CXXFLAGS="$CXXFLAGS -pedantic -Wall -Werror -Werror=format-security"], - [AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)]) - AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C++: $CXX])]) - ])]) + [AS_IF([$CXX --version 2>&1 | grep 'clang version' > /dev/null], + [AC_MSG_NOTICE([Enabling pedantic errors for clang C++]) + CXXFLAGS="$CXXFLAGS -pedantic -Wall -Werror -Werror=format-security"], + [AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU or clang C++)]) + AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C++: $CXX])]) + ])])]) AS_IF([test -n "$CPP"],[AS_IF([$CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null && test "x$GCC" = "xyes"], [AC_MSG_NOTICE([Enabling pedantic errors for GNU CPP preprocessor]) - CPPFLAGS="$CPPFLAGS -pedantic -Werror -Wall -Wc++-compat" - ], - [AC_MSG_NOTICE([Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)]) - AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for CPP: $CPP])]) - ])]) + CPPFLAGS="$CPPFLAGS -pedantic -Werror -Wall -Wc++-compat"], + [AS_IF([$CXX --version 2>&1 | grep 'clang version' > /dev/null], + [AC_MSG_NOTICE([Enabling pedantic errors for clang CPP preprocessor]) + CPPFLAGS="$CPPFLAGS -pedantic -Werror -Wall -Wc++-compat"], + [AC_MSG_NOTICE([Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU or clang CPP)]) + AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for CPP: $CPP])]) + ])])]) ]) # Optional project-local hook to (re-)define some variables that can be used @@ -664,7 +672,7 @@ AC_CONFIG_FILES([Makefile doc/Makefile include/Makefile src/libzyre.pc - ]) + ]) # Optional project-local hook to put some finishing touches in your configure diff --git a/src/zyre_classes.h b/src/zyre_classes.h index a98e74ec1..d3b7b249f 100644 --- a/src/zyre_classes.h +++ b/src/zyre_classes.h @@ -25,8 +25,6 @@ // External API #include "../include/zyre.h" -// Extra headers - // Opaque class structures to allow forward references #ifndef ZRE_MSG_T_DEFINED typedef struct _zre_msg_t zre_msg_t; @@ -49,6 +47,8 @@ typedef struct _zyre_node_t zyre_node_t; #define ZYRE_NODE_T_DEFINED #endif +// Extra headers + // Internal API #include "zre_msg.h"